From ab76491ecc26c6527da3aa5ccaefdc9a563fdfd8 Mon Sep 17 00:00:00 2001 From: DevilXD <4180725+DevilXD@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:07:25 +0200 Subject: [PATCH] Fix channel settings URL being different for some users --- channel.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/channel.py b/channel.py index 77362c7..0550aa1 100644 --- a/channel.py +++ b/channel.py @@ -223,21 +223,21 @@ class Channel: For mobile view, spade_url is available immediately from the page, skipping step #2. """ SETTINGS_PATTERN: str = ( - r'src="(https://static\.twitchcdn\.net/config/settings\.[0-9a-f]{32}\.js)"' + r'src="(https://[\w.]+/config/settings\.[0-9a-f]{32}\.js)"' ) SPADE_PATTERN: str = ( r'"spade_?url": ?"(https://video-edge-[.\w\-/]+\.ts(?:\?allow_stream=true)?)"' ) - async with self._twitch.request("GET", self.url) as response: - streamer_html: str = await response.text(encoding="utf8") + async with self._twitch.request("GET", self.url) as response1: + streamer_html: str = await response1.text(encoding="utf8") match = re.search(SPADE_PATTERN, streamer_html, re.I) if not match: match = re.search(SETTINGS_PATTERN, streamer_html, re.I) if not match: raise MinerException("Error while spade_url extraction: step #1") streamer_settings = match.group(1) - async with self._twitch.request("GET", streamer_settings) as response: - settings_js: str = await response.text(encoding="utf8") + async with self._twitch.request("GET", streamer_settings) as response2: + settings_js: str = await response2.text(encoding="utf8") match = re.search(SPADE_PATTERN, settings_js, re.I) if not match: raise MinerException("Error while spade_url extraction: step #2")