Skip to content

Instantly share code, notes, and snippets.

@riza
Last active August 29, 2015 14:03
Show Gist options
  • Save riza/4702ce011fac36bc1e4e to your computer and use it in GitHub Desktop.
Save riza/4702ce011fac36bc1e4e to your computer and use it in GitHub Desktop.
Soundcloud Downloader with Python
#!/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ı"
@tibbiyelininja
Copy link

try:
    import requests
except ImportError, e:
    print u"Lütfen requests modülünü kurun!"
    exit()

@riza
Copy link
Author

riza commented Jul 1, 2014

@haydarsahin34 thnx Haydar :)
@kulturlupenguen thnx :)

@mucahit
Copy link

mucahit commented Jul 1, 2014

hl qrdşm.

@riza
Copy link
Author

riza commented Jul 2, 2014

@mtutuncu ty qnq ;)99

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