@@ -1,10 +1,10 @@
1#!/usr/bin/env python
1#!/usr/bin/env python
3## Flickr (Images)
3## Flickr (Images)
5# @website https://www.flickr.com
5# @website https://www.flickr.com
6−# @provide-api yes (https://secure.flickr.com/services/api/flickr.photos.search.html)
6+# @provide-api yes (https://secure.flickr.com/services/api/flickr.photos.search.html)
8# @using-api yes
8# @using-api yes
9# @results JSON
9# @results JSON
10# @stable yes
10# @stable yes
@@ -18,16 +18,20 @@ categories = ['images']
19nb_per_page = 15
19nb_per_page = 15
20paging = True
20paging = True
21−api_key= None
21+api_key = None
24−url = 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key={api_key}&{text}&sort=relevance&extras=description%2C+owner_name%2C+url_o%2C+url_z&per_page={nb_per_page}&format=json&nojsoncallback=1&page={page}'
24+url = 'https://api.flickr.com/services/rest/?method=flickr.photos.search' +\
25+ '&api_key={api_key}&{text}&sort=relevance' +\
26+ '&extras=description%2C+owner_name%2C+url_o%2C+url_z' +\
27+ '&per_page={nb_per_page}&format=json&nojsoncallback=1&page={page}'
25photo_url = 'https://www.flickr.com/photos/{userid}/{photoid}'
28photo_url = 'https://www.flickr.com/photos/{userid}/{photoid}'
27paging = True
30paging = True
29def build_flickr_url(user_id, photo_id):
33def build_flickr_url(user_id, photo_id):
30− return photo_url.format(userid=user_id,photoid=photo_id)
34+ return photo_url.format(userid=user_id, photoid=photo_id)
33def request(query, params):
37def request(query, params):
@@ -40,7 +44,7 @@ def request(query, params):
41def response(resp):
45def response(resp):
42 results = []
46 results = []
44 search_results = loads(resp.text)
48 search_results = loads(resp.text)
46 # return empty array if there are no results
50 # return empty array if there are no results
@@ -64,11 +68,14 @@ def response(resp):
64 url = build_flickr_url(photo['owner'], photo['id'])
68 url = build_flickr_url(photo['owner'], photo['id'])
66 title = photo['title']
70 title = photo['title']
68− content = '<span class="photo-author">'+ photo['ownername'] +'</span><br />'
72+ content = '<span class="photo-author">' +\
69−
73+ photo['ownername'] +\
75+ '<span class="description">' +\
70− content = content + '<span class="description">' + photo['description']['_content'] + '</span>'
76+ photo['description']['_content'] +\
72 # append result
79 # append result
73 results.append({'url': url,
80 results.append({'url': url,
74 'title': title,
81 'title': title,