A SoundCloud(R) export tool
Hoi. OK, so these last couple of weeks I've been cleaning up things in my SoundCloud account, as there were lots of cover songs and some mixes and remixes that triggered the "SoundCloud copyright system".There has been many rounds back and forth, and I even had to clear out private tracks for example of cover songs, which is strange.
Anyway, I figured that it would be nice to be able to export all of the content I've created over the last couple of years, just in case SoundCloud decides to "terminate" my account, files could be lost etc.
I downloaded the python-soundcloud package, and started getting to work. This module has been created by some person over @ SoundCloud. After some trying and failing it looked like it wasn't able to download tracks with the package, so I forked it on github ( here https://github.com/morphex/soundcloud-python ). Using that module and the following code in a script called for example download.py should do the trick.
# The following code is available under the GPL, version 3, available here: http://www.gnu.org/copyleft/gpl.html import soundcloud, urllib2, urllib from soundcloud.request import make_request import os CLIENT_ID = 'REGISTER ON SOUNDCLOUD AS APP' CLIENT_SECRET = 'REGISTER ON SOUNDCLOUD AS APP' USERNAME='YOUR SOUNDCLOUD EMAIL' PASSWORD='YOUR SOUNDCLOUD PASSWORD' LIMIT = 1000 # Maximum number of tracks to download # a limit in case something goes wrong # so we don't hammer the system. def download_tracks(output_directory): client = soundcloud.Client( client_id=CLIENT_ID, client_secret=CLIENT_SECRET, username=USERNAME, password=PASSWORD, ) for track in client.get('/me/tracks', limit=LIMIT): path = track.download_url[len('https://api.soundcloud.com/')-1:] filename, data = client.get(track.download_url) output = open(os.path.join(output_directory, filename), 'w') output.write(data) output.close() print 'Downloaded file: ', filename if __name__ == '__main__': import sys if len(sys.argv) != 2: raise SystemExit, 'output directory required' import os output_directory = sys.argv[1] try: os.mkdir(output_directory) except OSError: pass download_tracks(output_directory)
[Permalink] [By morphex] [Technology (Atom feed)] [03 Jan 01:55 Europe/Oslo]