Skip to content

Commit f4b45b0

Browse files
committed
feat: Using async generators in all providers
1 parent 8d21b1f commit f4b45b0

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

katcr/engines/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def search_site(self, url):
7474
if any(reserved in text for reserved in CLDS):
7575
raise CloudFlareError()
7676

77-
return list(await self.get_torrents(response))
77+
return [a async for a in self.get_torrents(response)]
7878

7979
@classmethod
8080
async def get_torrents(cls, data):

katcr/engines/tpb.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ class ThePirateBay(BaseSearch):
2323

2424
async def get_torrents(self, response):
2525
result = await response.json()
26-
return [[
27-
a['name'],
28-
(f"magnet:?xt=urn:btih:{a['info_hash']}"
29-
f"&dn={quote(a['name'])}&tr={'&tr='.join(TRACKERS)}")
30-
] for a in result]
26+
for mag in result:
27+
yield [
28+
mag['name'],
29+
(f"magnet:?xt=urn:btih:{mag['info_hash']}"
30+
f"&dn={quote(mag['name'])}&tr={'&tr='.join(TRACKERS)}")
31+
]

0 commit comments

Comments
 (0)