Skip to content

Commit

Permalink
fix: easier for elfhosted to process
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy committed Jul 6, 2024
1 parent 9a94f0f commit 6443fa1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions comet/debrid/realdebrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ async def check_premium(self):

return False

async def get_instant(self, hash: str):
async def get_instant(self, chunk: list):
try:
response = await self.session.get(
f"{self.api_url}/torrents/instantAvailability/{hash}"
f"{self.api_url}/torrents/instantAvailability/{'/'.join(hash for hash in chunk)}"
)
return await response.json()
except Exception as e:
Expand All @@ -44,9 +44,15 @@ async def get_instant(self, hash: str):
async def get_files(
self, torrent_hashes: list, type: str, season: str, episode: str
):
chunk_size = 50
chunks = [
torrent_hashes[i : i + chunk_size]
for i in range(0, len(torrent_hashes), chunk_size)
]

tasks = []
for hash in torrent_hashes:
tasks.append(self.get_instant(hash))
for chunk in chunks:
tasks.append(self.get_instant(chunk))

responses = await asyncio.gather(*tasks)

Expand Down

0 comments on commit 6443fa1

Please sign in to comment.