Script to download the latest billboard top 100 songs from youtube using python packages instantmusic and pyquery.


~/bin/bb100

#!/usr/local/bin/python
from pyquery import PyQuery as pq
from subprocess import call

data = pq(url='http://www.billboard.com/charts/hot-100')
hits = zip(iter(data('.chart-row__artist')), iter(data('.chart-row__song')))

for idx, (artist, song) in enumerate(hits):
    title = '%s - %s' % (pq(artist).text(), pq(song).text())
    print 'Downloading: #%d - %s' % (idx, title)
    call(['instantmusic', '-p', '-s', title])
    print ''

You can further change -p to -q to hide the download script’s output.

Also, make sure to cd ~/Music before running this one.