Fix channel settings URL being different for some users
This commit is contained in:
1 parent
5dea41a6ab
commit
ab76491ecc
1 file changed
+5
-5
+5
-5
@@ -223,21 +223,21 @@ class Channel:
|
|||||||
For mobile view, spade_url is available immediately from the page, skipping step #2.
|
For mobile view, spade_url is available immediately from the page, skipping step #2.
|
||||||
"""
|
"""
|
||||||
SETTINGS_PATTERN: str = (
|
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 = (
|
SPADE_PATTERN: str = (
|
||||||
r'"spade_?url": ?"(https://video-edge-[.\w\-/]+\.ts(?:\?allow_stream=true)?)"'
|
r'"spade_?url": ?"(https://video-edge-[.\w\-/]+\.ts(?:\?allow_stream=true)?)"'
|
||||||
)
|
)
|
||||||
async with self._twitch.request("GET", self.url) as response:
|
async with self._twitch.request("GET", self.url) as response1:
|
||||||
streamer_html: str = await response.text(encoding="utf8")
|
streamer_html: str = await response1.text(encoding="utf8")
|
||||||
match = re.search(SPADE_PATTERN, streamer_html, re.I)
|
match = re.search(SPADE_PATTERN, streamer_html, re.I)
|
||||||
if not match:
|
if not match:
|
||||||
match = re.search(SETTINGS_PATTERN, streamer_html, re.I)
|
match = re.search(SETTINGS_PATTERN, streamer_html, re.I)
|
||||||
if not match:
|
if not match:
|
||||||
raise MinerException("Error while spade_url extraction: step #1")
|
raise MinerException("Error while spade_url extraction: step #1")
|
||||||
streamer_settings = match.group(1)
|
streamer_settings = match.group(1)
|
||||||
async with self._twitch.request("GET", streamer_settings) as response:
|
async with self._twitch.request("GET", streamer_settings) as response2:
|
||||||
settings_js: str = await response.text(encoding="utf8")
|
settings_js: str = await response2.text(encoding="utf8")
|
||||||
match = re.search(SPADE_PATTERN, settings_js, re.I)
|
match = re.search(SPADE_PATTERN, settings_js, re.I)
|
||||||
if not match:
|
if not match:
|
||||||
raise MinerException("Error while spade_url extraction: step #2")
|
raise MinerException("Error while spade_url extraction: step #2")
|
||||||
|
|||||||
Reference in new issue
Block a user