-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwbanners.py
27 lines (25 loc) · 996 Bytes
/
twbanners.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
import os, json, urllib, time
try:
os.mkdir('banners')
except:
pass
for friend in os.listdir('friends'):
if not os.path.isdir('friends/' + friend):
continue
for theirfriend in os.listdir('friends/' + friend):
f = open('friends/' + friend + '/' + theirfriend)
try:
profile = json.load(f)
except Exception as e:
print "[%s] Exception: %s // %s // %s" % (time.strftime("%Y%m%d %H:%M:%S"), type(e), e, friend + '/' + theirfriend)
continue
try:
url = profile['profile_banner_url']
filename = 'banners/' + url.replace('/', '-').replace(':', '-') + '.jpg'
if(os.path.exists(filename)):
print 'already got ' + theirfriend
continue
urllib.urlretrieve(url, filename)
except Exception as e:
print "[%s] Exception: %s // %s // %s" % (time.strftime("%Y%m%d %H:%M:%S"), type(e), e, theirfriend)
continue