Hi
I need help in extracting live streaming links from https://www.twitch.tv/yementv and forward them to tivimate app.
The streaming link contains a token so every time I need a new one
Support our site by donate $5 directly to us Thanks!!!
Try StreamFab Downloader and download streaming video from Netflix, Amazon!
Try StreamFab Downloader and download streaming video from Netflix, Amazon!
+ Reply to Thread
Results 1 to 6 of 6
-
-
You have to make a script that fetch a fresh url and forward when requested. You have to self host that.
-
Yes that's exactly what I want, I have a script running on flask that does this on several other platforms.
But I didn't succeed on twitch,
Look what I came up with
Code:import requests headers = { 'Accept': 'application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain', 'DNT': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36', } params = ( ('sig', '8ef3cd57c77d9c6c9c72ee943f65ac654ec11f5a'), ('token', '{"adblock":false,"authorization":{"forbidden":false,"reason":""},"blackout_enabled":false,"channel":"yementv","channel_id":492835585,"chansub":{"restricted_bitrates":[],"view_until":1924905600},"ci_gb":false,"geoblock_reason":"","device_id":"78b902e307bf5b","expires":1726180696,"extended_history_allowed":false,"game":"","hide_ads":false,"https_required":true,"mature":false,"partner":false,"platform":"web","player_type":"site","private":{"allowed_to_view":true},"privileged":false,"role":"","server_ads":true,"show_ads":true,"subscriber":false,"turbo":false,"user_id":null,"version":2}'), ) response = requests.get('https://usher.ttvnw.net/api/channel/hls/yementv.m3u8', headers=headers, params=params)
-
I just looked at this and I noticed as well that the dynamic m3u8 url needs just those two parameters (sig and token). Token is relatively simple as it's just a url-encoded JSON with mostly predictable (or even static) values. But yes, the signature is calculated from that token using a key known only to Twitch. As soon as you change just one thing in the token value, the signature becomes invalid and the url will return an error message to say as much.
It also looks like these m3u8 url's aren't simply fetched from some API that you could call yourself, but are produced by as piece of WASM code that gets loaded from Amazon (amazon-ivs-wasmworker). I don't think there's much you can do here except going the Selenium/Puppeteer route but even then, a captcha could stop you in your tracks. -
I wrote the code a while ago, but I'm not sure if I should share it here publicly, because it will be patched by a developer lurking here. If you want it DM me and I'll share it with you
-
Code:
pip install streamlink
Code:pip install --upgrade streamlink
"streamlink https://www.twitch.tv/yementv best" in your terminal to check the available stream.
Code:import subprocess def get_m3u8_playlist(twitch_url): try: # Use streamlink to fetch the best stream quality URL result = subprocess.run( ['streamlink', '--stream-url', twitch_url, 'best'], capture_output=True, text=True ) # Check if the command was successful if result.returncode == 0: m3u8_url = result.stdout.strip() print(f"M3U8 playlist URL: {m3u8_url}") return m3u8_url else: print(f"Error fetching M3U8 playlist: {result.stderr}") return None except Exception as e: print(f"An error occurred: {str(e)}") return None if __name__ == "__main__": twitch_url = "https://www.twitch.tv/yementv" get_m3u8_playlist(twitch_url)
Similar Threads
-
Twitch trouble with live streams
By ghostrewel in forum Video Streaming DownloadingReplies: 3Last Post: 3rd Dec 2023, 04:57 -
Twitch Problem
By ghostrewel in forum Video Streaming DownloadingReplies: 1Last Post: 17th Nov 2023, 19:28 -
winner - best vid player well designed like youtube / twitch
By easytools in forum Newbie / General discussionsReplies: 2Last Post: 3rd Dec 2020, 01:45 -
[francetelevisions.fr] Can play/record M3U8 links, but not "HLS_V5" links
By abolibibelot in forum Video Streaming DownloadingReplies: 5Last Post: 17th Jul 2020, 15:14 -
Streaming media solution... but no streaming (hardwired only)
By Reading Bug in forum Media Center PC / MediaCentersReplies: 41Last Post: 12th Jan 2020, 13:35