.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.flickr Namespace Reference

Functions

 build_flickr_url (user_id, photo_id)
 
 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['images']
 
int nb_per_page = 15
 
bool paging = True
 
 api_key = None
 
tuple url
 
str photo_url = 'https://www.flickr.com/photos/{userid}/{photoid}'
 

Detailed Description

 Flickr (Images)

 More info on api-key : https://www.flickr.com/services/apps/create/

Function Documentation

◆ build_flickr_url()

searx.engines.flickr.build_flickr_url ( user_id,
photo_id )

Definition at line 39 of file flickr.py.

39def build_flickr_url(user_id, photo_id):
40 return photo_url.format(userid=user_id, photoid=photo_id)
41
42

Referenced by searx.engines.flickr.response().

+ Here is the caller graph for this function:

◆ request()

searx.engines.flickr.request ( query,
params )

Definition at line 43 of file flickr.py.

43def request(query, params):
44 params['url'] = url.format(
45 text=urlencode({'text': query}), api_key=api_key, nb_per_page=nb_per_page, page=params['pageno']
46 )
47 return params
48
49

◆ response()

searx.engines.flickr.response ( resp)

Definition at line 50 of file flickr.py.

50def response(resp):
51 results = []
52
53 search_results = loads(resp.text)
54
55 # return empty array if there are no results
56 if 'photos' not in search_results:
57 return []
58
59 if 'photo' not in search_results['photos']:
60 return []
61
62 photos = search_results['photos']['photo']
63
64 # parse results
65 for photo in photos:
66 if 'url_o' in photo:
67 img_src = photo['url_o']
68 elif 'url_z' in photo:
69 img_src = photo['url_z']
70 else:
71 continue
72
73 # For a bigger thumbnail, keep only the url_z, not the url_n
74 if 'url_n' in photo:
75 thumbnail_src = photo['url_n']
76 elif 'url_z' in photo:
77 thumbnail_src = photo['url_z']
78 else:
79 thumbnail_src = img_src
80
81 # append result
82 results.append(
83 {
84 'url': build_flickr_url(photo['owner'], photo['id']),
85 'title': photo['title'],
86 'img_src': img_src,
87 'thumbnail_src': thumbnail_src,
88 'content': photo['description']['_content'],
89 'author': photo['ownername'],
90 'template': 'images.html',
91 }
92 )
93
94 # return results
95 return results

References searx.engines.flickr.build_flickr_url().

+ Here is the call graph for this function:

Variable Documentation

◆ about

dict searx.engines.flickr.about
Initial value:
1= {
2 "website": 'https://www.flickr.com',
3 "wikidata_id": 'Q103204',
4 "official_api_documentation": 'https://secure.flickr.com/services/api/flickr.photos.search.html',
5 "use_official_api": True,
6 "require_api_key": True,
7 "results": 'JSON',
8}

Definition at line 12 of file flickr.py.

◆ api_key

searx.engines.flickr.api_key = None

Definition at line 25 of file flickr.py.

◆ categories

list searx.engines.flickr.categories = ['images']

Definition at line 21 of file flickr.py.

◆ nb_per_page

int searx.engines.flickr.nb_per_page = 15

Definition at line 23 of file flickr.py.

◆ paging

bool searx.engines.flickr.paging = True

Definition at line 24 of file flickr.py.

◆ photo_url

str searx.engines.flickr.photo_url = 'https://www.flickr.com/photos/{userid}/{photoid}'

Definition at line 34 of file flickr.py.

◆ url

tuple searx.engines.flickr.url
Initial value:
1= (
2 'https://api.flickr.com/services/rest/?method=flickr.photos.search'
3 + '&api_key={api_key}&{text}&sort=relevance'
4 + '&extras=description%2C+owner_name%2C+url_o%2C+url_n%2C+url_z'
5 + '&per_page={nb_per_page}&format=json&nojsoncallback=1&page={page}'
6)

Definition at line 28 of file flickr.py.