56def response(resp):
57 results = []
58
59 search_res = loads(resp.text)
60
61
62 if search_res[0]["name"] == "No results returned":
63 return []
64
65
66 for result in search_res:
67 link = url + "description.php?id=" + result["id"]
68 magnetlink = (
69 "magnet:?xt=urn:btih:" + result["info_hash"] + "&dn=" + result["name"] + "&tr=" + "&tr=".join(trackers)
70 )
71
72 params = {
73 "url": link,
74 "title": result["name"],
75 "seed": result["seeders"],
76 "leech": result["leechers"],
77 "magnetlink": magnetlink,
78 "template": "torrent.html",
79 }
80
81
82 try:
83 params['publishedDate'] = datetime.fromtimestamp(float(result["added"]))
84 except:
85 pass
86
87
88 params['filesize'] = humanize_bytes(int(result["size"]))
89
90
91 results.append(params)
92
93
94 return sorted(results, key=itemgetter("seed"), reverse=True)