From 9c093ac817ba541aecc552c3e1a6170cf767d58d Mon Sep 17 00:00:00 2001 From: Davide Marcoli <69892203+davidemarcoli@users.noreply.github.com> Date: Sun, 3 Nov 2024 16:22:41 +0100 Subject: [PATCH] fix: mediafusion sometimes throwing error when parsing response (#844) --- src/program/services/scrapers/mediafusion.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/program/services/scrapers/mediafusion.py b/src/program/services/scrapers/mediafusion.py index e7ae9a22..1cbf0d7e 100644 --- a/src/program/services/scrapers/mediafusion.py +++ b/src/program/services/scrapers/mediafusion.py @@ -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