-
Notifications
You must be signed in to change notification settings - Fork 4
/
flickr.py
34 lines (28 loc) · 951 Bytes
/
flickr.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
import flickrapi
import json
# TARGET_TITLE = '20140501'
# Belows informations seems public.(I can't sure for api key.
# even though I didn't exposed its secret key, it doesn't mean
# api key is public information or not, anyway, there is no
# problem of exposing my api key.)
api_key = 'c165ac58362fc00ad075c667ef060dc1'
api_secret = '7f5c05b7d82779ba'
myid = '123519224@N08'
def fetch_images(title):
fl = flickrapi.FlickrAPI(api_key, api_secret)
res = fl.photos_search(
user_id = myid, per_page = '20',
extras = 'url_o',
format = 'json')
photos = json.loads(res.decode('utf-8'))[u'photos'][u'photo']
for photo in photos:
if photo[u'title'] != title:
continue
url = photo[u'url_o']
yield url
if __name__ == "__main__":
# 1. download them
download_images('20150328')
# 2. list images
# for it in fetch_images('20140501'):
# print it