Created
October 7, 2011 15:51
-
-
Save greenarrow/1270615 to your computer and use it in GitHub Desktop.
Scuddle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Pass in SoundCloud page URLs as arguments and all MP3s will be downloaded into the current directory. | |
This is a demonstration only and you should almost definitely not use it. | |
""" | |
import urllib | |
import re | |
import subprocess | |
import time | |
import sys | |
# Time to pause between downloads (be nice) | |
PAUSE = 60 | |
RE_TRACK = re.compile(r'"title":"([^"]+)".+?"streamUrl":"(http://[^"]+)"') | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
print "at least one url must be provided" | |
for page in sys.argv[1:]: | |
print "reading page %s" % page | |
html = urllib.urlopen(page).read() | |
results = RE_TRACK.findall(html) | |
print "found %d tracks" % len(results) | |
for title, url in results: | |
title = str(title).replace("\u0026amp;", "and") | |
print "downloading %s\n%s" % (title, url) | |
assert subprocess.Popen( | |
["wget", "-O", "%s.mp3" % title, url] | |
).wait() == 0 | |
time.sleep(PAUSE) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment