mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
fix: aiohttp max number of simultaneous connections
This commit is contained in:
+2
-3
@@ -31,7 +31,8 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
]
|
||||
}
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
connector = aiohttp.TCPConnector(limit=0)
|
||||
async with aiohttp.ClientSession(connector=connector) as session:
|
||||
check_debrid = await session.get("https://api.real-debrid.com/rest/1.0/user", headers={
|
||||
"Authorization": f"Bearer {config['debridApiKey']}"
|
||||
})
|
||||
@@ -80,7 +81,6 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
sorted_ranked_files = json.loads(sorted_ranked_files[0])
|
||||
|
||||
balanced_hashes = await get_balanced_hashes(sorted_ranked_files, config)
|
||||
|
||||
results = []
|
||||
for hash in sorted_ranked_files:
|
||||
for resolution in balanced_hashes:
|
||||
@@ -253,7 +253,6 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
logger.info(f"Results have been cached for {logName}")
|
||||
|
||||
balanced_hashes = await get_balanced_hashes(sorted_ranked_files, config)
|
||||
|
||||
results = []
|
||||
for hash in sorted_ranked_files:
|
||||
for resolution in balanced_hashes:
|
||||
|
||||
@@ -199,14 +199,13 @@ async def get_balanced_hashes(hashes: dict, config: dict):
|
||||
|
||||
return balanced_hashes
|
||||
|
||||
async def check_info_hash(debrid_api_key: str, hash: str):
|
||||
async def check_info_hash(session: aiohttp.ClientSession, debrid_api_key: str, hash: str):
|
||||
try:
|
||||
async with aiohttp.ClientSession(headers={
|
||||
response = await session.get(f"https://api.real-debrid.com/rest/1.0/torrents/instantAvailability/{hash}", headers={
|
||||
"Authorization": f"Bearer {debrid_api_key}"
|
||||
}) as session:
|
||||
response = await session.get(f"https://api.real-debrid.com/rest/1.0/torrents/instantAvailability/{hash}")
|
||||
})
|
||||
|
||||
return response
|
||||
return response
|
||||
except Exception as e:
|
||||
logger.warning(f"Exception while checking info hash with Real Debrid for {hash}: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user