Skip to content

Commit

Permalink
fix: mediafusion sometimes throwing error when parsing response (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemarcoli authored Nov 3, 2024
1 parent 19cf38f commit 9c093ac
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/program/services/scrapers/mediafusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,18 @@ def scrape(self, item: MediaItem) -> tuple[Dict[str, str], int]:
torrents: Dict[str, str] = {}

for stream in response.data.streams:
raw_title = stream.description.split("\n💾")[0].replace("📂 ", "")
info_hash = stream.url.split("?info_hash=")[1]
description_split = stream.description.split("\n💾")
if len(description_split) < 2:
logger.warning(f"Invalid stream description: {stream.description}")
continue
raw_title = description_split[0].replace("📂 ", "")

url_split = stream.url.split("?info_hash=")
if len(url_split) < 2:
logger.warning(f"Invalid stream URL: {stream.url}")
continue
info_hash = url_split[1]

if not info_hash or not raw_title:
continue

Expand Down

0 comments on commit 9c093ac

Please sign in to comment.