-
Notifications
You must be signed in to change notification settings - Fork 0
/
search_users.py
57 lines (41 loc) · 1.18 KB
/
search_users.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
from workflow import Workflow, ICON_FILES
from workflow.background import run_in_background, is_running
from lib import search_analogue_users
from thumbnails import Thumbs
from datetime import date, datetime
import time
log = None
def main(wf):
if wf.args:
query = wf.args[0]
else:
query = None
log.debug("query : %r", query)
results = search_analogue_users(query=query)
log.debug("%d results.", len(results))
if not results:
wf.add_item(
'No results found for "%s".' % query,
"Try a different query or add a link.",
icon=ICON_FILES,
)
thumbs = Thumbs(wf.datafile("thumbs"))
for hit in results:
wf.add_item(
title=hit["name"],
subtitle=hit["username"],
valid=True,
arg="https://www.analogue.app/@{}".format(hit["username"]),
icon=thumbs.thumbnail(hit.get("image_url")),
icontype=None,
)
wf.send_feedback()
thumbs.save_queue()
if thumbs.has_queue:
thumbs.process_queue()
return 0
if __name__ == u"__main__":
wf = Workflow()
log = wf.logger
sys.exit(wf.run(main))