-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoundgrab.py
More file actions
82 lines (51 loc) · 1.7 KB
/
soundgrab.py
File metadata and controls
82 lines (51 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import requests, sys, re
# SoundGrab
# SoundCloud MP3 downloader
# Please use this script to download free tracks!
# Coded by MGF15 - GitHub (http://github.com/MGF15)
tr = 'https://api.soundcloud.com/i1/tracks/'
tr2 = '/streams?client_id='
id = '5Fs6ZkkdEgn8Ygc7xKYumtor6mrxIhb3' # be careful with this ;) please!
ver = '&app_version=14823339819'
def get(url):
print '[+] Grabbing %s' % url
site = requests.get(url).text
track = re.findall(r':tracks:(.*?)"', site) # get track id
print '[+] Got track id'
name = re.findall(r'Stream(.*?)by(.*?)from', site) # get track name
trackid = track[0]
apidown = tr + trackid + tr2 + id + ver
getfile = requests.get(apidown).text
if getfile == "":
print "[-] it seems like client id has expired ! "
exit()
findfile = re.findall(r'http_mp3_128_url":"(.*?)"',getfile) # our download link
refix = findfile[0].replace('\u0026', '&')
fname = name[0][1] + '-' + name[0][0]
return refix, fname
def downmp3(mp3file, name):
file = open(name + '.mp3', 'wb')
mp = requests.get(mp3file, stream=True)
size = round(int(mp.headers['Content-Length'])/1024.0/1024.0,2)
n = int(mp.headers['Content-Length'])
print '[+] File size :' , size, 'Mb'
print '[*] File name : '+ name +'.mp3'
m = 0
while m <= n:
for i in mp.iter_content(1024):
if i:
m += 1024
file.write(i)
sys.stdout.write('\r')
sys.stdout.write("[*] Downloading [%-50s] %d%% " % ('*'*((m*100/n)/2), m*100/n))
sys.stdout.flush()
print '\n[+] Download has been done!'
return file
try:
g = sys.argv[1]
file = get(g)
f = file[0]
f2 = file[1]
down = downmp3(f, f2)
except:
print '\n[-] soundgrab.py <trackurl>\n[-] Or check your internet connection!'