Last active
August 29, 2015 14:03
-
-
Save riza/4702ce011fac36bc1e4e to your computer and use it in GitHub Desktop.
Soundcloud Downloader with Python
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 -*- | |
# requests modülü gerekir | |
import os | |
try: | |
import requests | |
except ImportError, e: | |
print u"Lütfen requests modülünü kurun!" | |
exit() | |
print "********************" | |
print "* Soundcloud *" | |
print "* Downloader *" | |
print "* *" | |
print "* Rıza Sabuncu *" | |
print "* git: rizasabuncu *" | |
print "* *" | |
print "********************" | |
API_KEY = "CLIENT_ID" # developers.soundcloud.com | |
URL = raw_input("SC linki giriniz : ") | |
API_LINK = 'http://api.soundcloud.com/resolve.json?url=' + URL + '&client_id=' + API_KEY | |
BASE_PATH = os.path.abspath(os.path.dirname(__file__)) | |
r = requests.get(API_LINK) | |
data = r.json() | |
STREAM_URL = data["stream_url"] + "?client_id=" + API_KEY | |
path = os.path.join(BASE_PATH, '{0:s}.mp3'.format(data["permalink"])) | |
data = requests.get(STREAM_URL, 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 u"İndirme başarılı" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@haydarsahin34 thnx Haydar :)
@kulturlupenguen thnx :)