-
Notifications
You must be signed in to change notification settings - Fork 0
/
soundcrawl.py
45 lines (40 loc) · 1.01 KB
/
soundcrawl.py
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
#soundcrawl.py
#crawl and output your friend's favorite songs. + your recent dashboard songs
#soundcloud v0.5.0 module
#v088
import time
from urllib2 import HTTPError
import soundcloud
client = soundcloud.Client(
client_id='',
client_secret='',
username='',
password='')
text = open("new.txt", "w")
followers = client.get('/me/followings').collection
dashboard = client.get('/me/activities/tracks').collection
for users in followers:
user = users
o = 0
print users.permalink
try:
favs = client.get ('/users/%s/favorites'%(user.permalink), limit = 200, offset = o)
except HTTPError, e:
print e
continue
while favs:
time.sleep(1)
try:
favs = client.get ('/users/%s/favorites'%(user.permalink), limit = 200, offset = o)
except HTTPError, e:
o=o+200
print e
continue
o = o+200
for x in favs:
text.write(x.permalink_url + '\n')
print x.permalink_url
for track in dashboard:
if track.origin.obj:
text.write(track.origin.permalink_url + '\n')
print track.origin.permalink_url