Skip to content

Commit

Permalink
fix: zilean
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy committed Aug 31, 2024
1 parent 3228323 commit 6a272fc
Showing 1 changed file with 17 additions and 34 deletions.
51 changes: 17 additions & 34 deletions comet/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,40 +354,23 @@ async def get_zilean(
):
results = []
try:
if not season:
get_dmm = await session.post(
f"{settings.ZILEAN_URL}/dmm/search", json={"queryText": name}
)
get_dmm = await get_dmm.json()

if isinstance(get_dmm, list):
take_first = get_dmm[: settings.ZILEAN_TAKE_FIRST]
for result in take_first:
object = {
"Title": result["raw_title"],
"InfoHash": result["info_hash"],
"Size": result["size"],
"Tracker": "DMM",
}

results.append(object)
else:
get_dmm = await session.get(
f"{settings.ZILEAN_URL}/dmm/filtered?query={name}&season={season}&episode={episode}"
)
get_dmm = await get_dmm.json()

if isinstance(get_dmm, list):
take_first = get_dmm[: settings.ZILEAN_TAKE_FIRST]
for result in take_first:
object = {
"Title": result["raw_title"],
"InfoHash": result["info_hash"],
"Size": result["size"],
"Tracker": "DMM",
}

results.append(object)
show = f"&season={season}&episode={episode}"
get_dmm = await session.get(
f"{settings.ZILEAN_URL}/dmm/filtered?query={name}{show if season else ''}"
)
get_dmm = await get_dmm.json()

if isinstance(get_dmm, list):
take_first = get_dmm[: settings.ZILEAN_TAKE_FIRST]
for result in take_first:
object = {
"Title": result["raw_title"],
"InfoHash": result["info_hash"],
"Size": result["size"],
"Tracker": "DMM",
}

results.append(object)

logger.info(f"{len(results)} torrents found for {log_name} with Zilean")
except Exception as e:
Expand Down

0 comments on commit 6a272fc

Please sign in to comment.