Skip to content

Instantly share code, notes, and snippets.

@riza
Last active July 8, 2018 07:21
Show Gist options
  • Save riza/6f3c2614ed6f0d001225 to your computer and use it in GitHub Desktop.
Save riza/6f3c2614ed6f0d001225 to your computer and use it in GitHub Desktop.
Soundcloud Playlist Downloader
#!/usr/bin/python
#-*- coding: utf-8 -*-
import os
try:
import requests
except ImportError, e:
print u"Lütfen requests modülünü kurun!"
exit()
# şu alt tarafı yusuf(kulturlupenguen) karrrdeşimden copy paste yaptım :(
print "#=============================================#"
print "# #"
print "# Soundcloud Playlist Downloader #"
print "# Rıza Sabuncu #"
print "# #"
print "#---------------------------------------------#"
print "# #"
print "# twitter : rizasabuncu #"
print "# facebook : dentrimental.sh #"
print "# github : rizasabuncu #"
print "# blog : 32byte.org #"
print "# #"
print "#---------------------------------------------#"
print
print
print
API_KEY = "GET API KEY XDXD"
URL = raw_input("Playlist linki giriniz : ")
API_LINK = 'http://api.soundcloud.com/resolve.json?url=' + URL + '&client_id=' + API_KEY
r = requests.get(API_LINK)
data = r.json()
playlistName = data["title"] + ""
if not os.path.exists(playlistName):
os.mkdir(playlistName)
BASE_PATH = os.path.abspath(os.path.dirname(__file__)) + "/" + playlistName
for tracks in data["tracks"]:
parcaAdi = tracks["title"]
print parcaAdi + " indiriliyor.."
streamData = tracks["stream_url"] + "?client_id=" + API_KEY
path = os.path.join(BASE_PATH, '{0:s}.mp3'.format(tracks["permalink"]))
data = requests.get(streamData, stream=True)
with open(path, 'wb+') as f:
for chunk in data.iter_content(chunk_size=32*1024):
if chunk:
f.write(chunk)
f.flush()
print playlistName + " indirildi."
print "Feedback : rizasabuncu"
@riza
Copy link
Author

riza commented Jul 4, 2014

@kulturlupenguen Track titles UTF-8 problem :(

@tibbiyelininja
Copy link

Use Python 3.

@zarrarkhaan
Copy link

Hello I created a script in php for downloading playlist from soundcloud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment