Last active
July 8, 2018 07:21
-
-
Save riza/6f3c2614ed6f0d001225 to your computer and use it in GitHub Desktop.
Soundcloud Playlist Downloader
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/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 "#---------------------------------------------#" | |
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" | |
@kulturlupenguen Track titles UTF-8 problem :(
Use Python 3.
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
Filenames are could be the tracks' titles.