Skip to content

Commit

Permalink
fixed info hash retriever
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy authored Jun 24, 2024
1 parent 6a81f7a commit 949f17c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion comet/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ async def getJackett(session: aiohttp.ClientSession, indexers: list, query: str)
logger.warning(f"Exception while getting Jackett results for {query} with {indexers}: {e}")

async def getTorrentHash(session: aiohttp.ClientSession, url: str):
if url["InfoHash"] != None:
return url["InfoHash"]

url = url["Link"]

try:
timeout = aiohttp.ClientTimeout(total=int(os.getenv("GET_TORRENT_TIMEOUT", 5)))
response = await session.get(url, allow_redirects=False, timeout=timeout)
Expand Down Expand Up @@ -273,7 +278,7 @@ async def stream(request: Request, b64config: str, type: str, id: str):

continue

tasks.append(getTorrentHash(session, torrent["Link"]))
tasks.append(getTorrentHash(session, torrent))

torrentHashes = await asyncio.gather(*tasks)
torrentHashes = list(set([hash for hash in torrentHashes if hash]))
Expand Down

0 comments on commit 949f17c

Please sign in to comment.