A Cool linux script that gets top 100 songs

edited October 2016 in Programming
I thought maybe shed some light on a Linux script that I have made in the past semester of College. Since there was a lot of debate about whether or not Linux will prevail.

In this script, the general moral is that it will download the top songs on the billboard 100 and the top 100 songs on UK top chart, then it will save it to a temp file so the sed editor can take out the html tags.
clear
                        wget http://www.billboard.com/charts/hot-100
                        echo "As of `date |cut -c1-11`  these are the Top 100 songs
These are the top song titles from the Bilboard top 100 website
                        " > Hsongs
                        grep 'h2 class="chart-row__song"'* hot-100 > songs
                        #Found at http://stackoverflow.com/questions/19878056/sed-remove-tags-from-html-file
                        sed -e 's/<[^>]*>//g' songs > songs1 &
                        # END FOUND
                        mv songs1 Top2
                        cat -n Top2 >> Hsongs
                        mv Hsongs Us-Top-songs
                        echo "This file will be saved by default as US-Top-Songs in your home directory."
                        less Us-Top-songs
                        clear
                        rm hot-100 songs Top2
                #Top Uk charts
                        echo "This is the U.K Top charts."
                        echo -n "Attempting to download Top 100 songs from Official Charts"
                sleep 4
                        clear
                        wget http://www.officialcharts.com/charts/
                        echo "As of `date |cut -c1-11`  these are the Top 100 songs
These are the top song titles from the Official Charts top 100 website
" > Hsongs
                        grep '<a href="/search/singles/'* index.html > songs
                        sed -e 's/<[^>]*>//g' songs > songs1 &
                        mv songs1 Top2
                        cat -n Top2 >> Hsongs
                        mv Hsongs Top-songs-UK
                        echo "This file will be saved by default as Top-songs-uk in your home directory."
                sleep 3
                        less Top-songs-UK
                        clear
                        rm index.html songs Top2

Tell me what you think! You have my permission to make edits on this code.

Comments

  • Nice script!

    I'd want to use this if I was sitting in front of a Linux machine right now. Unfortunately, I'm using Windows 10 (ugh).

    One question though: How could I adapt this to get the top 100 songs in the US? I'm kind of a noob at Linux programming.

    Thanks,
  • Thank you! This script grabs both the us top 100 songs and the top 100 UK songs.
    This grabs the Top 100 songs in the US from Billboard.com.
                            clear
                            wget http://www.billboard.com/charts/hot-100
                            echo "As of `date |cut -c1-11`  these are the Top 100 songs
    These are the top song titles from the Bilboard top 100 website
                            " > Hsongs
                            grep 'h2 class="chart-row__song"'* hot-100 > songs
                            #Found at http://stackoverflow.com/questions/19878056/sed-remove-tags-from-html-file
                            sed -e 's/<[^>]*>//g' songs > songs1 &
                            # END FOUND
                            mv songs1 Top2
                            cat -n Top2 >> Hsongs
                            mv Hsongs Us-Top-songs
    
    And this grabs the top songs from the U.K Top charts.
                    #Top Uk charts
                            echo "This is the U.K Top charts."
                            echo -n "Attempting to download Top 100 songs from Official Charts"
                    sleep 4
                            clear
                            wget http://www.officialcharts.com/charts/
                            echo "As of `date |cut -c1-11`  these are the Top 100 songs
    These are the top song titles from the Official Charts top 100 website
    " > Hsongs
                            grep '<a href="/search/singles/'* index.html > songs
                            sed -e 's/<[^>]*>//g' songs > songs1 &
                            mv songs1 Top2
                            cat -n Top2 >> Hsongs
                            mv Hsongs Top-songs-UK
                            echo "This file will be saved by default as Top-songs-uk in your home directory."
                    sleep 3
                            less Top-songs-UK
                            clear
                            rm index.html songs Top2
    
  • Thanks!

    -- Erito
Sign In or Register to comment.