Skip to content

Instantly share code, notes, and snippets.

@timkofu
Created March 22, 2015 15:28
Show Gist options
  • Save timkofu/df0642936123f9ae7178 to your computer and use it in GitHub Desktop.
Save timkofu/df0642936123f9ae7178 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
from num2words import num2words
import time
import subprocess
import re
import random
maxlen = 31
while maxlen:
mp3_link = [x['href'] for x in BeautifulSoup(requests.get('http://musicforprogramming.net/?c{}'.format(num2words(maxlen).replace('-',''))).text).find_all('a') if re.search('\.mp3', x['href'])][0]
for output in iter(subprocess.Popen(['/usr/bin/axel', mp3_link], stdout=subprocess.PIPE).stdout.readline, b""):
print(output)
maxlen -= 1
time.sleep(random.randint(30,67))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment