Skip to content

Commit

Permalink
feat: GG Debrid-Link, restrictions defeated 🤓☝️
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy committed Nov 26, 2024
1 parent 0cda7b5 commit 49cd90b
Showing 1 changed file with 65 additions and 48 deletions.
113 changes: 65 additions & 48 deletions comet/debrid/debridlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,31 @@ async def check_premium(self):
return False

async def get_instant(self, chunk: list):
try:
get_instant = await self.session.get(
f"{self.api_url}/seedbox/cached?url={','.join(chunk)}"
)
return await get_instant.json()
except Exception as e:
logger.warning(
f"Exception while checking hashes instant availability on Debrid-Link: {e}"
)
responses = []
for hash in chunk:
try:
add_torrent = await self.session.post(
"https://debrid-link.com/api/v2/seedbox/add",
data={"url": hash, "wait": True, "async": True},
)
add_torrent = await add_torrent.json()

torrent_id = add_torrent["value"]["id"]
await self.session.delete(f"{self.api_url}/seedbox/{torrent_id}/remove")

responses.append(add_torrent)
except Exception as e:
logger.warning(
f"Exception while checking cached status on DebridLink for {hash}: {e}"
)
pass

return responses

async def get_files(
self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
):
chunk_size = 250
chunk_size = 10
chunks = [
torrent_hashes[i : i + chunk_size]
for i in range(0, len(torrent_hashes), chunk_size)
Expand All @@ -54,61 +65,67 @@ async def get_files(

responses = await asyncio.gather(*tasks)

availability = [
response for response in responses if response and response.get("success")
]
availability = []
for response_list in responses:
for response in response_list:
availability.append(response)

files = {}

if type == "series":
for result in availability:
for hash, torrent_data in result["value"].items():
for file in torrent_data["files"]:
filename = file["name"]
torrent_files = result["value"]["files"]
for file in torrent_files:
if file["downloadPercent"] != 100:
continue

if not is_video(filename):
continue
filename = file["name"]

if "sample" in filename.lower():
continue
if not is_video(filename):
continue

filename_parsed = parse(filename)
if episode not in filename_parsed.episodes:
continue
if "sample" in filename.lower():
continue

if kitsu:
if filename_parsed.seasons:
continue
else:
if season not in filename_parsed.seasons:
continue
filename_parsed = parse(filename)
if episode not in filename_parsed.episodes:
continue

files[hash] = {
"index": torrent_data["files"].index(file),
"title": filename,
"size": file["size"],
}
if kitsu:
if filename_parsed.seasons:
continue
else:
if season not in filename_parsed.seasons:
continue

break
files[result["value"]["hashString"]] = {
"index": torrent_files.index(file),
"title": filename,
"size": file["size"],
}

break
else:
for result in availability:
for hash, torrent_data in result["value"].items():
for file in torrent_data["files"]:
filename = file["name"]
value = result["value"]
torrent_files = value["files"]
for file in torrent_files:
if file["downloadPercent"] != 100:
continue

if not is_video(filename):
continue
filename = file["name"]

if "sample" in filename.lower():
continue
if not is_video(filename):
continue

files[hash] = {
"index": torrent_data["files"].index(file),
"title": filename,
"size": file["size"],
}
if "sample" in filename.lower():
continue

break
files[value["hashString"]] = {
"index": torrent_files.index(file),
"title": filename,
"size": file["size"],
}

return files

Expand Down

0 comments on commit 49cd90b

Please sign in to comment.