Skip to content

Instantly share code, notes, and snippets.

@greenarrow
Created October 7, 2011 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenarrow/1270615 to your computer and use it in GitHub Desktop.
Save greenarrow/1270615 to your computer and use it in GitHub Desktop.
Scuddle
#!/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