|
@@ -14,6 +14,7 @@
|
14
|
14
|
|
15
|
15
|
from urllib import urlencode
|
16
|
16
|
from json import loads
|
|
17
|
+from time import time
|
17
|
18
|
import re
|
18
|
19
|
from searx.engines import logger
|
19
|
20
|
|
|
@@ -24,21 +25,31 @@ categories = ['images']
|
24
|
25
|
|
25
|
26
|
url = 'https://www.flickr.com/'
|
26
|
27
|
search_url = url + 'search?{query}&page={page}'
|
|
28
|
+time_range_url = '&min_upload_date={start}&max_upload_date={end}'
|
27
|
29
|
photo_url = 'https://www.flickr.com/photos/{userid}/{photoid}'
|
28
|
30
|
regex = re.compile(r"\"search-photos-lite-models\",\"photos\":(.*}),\"totalItems\":", re.DOTALL)
|
29
|
31
|
image_sizes = ('o', 'k', 'h', 'b', 'c', 'z', 'n', 'm', 't', 'q', 's')
|
30
|
32
|
|
31
|
33
|
paging = True
|
|
34
|
+time_range_support = True
|
|
35
|
+time_range_dict = {'day': 60 * 60 * 24,
|
|
36
|
+ 'week': 60 * 60 * 24 * 7,
|
|
37
|
+ 'month': 60 * 60 * 24 * 7 * 4}
|
32
|
38
|
|
33
|
39
|
|
34
|
40
|
def build_flickr_url(user_id, photo_id):
|
35
|
41
|
return photo_url.format(userid=user_id, photoid=photo_id)
|
36
|
42
|
|
37
|
43
|
|
38
|
|
-def request(query, params):
|
39
|
|
- params['url'] = search_url.format(query=urlencode({'text': query}),
|
40
|
|
- page=params['pageno'])
|
|
44
|
+def _get_time_range_url(time_range):
|
|
45
|
+ if time_range in time_range_dict:
|
|
46
|
+ return time_range_url.format(start=time(), end=str(int(time()) - time_range_dict[time_range]))
|
|
47
|
+ return ''
|
|
48
|
+
|
41
|
49
|
|
|
50
|
+def request(query, params):
|
|
51
|
+ params['url'] = (search_url.format(query=urlencode({'text': query}), page=params['pageno'])
|
|
52
|
+ + _get_time_range_url(params['time_range']))
|
42
|
53
|
return params
|
43
|
54
|
|
44
|
55
|
|