Streamlink: pre-roll ads playing before twitch stream

Created on 16 Mar 2019  路  33Comments  路  Source: streamlink/streamlink

Bug Report

  • [x ] This is a bug report and I have read the contribution guidelines.

Description


streamlink 1.0.0 on windows 10 64bit (latest updates) has a chance of playing pre-roll ads before loading the twitch stream. sometimes it will partially play the end of an ad (i.e. 1 or 2 seconds), sometimes the entire ad. sometimes the ad is low resolution (480/720), sometimes 1080p. sometimes you get expected behavior (no ads).

Expected / Actual behavior


expected: play the stream straight away
actual: sporadic pre-rolls play, then the stream.

Reproduction steps / Explicit stream URLs to test

  1. use streamlink 1.0.0
  2. execute streamlink using cmd line "streamlink twitch.tv/sodapoppin best"
  3. other twitch streams can exhibit the same issue, but not always

Log output

C:\WINDOWS\system32>streamlink twitch.tv/sodapoppin best -l debug
[cli][info] Found matching plugin twitch for URL twitch.tv/sodapoppin
[plugin.twitch][debug] Getting live HLS streams for sodapoppin
[cli][info] Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 1080p60 (best)
[cli][info] Opening stream: 1080p60 (hls)
[cli][info] Starting player: "C:\mpv-x86_64-20190224\mpv.exe"

Additional comments, screenshots, etc.

configuration file is default save for player-passthrough enabled/default player changed to mpv.
video of the issue in action - https://mega.nz/#!HEBn1K4S!titCic2lUv4Hsz2c5LjY4TDvK2cjrHRS_Y_BbyO8COk
i'll stress that this is sporadic - sometimes i'll get an ad no matter how many times i load the stream. sometimes i won't get an ad at all. this first started happening for me on march 14th.
bonus: alternate player for twitch.tv plugin (chrome/firefox) has the same issue.

Love Streamlink? Please consider supporting our collective. Thanks!

more info required

Most helpful comment

@vohzi
You can change HTTP headers via --http-header "key=value".
Setting the User-Agent to Blackberry --9900 does not prevent ads from being injected into the stream. I don't think they will check the User-Agent string, since it can easily be faked.


@pixeltris
Adding the platform=_ GET parameter to the access_token API endpoint call seems to be working. But yeah, that's something they could fix very easily.
If anyone wants to try it, see this diff:

diff --git a/src/streamlink/plugins/twitch.py b/src/streamlink/plugins/twitch.py
index 410a22b6..17ce4e0b 100644
--- a/src/streamlink/plugins/twitch.py
+++ b/src/streamlink/plugins/twitch.py
@@ -222,7 +222,7 @@ class TwitchAPI(object):
     # Private API calls

     def access_token(self, endpoint, asset, **params):
-        return self.call("/api/{0}/{1}/access_token".format(endpoint, asset), **params)
+        return self.call("/api/{0}/{1}/access_token".format(endpoint, asset), **dict(platform="_", **params))

     def token(self, **params):
         return self.call("/api/viewer/token", **params)

All 33 comments

Doesn't Twitch embed some ads directly into the HLS playlist?

I don't now why this issue is appearing now because the system (Twitch calls it SureStream apparently) was announced 2016 (although it is labeled as "new" on the Twitch Advertisements page). Maybe it's just a bunch of companies actually buying SureStream Ad-Spots?

correct, but it's never been an issue prior to this with either livestreamer or streamlink. partially played ads wouldn't be expected behavior on twitch's end, and ads triggered by streamers during their stream still don't play - imo, something has changed.
edit: ads triggered by the streamer now also affecting streamlink.

It's because you're using player-passthrough. When you do that Streamlink isn't handling the stream, the player you are using is. If you disable player-passthrough this shouldn't be an issue any more. If it's happening without player-passthrough then we can open this back up to see if other people get the error as well.

it's happening with player-passthrough disabled as well. video: https://mega.nz/#!HQo2hIDa!iKbbD0uRjICdtwHT3gc43aIrKVLxrBSrtqdjrZEn2pg

C:\>streamlink twitch.tv/mendokusaii best -l debug [cli][info] Found matching plugin twitch for URL twitch.tv/mendokusaii [plugin.twitch][debug] Getting live HLS streams for mendokusaii [cli][info] Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 900p60 (best) [cli][info] Opening stream: 900p60 (hls) [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 3 to queue [cli][debug] Pre-buffering 8192 bytes [stream.hls][debug] Adding segment 4 to queue [stream.hls][debug] Adding segment 5 to queue [stream.hls][debug] Download of segment 3 complete [cli][info] Starting player: "C:\mpv-x86_64-20190224\mpv.exe" [stream.hls][debug] Download of segment 4 complete [stream.hls][debug] Download of segment 5 complete [cli][debug] Writing stream to output [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 6 to queue [stream.hls][debug] Adding segment 7 to queue [stream.hls][debug] Download of segment 6 complete [stream.hls][debug] Download of segment 7 complete [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 8 to queue [stream.hls][debug] Adding segment 9 to queue [stream.hls][debug] Adding segment 10 to queue [stream.hls][debug] Download of segment 8 complete [stream.hls][debug] Download of segment 9 complete [stream.hls][debug] Download of segment 10 complete [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 11 to queue [stream.hls][debug] Adding segment 12 to queue [stream.hls][debug] Adding segment 13 to queue [stream.hls][debug] Download of segment 11 complete [stream.hls][debug] Download of segment 12 complete [stream.hls][debug] Download of segment 13 complete [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 14 to queue [stream.hls][debug] Adding segment 15 to queue [stream.hls][debug] Adding segment 16 to queue [stream.hls][debug] Download of segment 14 complete [stream.hls][debug] Download of segment 15 complete [stream.hls][debug] Download of segment 16 complete [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 17 to queue [stream.hls][debug] Adding segment 18 to queue [stream.hls][debug] Adding segment 19 to queue [stream.hls][debug] Download of segment 17 complete [stream.hls][debug] Download of segment 18 complete [stream.hls][debug] Download of segment 19 complete [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 20 to queue [stream.hls][debug] Adding segment 21 to queue [stream.hls][debug] Adding segment 22 to queue [stream.hls][debug] Download of segment 20 complete [stream.hls][debug] Download of segment 21 complete [stream.hls][debug] Download of segment 22 complete [cli][info] Player closed [stream.hls][debug] Closing worker thread [stream.hls][debug] Closing writer thread [stream.hls][debug] Closing writer thread [cli][info] Stream ended [cli][info] Closing currently open stream...

Weird, alright let's open this back up and see if others can duplicate. I haven't seen it since I've been using 1.0 so hopefully some others will chime in.

You are not running Streamlink 1.0.0 if the environment debug infos are not showing up when using -l debug. Please don't cut this out from the log.

Are you able to reliably get ads when watching this channel via Streamlink (without passthrough)? If so, then you could check the HLS playlist content and see whether the ad-segments at the beginning have a different pattern. Example on *nix in bash (see the --stream-url parameter):

curl -s $(streamlink --stream-url twitch.tv/CHANNEL best) | less

There's also the --hls-segment-ignore-names parameter for filtering out HLS segments, but that probably won't be of use here due to dynamic file names.

As @skulblakka already said, Twitch has (tried to) embed ads into the HLS streams almost two years ago, but I've never seen any ads since their announcement of that feature, and Twitch streams are basically running all day long on my system. However, I've seen a reddit thread today where users of uBlock origin were complaining about getting ads, too, but others not. Maybe they're doing a field test in a specific region or so because of GDC next week, who knows.

Regarding actively blocking ads in Streamlink, I don't know how to feel about this. There hasn't been anything implemented to specifically block ads. Ads simply happened to be served from an external source and were loaded by the web player from there, so being ad-free was just a "coincidence". Blocking ads on a website with user tracking also has a different motivation. Projects like Streamlink however are relying on access to their API and have to worry about not breaking ToS (to a certain extent).

then we can open this back up to see if other people get the error as well.

I'm running 1.0.0 and I'm still getting it too. I'm also reliably getting ads on streams (including ad breaks).
Just to chime in before this somehow gets closed again and wiped from the board.

You are not running Streamlink 1.0.0 if the environment debug infos are not showing up when using -l debug. Please don't cut this out from the log.

version check tells me "1.0" is available despite uninstalling and reinstalling the 1.0.0 windows binary.

edit: as per the other issue thread, an old streamlink installation was clinging to life in local appdata. proper debug:

streamlink twitch.tv/destiny best -l debug [cli][debug] OS: Windows 10 [cli][debug] Python: 3.6.6 [cli][debug] Streamlink: 1.0.0 [cli][debug] Requests(2.21.0), Socks(1.6.7), Websocket(0.54.0) [cli][info] Found matching plugin twitch for URL twitch.tv/destiny [plugin.twitch][debug] Getting live HLS streams for destiny [utils.l10n][debug] Language code: en_GB [cli][info] Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 1080p60 (best) [cli][info] Opening stream: 1080p60 (hls) [stream.hls][debug] Reloading playlist [stream.hls][debug] First Sequence: 0; Last Sequence: 7 [stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 5; End Sequence: None [stream.hls][debug] Adding segment 5 to queue [cli][debug] Pre-buffering 8192 bytes [stream.hls][debug] Adding segment 6 to queue [stream.hls][debug] Adding segment 7 to queue [stream.hls][debug] Download of segment 5 complete [cli][info] Starting player: "C:\mpv-x86_64-20190224\mpv.exe" [cli.output][debug] Opening subprocess: "C:\mpv-x86_64-20190224\mpv.exe" --title twitch.tv/destiny - [stream.hls][debug] Download of segment 6 complete [stream.hls][debug] Download of segment 7 complete [cli][debug] Writing stream to output [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 8 to queue [stream.hls][debug] Download of segment 8 complete [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 9 to queue [stream.hls][debug] Download of segment 9 complete [stream.hls][debug] Reloading playlist [stream.hls][debug] Adding segment 10 to queue [stream.hls][debug] Download of segment 10 complete [cli][info] Player closed [stream.segmented][debug] Closing worker thread [stream.segmented][debug] Closing writer thread [stream.segmented][debug] Closing writer thread [cli][info] Stream ended [cli][info] Closing currently open stream...

Are you able to reliably get ads when watching this channel via Streamlink (without passthrough)?
If so, then you could check the HLS playlist content and see whether the ad-segments at the beginning have a different pattern. Example on *nix in bash (see the --stream-url parameter):

curl -s $(streamlink --stream-url twitch.tv/CHANNEL best) | less

There's also the --hls-segment-ignore-names parameter for filtering out HLS segments, but that probably won't be of use here due to dynamic file names.

this is what the playlist shows from a stream that is realiably displaying ads.
```#EXTM3U

EXT-X-VERSION:3

EXT-X-TARGETDURATION:5

EXT-X-MEDIA-SEQUENCE:0

EXT-X-TWITCH-ELAPSED-SECS:12585.683

EXT-X-TWITCH-TOTAL-SECS:12601.683

EXT-X-DATERANGE:ID="stitched-ad-1552712664-17602000000",CLASS="twitch-stitched-ad",START-DATE="2019-03-16T05:04:24.476Z",DURATION=17.602,X-TV-TWITCH-AD-POD-POSITION="0",X-TV-TWITCH-AD-URL="https://www.amazon.co.uk/Amazon-Video/b?node=13827483031&ref=vm_uk_pr_ao_pd10t",X-TV-TWITCH-AD-ROLL-TYPE="PREROLL",X-TV-TWITCH-AD-POD-LENGTH="1"

EXT-X-DISCONTINUITY

EXT-X-SCTE35-OUT:URL="https://www.amazon.co.uk/Amazon-Video/b?node=13827483031&ref=vm_uk_pr_ao_pd10t"

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:04:24.476Z

EXTINF:2.000,3648366870f93cffb39288a3cb7e2e2c-03-04-2019-00.00.03

https://video-edge-c67a94.lhr03.abs.hls.ttvnw.net/v1/segment/CtkEdcsEJYc3LSFyDx4HVFZUPbykuUNEFKh1duw5-szSzT9bTSyK5HsVPBNe00DeUF1QfAm6h1PYe0wVxepUoO_eLZx56gFW406ViTaBFV6Mr3namnHuKXRn2vY4_b1nbxJjWSotNIEdH57OE9QIKc1BvSFOcJRLKl-JCEinuK9IzI7V3PBmbhKV2VSTaNgjz4PWRgkSbVdKK3g8fwG3ccTDQhO6xmVumH4-am9uheM-YUpdUZly7Bze4oz1XZisGCnd1VqVxpw9IXsCjOVycKcnGHxhkpGVYK00hhbF2bUrqLUQ-bPrIAXDuHlQf4t9OmKBDUucnqhPxZMVu9azIO7Dz5uEpa75aNU0Axa1L2M5i7HCtgrDfRRiXrX7d6Xcgfk-CGhMkEvl-vrcYhP9nlEKir9vOdovfB7ws3cj5HQfTNX5PN04cTSdbP4SOCFcXWMqHZ4FX43XJEmC2XiRRocnRdtFiLvwfzeFmd9R-r9pZPHDuVZk96eGsdH0BbhQ0P3NiWc263IqhINA6ndhyLlcUXxNthyBJeOaEV6cs2YXlIyiBhJ8ofeklcJZjIWjm5hX6nyPs7U_o2N_7NHHdQ6LZY-DHQeeIV2K3-7aY93Hycgu41OtPxzrtWhYHcrkcYv30SNlNcMoc_HqlsD-vWuu5c_Mry8y82lVhQD0XIpXe3MgkPAeTlyFS1imAB8Endu2RwtkU-DuK2yaVqhTuMVsHhdTtweBCq9LAxEkJ5UKauX3Vew9i7SVkPzVaWyQ6d0cRKyttjeLc-AADrJMSWathXchoQ_FYACHtRIQvreE_LXmYuXh8pU0vZQDShoM0yfix0mORPLqqtnB.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:04:26.476Z

EXTINF:2.000,3648366870f93cffb39288a3cb7e2e2c-03-04-2019-00.00.03

https://video-edge-c67a94.lhr03.abs.hls.ttvnw.net/v1/segment/CtMDgyCiriU_O3FhDCIYbwpmxxbPXC-C1H36pYuWsdfocXH0JncYnW5jswxtoOm6of8AQEdg1xGXtlWyt-eTEtrSuVDR6WEwWjlpKKxssEw2E1Qv_roOWjY7H8JkPqctdKQXM1TkU7hmh1h0zXWbUAzwamK_4KsZieiOLjvVSh_5dnXdtclt7VplT6yyzUfU70iZVu_d2BSAgM0hRdnAEhbZEL9d4AwtyfI5SQKZaZJmFldlhoZzmKbuB9DrkwaBFQcd_366H0pM98YgYBu9CKTCa53CA2OUyJJqM-XVzpR-ACDEUEhfC2XressrAjok-3G6UiEFit2-70oAUXCIWugbOSBObGChRQNypyHmYiK8XxyziZ3qj-4lyaM705axsi1N3_YrNCCZl-ax8ZSTAwuQylfOaeZZ01RYtOQYJY5PiPJOADKscybIzUV8Xuse5F_Cc0CZEOHEob861Bl70xucPdWDIIbNCHq7RvFjCTQw2h3d8pyLgig5-KGM3vkhvHWvs-zsdWTLzr-HOKRfOBnIzZ9aqMlcrGxH8Pt6aQ1ofBqPJkcyTetrCAvj9-o9DQ-8BU8WypaGYY-EqApFymoceDOmL0TvqIw4wMwfpztg-rMcC-QSEJGLIFXOtu0cz_XVQpLedOQaDI5kYvR-rE1RABv3Sg.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:04:28.476Z

EXTINF:2.000,3648366870f93cffb39288a3cb7e2e2c-03-04-2019-00.00.03

https://video-edge-c67a94.lhr03.abs.hls.ttvnw.net/v1/segment/CtkE0S_5_h-cKh8qBdSboJerQY_Q-J9XbLEmiQVSKECw7ikCWoI_tD1HvYezEfwgyVyE_sCJS5GDFvql4mtkkfRW5n_Xc34f1WEHj57_gfS-seUafSHE3ARHEfBHYn17XEO7ppBzS8FWRcm4_LqrDpa1hbjXLEEUlxgastGph01DUwfiXE1fNXBhCZNwe0lYpITCsmylStHUnhKsWZ3vK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-jJYB4Yh5eYjLb_nZxwhETONVe4jH7IzyFlnzOgpFcWpqlGeNZH8xEaRVxf0eV6x3rHE0x9MrAbEwuBV7ILVor09oRzpBDvJ_Vc5Ed6IrlDPb0Lza4TfGaakaYVxkssEp1FMHJgSJekh6_N5jrcYNJmxq2-auXIiXXHCB0tSwStgr53oaJ66DU6mzWMsY87G8X3J7bSG4ZD0mHrXS7hTQYId2MGL5PVl0EImDuJCeZ2oGMuCcBIQ71Io-j7_sR_jKzfuLB8MsRoM7P6fzmYy6C8RD9en.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:04:34.476Z

EXTINF:2.000,3648366870f93cffb39288a3cb7e2e2c-03-04-2019-00.00.03

https://video-edge-c67a94.lhr03.abs.hls.ttvnw.net/v1/segment/CtMD0TSxM5isO4E5aB0NwQDwsaO8uCcSunpxeWQwiC_k7odD20wW9zq_flghLiGmsahchqCOV4pdYcF7xOVNf_ejGicPUAAYEw0f3TYSCW4w6a-mK2NlUn4AdODmAvO1sQZhZnUIV0ieRVAhhKqzKT01WTwpjZ1-s1NAZITryNMk-pzWWR7PRITdCQisIrCvi0mDdlRchmItaqoNFKBcaFFtiTXHZryi2VU5mVZuuzmfu9HpGaj1tHXzaIxbtug-19Q8bf4MXNFoVqqdasDEjib0uqzrehW6JQXWMK0aYVjipCIOIpsB0GuRId6Tt6ZMbo-t12HKmxX4GErZxV2qdbNI_PHvctBJ7ST4pDkUAT7SVzVZUgdu3g5XJ78A6Kbed1m2uZ0vsCRtqfBNU_LobKelEIm0JB1cUga2PSVH61SGDVBiY7Et4AUoE5JyYkc-wWrMAKgoogf0TH2A89xARnd8SO79vCWcBrYas7wAkB6Wmjn-sWNrdYCvLjAYfJuMT5Ds2qkHnQTCfOubYhIHcWJr79twtHFyEL7mw8SZruzUoMy1BunWponwA2iiy9vD2qWRYfZwBvv7bPq-x4h0fiA6674ybI1k3zEVvUL9REj0Rr4azE4SENvpJeLMLkmsaFjRZX7_H98aDG27NWppNEs_q8K8Uw.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:04:36.476Z

EXTINF:2.000,3648366870f93cffb39288a3cb7e2e2c-03-04-2019-00.00.03

https://video-edge-c67a94.lhr03.abs.hls.ttvnw.net/v1/segment/CtkENa_3lEq-XBzyT6pEf7Fl6IYtQtf1pNkFic1TnGNhxFMRoEednlJgcukf3GHAfs9goMGvFvCCDfZyrjCYIebq0GLRwyC8V3IxShc7KiZs3BNyf03Kl504K1qoTt-OqzfluJ7e7m42KDhvNhDNrpieRjNGLMn_qtJE3a_e4oJCZS-gMoYygsGz7X4X1VU0uKQ9XLLfG_9jOc2ukRSVBZfyWWc02Pp1N9fSC3v0eDIUy9wlS9cpX9VCbqVZYIZ9IAz8McKtBebMnAaBPOIh3uUSPulBovEjk3hKRgeAq0SnkvLL17zgg7YYjNFZ7YaV_Uk-t97Iz7UgPOdfDz8WoojWxIdgjC-M098zThx9c83axgKHG9WeFdZP5tTGDX4swzwGVfNFoDjT0aFNDEzC6DbtXYxNfeaaaOwZlV0Si5-Aip9qUIvUKdwyXIGGjS0Dq2hp6h7iJfWOfnnXlC4XyGLSsyaNc-iJ2lKXA4eG3MhMhFTlVfi0Rx0NF0Ox1qmaXi9HWevwNy0xYjFb6Q85ypHZpFJw-fEuRFW0D2IV6R8SlMrsFj456irFaxKtjIvp7VHrCcyhEvjt3tqqKXxFd2dFzdlNWjcb2tDxuNWJf0LyLbHDw41zDW7hfIMxVoklknyKwyamwfSaALqCFMsurdHKCC7ncc1qH0Wq12_b-iVIo4PY8OAxjiWUMOV_DbcXt4lCvTv8YyyRniD82FM37aJDdsf3z2pBDp5QNWIt0SJCQo-60Ul-2Ute1vkXU8b6k5eBBfFe9tXHTaACfu-UBdW3rbmarKqcEE0GFxIQ8K_72JT9Nu6m_y3GRnwuKxoMWWweq21VoBtq2bGj.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:04:38.476Z

EXTINF:2.000,3648366870f93cffb39288a3cb7e2e2c-03-04-2019-00.00.03

https://video-edge-c67a94.lhr03.abs.hls.ttvnw.net/v1/segment/CtMDGTqRuj1R-QXWgkgziLLSua_d5gm40QVeTivAqV7kbTOTwHDQkSYqfnZ0qb3KTo3jxqOK4SbZIVhqlOGG4xmUsbAQHyCzHc_DU4P0Myae7w2erpgfWK87SFbOFqJNhpqnusrXZIxQojledAOVHkFftzVw5R4Fr7YA_bUY4htvvCLf4YjGxrfKCvki0p5r2DSXEvgrS7qhtefDzw3dW8hlPA-hWyDtgRmG_a5lmIFjxn7_AhnVUvYFIQBgzdFNyLNmqtHEJjHasDRPMUGBLRFvIqaIWxwpUraLn2bN-h05Bb_g6DpiBfVZ5LVnI64-UETKBFsO_zfpOZhxej4MDgyMPvXswvg3g-WQy1NiqZQ2naJ-RNYwVy2V3LU39OXey26e5zYalgryEKRNtFWzWzjG1IaMeLnNrQZ3H-16lK2C5NGO6jPG3SmqB-GGD3JwarrCWKuXRIlIYRBSuXk2VIvT5RfJHyygopvz6pcQnfurcE-MvKxZvWkMCNRalpe_pWKwEm0RuavaHtkgwpSdwBSDE9i9mxYZT_cdhGR8nNfkDqr_PWiGN_gvpKu7G9bJMX72H_oFMq-mwtx3jqJmxLlnCDS35US7xhUSGH-FzA-U8mwnxC4SEIwpvU3RSHJrQquPdNwJ3EUaDDhptrUqFPJUuBJf-A.ts```

The playlist is indeed different for the HLS ad segments vs live stream segments. I need to download the playlist a few times to ensure it includes both ad and live stream segments.

Note that the live segments are prefixed with #EXTINF:2.000,live while the ad segments aren't. This seems like something they could easily change though.

streamlink --version streamlink 1.0.0

streamlink --stream-url twitch.tv/tfue https://video-weaver.syd01.hls.ttvnw.net/v1/playlist/CrYDff5aYKA19XXRE_GyftQTF1U5azuypA4VpL6zldptf-iPq1ayyCuU7496LQ1KmBf9-isCSbuLu73Xmc_Cdz2GE_dKAsCDRZ5XsUO_H4lZQpV30H7ypoEuA7O1i7R4WC7XAgIwxtCbMlF_Knp0iZmBYZeJuORZEqbygOd5C6yPaR2CGCxUMdVXtTJhgIptnDgtHwlBvGoUBHziRZmXDvNMD8wzRjsoxM2caCBRy7fQme8OWg_FZA-AALhf1QUxhu536WILF0WVw3oL2M5tIljQIq-tJIrrsYH5FqD0qbc5D27DLOKHFBWdmQk6jB_59-jWwfDE9G-7lbBZrkZDQ2R5rEhDjDkfz8W7dopgDKIs2Cz8TrB04HBzG5_Ywi4uFV7AdKGacc_yQkvabh8f6yG2A2hkIoPiuqajvEmk-0_cIFKfR5uQd_en1VbWRGCJtZLLy47X6Yqn21Ph1-rP3Wlp8UdxzPatdRTCZVWGuyWK84V9nkyafVQzf49HfWSamyVA64FMnXyhLqsjvv9m5lxj7hyDmmhy1dLkHcuPEgADcAyc-_segYYFuZ4TRoOT0WPkiOIUTKLXEhA8UPY5GtOddTEKwdQHeITJGgwCeDSchjJvNannfmU.m3u8

```#EXTM3U

EXT-X-VERSION:3

EXT-X-TARGETDURATION:5

EXT-X-MEDIA-SEQUENCE:0

EXT-X-TWITCH-ELAPSED-SECS:14632.000

EXT-X-TWITCH-TOTAL-SECS:14657.164

EXT-X-DATERANGE:ID="stitched-ad-1552713489-15163999993",CLASS="twitch-stitched-ad",START-DATE="2019-03-16T05:18:09.474Z",DURATION=15.164,X-TV-TWITCH-AD-POD-POSITION="0",X-TV-TWITCH-AD-URL="https://www.moosetoys.com/brand/fortnite/",X-TV-TWITCH-AD-ROLL-TYPE="PREROLL",X-TV-TWITCH-AD-POD-LENGTH="1"

EXT-X-DISCONTINUITY

EXT-X-SCTE35-OUT:URL="https://www.moosetoys.com/brand/fortnite/"

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:09.474Z

EXTINF:2.002,87d22d0b208d6a47c3bba6f412f7fb43-03-04-2019-05.03.22

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/CtQE5liiw6GK7ddulLbzeDSmBhKOtzxP65FTsMHcxnRFxOlc7kA6Nki-lc_Uw6iveok_oFAqL8DNgqPhtf-hlNWkdLJRtiMgA5_T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wnBiZjbV_a9o527LdYF5Yxmo-bXPbWimgNVbH384_ghbGv-z7DuO31QyvRuymHH7JlTGF6d6wL-noCpPbNE3fR2G4roAjdCsEbGE6K1y7IEXdlS1Mygd5wcZOJVvn_kYSfb4IVw6V4MGguR_xHFfI5PfRvyApBLlYVdN4--eRP5QkAtMeg4v2fdTo2B948xd6W47A-9VTOkFioO5zv8gCUBHYEW0rbzGlXvGJ6PWaqGhcco8orMLmAmxI1y81LHdnnVqvUzrsHi6jlsmZZz8RVdEXYKpsBRMwQPVU3kyVXfIQbN0zs0mvk5KwUqxi0v7DcHGHx3qZ8sGJdn3jhIQ06ivm-VWC4ps1GD00GLVcBoMTPxAtCpgP8CwB-41.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:15.479999997Z

EXTINF:2.002,87d22d0b208d6a47c3bba6f412f7fb43-03-04-2019-05.03.22

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/CtQEw3qW07BT-Au2YGqV_XvbUzpSQw5_XCuTVyeSDgvlm8RdZt4IpuZa0PTp8UtYuwk3uHmT0hn8oBtBXMAV7IPzuvfVy29Migh_JqP4u3J0BDpcoKg4x2PjHkGIATxrpF9J1f7EVSxbZx-XEgl7HZSvTL16iIXL58XksMKTWGQ52la9xTwTeaOnI9hvZ8a6fh5M-k-kNMljZsMO6KKCwfnqhZNmDAjm2qhxzn-EVTGvSwjH0ixNmfZkT57O5Zvwygnfm2R6Z9LOrdVlgk0UiY_tMTjfFCd1fV7GU5HzxoF-GHD44JpZiWHM5wxQ_mQrCymKvunzVSQa4GkwvRwbrrR_ebb27JV-plNytFyJQun1SDWzujqgM4ngfvlul4YdglJ_yd5vvpnP1VQtJIaycgt5i6dMRuvdpARUP0gBp57GKW6Syy5Vewbco2g-eKJjsrqqdJxmJppGCOsljH-E7vLDCw0S9vPX4-69xFHGmOJQd88OqRHK-ycx0cgKyfYvn5ydcSb_goXJJ9tPwkPV6OBlNkf5rPSaT4qsYKDbNXdg-8HM_NeuHUtzRlzpPeexXnuU8UEaKXJIHjeAVTCxf0t_l8pHkwSYGtT3QwsyQKoIkDMpu7Vnk2ybviKTPRvh4R2POCzXC8eCmmJVslKrXq_DhhgPT6Q7Pi_482rUjjSm_e6SWfFvrl9nZDNpQT8zw7HlG-bt0H-foQcnAtiA3HQFbYVwvGBDul_zpPQY7Pl5uXGpxd1gIPysc-qQ68QJ9cv2n3styopH8pfal9wEXtkw-Y8aOQsSEKOinDeDDh0wBNKl2kNG9EoaDNItuoPLn2687yOUrQ.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:17.481999996Z

EXTINF:2.002,87d22d0b208d6a47c3bba6f412f7fb43-03-04-2019-05.03.22

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/Cs8DJIvtZeKT1-XGZYZ5RfeLlP2k3HbtTffKFlrpeQDYb8d_FLRMVA3YUbXeAbgSPDgg_a_PecB1Skgg7CgJ3VSJoLUYJeaqa5kw4KYtnYcFUbWwoM0V2UukzBUjJFT9YtwgCEyAe93eC0kMu-TZMV73q9m2DOY5lFfFLE_HK7xf3e3aa4BUhOG_1ja35zES8bEDx1-E7gqExJPOV7DRtDFts7fMvJKKHIxJR-OdIGe0Lirsr-dp560bGOjjz9-ONhcGXIHK8RL-UP8c5oudmzxkKmoodxPruD6de81bYs5QjDkHBjwqsEfRr4PQcme7bnMfw9N_OUzNo80zQORQLvA_DK1hMzCmC0c4U6CaEHFxTLsMuZqigqnomO377chV5w7YgE_dE1pE0oyT98V6thSVjsbAnYJztegRrn3ymtg35JB_8k_D7cUnGfruMlAhtKY10mc9Im1ib62X1UjBnF7VMvyOanLVvQeL0KX5zCrCWGgTgpJWqJA_D0XvRTXTkSQEo2GOdwiZQb2RkBbtaX4_WJijjB41APzPYhar6Y7NM5yNUFMKu2QwWKbHeygjon2zxVXSffCN0whXylIzUx85HKiOcPUQ-9HhJ9HuVIHFpxIQwwsCk-mpKvwnSO3bRRr5ABoMLfJFpHHn569yFj6l.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:19.483999995Z

EXTINF:2.002,87d22d0b208d6a47c3bba6f412f7fb43-03-04-2019-05.03.22

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/CtQEH7pdy1nqH4ax_3xaOCoov4OH5Esb81AAfHbhK-VWPwB7ao92sITh4-IFFTl0ctAXemi0DMET1xyFjNyurQQ65cPkzvIg9ZDkWGe3gbeK-CazcyItvB2biter4BGwX4o3aVq6G4yDtZzpxu0Gs75iD2p_hmBxcdFd-iWus2v1SEkS9R6UXgrDQy6FhVithK-DoQw-hiCrEC_qlc00ABWSyhDRxUOTpTSpweSbru1Dc-OczXLx9D867Sm75VX19xg9n890pv_Cdnq2pqVhTvhhMi0hNY6o0rJ95-cMqkYf2ht_spmS3DwcS8rGqqkdfguSMSN7nKZwnfVhnNlXN_nKTFc21U1u0cD_f8xQPLkxmVVx3r4GW-QPQCRu_FzilxPQNc8vaJA2kCmqaqWdIoARgkvWqssOsKGM_iTcVeOmBJ4X9ODIzynsubeYI_exJy7DRtX1DYS-CkUr5fTZlWQzAjs9u3QHEPKtDsX914ITCN01Kicm62mzUWMPLdcqhzZ7X4UzptmIh4RHmPP_d2V1L8d88ZpjbCsGrNNXrOXAy1qAXU-QxHy4vFZfmBYLIInKgOTKe33zzaRc7vav5ySB2rhqcxq-P6nM3KOSPcDoZqJ_JHkO4ooAYoiNhxzaOqVoLNemDs0fWliAmslwfM__VQjqGWBkHp_VxK-XrUl9RDhe2cyy5V4qHKW4AAiX0Q26W0eXCbENUH9d5GkJAgW84lf4xS8hooRLL91kw07WKRrD6GKcsrEjtgOdgG1wH33a4lnhPcVfnWWezh1-ErCuQiA5pfMSEKhpN6_lxjMOMBU2MscR0E8aDEhLG3MO4q39YEdukA.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:21.485999994Z

EXTINF:2.002,87d22d0b208d6a47c3bba6f412f7fb43-03-04-2019-05.03.22

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/Cs8DrWQonyJtr2R1ZicafFyXovVNRVLVESPA6jFdDr7zzMp5qwOqCyMRSxizfImbA2nZxgfKnZZjO7WRuaUU5xGP4l48GPAfQTujBY00gRm01c-SPuNWG4ytN46JvJyi3cFoJwAcKC6GmXKue4MpI0iKOxHwWifasumoHnUh42b5T2dohBg3iXqn1DkWytv2-pXsZ-v_wwjlQ4FMe93RzucKE8C21SZInJ7-i705wWPbXGfwrYzGdR1_wb3Zma6d8-wSUfaAhu31yHSBsbXxLYnM4Ox0dJtmg1ssPT3F63Z36KPpKfJOQObZTQvL4QnwJhzfmoyROvQsEsemzU2zEZzdlORdS3KkdJeR4M3iWxXJvrx37lo04ISWeE9yi4QHl5RoUdJgU3t_8-6652Ure5bd7k4CCCInGahEpxVI12DV6yCLFLkVmLK7oB7nXO83bybOHe5RgII9dhxqwWs8M2xMQmCFTuEz-mm0wKC638f76Y_jgxMkJdB_V8chq5a6MxR_f78zfIBGjTieUzOpg4EcKOB32zbtQG4iySassfCcFMZQgqSkNKVG2ZJLwS6D7NkmKsVF_hPypwSAvfvfkceYZ3e0DiksIcYfBjnRi8rsQhIQlJeMSFqUcVYC5VPfBsrZVRoMQ436aeP_CztrcLX4.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:23.487999993Z

EXTINF:1.150,87d22d0b208d6a47c3bba6f412f7fb43-03-04-2019-05.03.22

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/CtQEPTRDLrhBigT90xbGBPM9e3jpEdYNg7BzDnAS3dc1RhfZ9H7YHTGm72a6SVPuTJLTiDI8QGhcoROLpVOWT1OjCo5wwL1jafaL0-jkVj5IbMu5xmt7z52OsyHhaM8l1m5MoLJm3Dp8UOBKGyW8aercCTd7jOLtwbVbZY04rZ5xWZu-1i1L5CHF8mOPuV4_Cq5dgRQyldaOw2OOLgLTJPfuABheNrNMLeVKx_RHAqUsNiWxsJoY9-S9YjmYq0U8Xo3BARhpCcnagcIPGnv_Q-1kfn0khhTIXpaW8BkvK2xL6P3EibVWt6ycW-rLmtN8PlSeKImQB8f_2nnN1LiQfY8_m8QsA6cJwtpADhDZoVbGw353vJO5BrGg9drdskWkYpyDSlBBPPXifOvc4NEGbOdpw2U-KuQYiE-KiEi_YnpCV4flLSr54q1hYzqQye1Q18TIns7oUblLIC3Pt8GzVboYaUDNwsxuYWL7wpLJxVJ3pXOh_JSqL9wrD91G0s-mFa63i1gQKYnYXsJ5yQSaeCiVMt8OJzgqfRasoReIAtHipaAF2P75j0dQ7n_gYLn8pxg8h9gpQJEFDZTU7O1Vo80LJkV1gVkEpJlSQy7cQewsd5Q7k8mbE6dWnQefjm1qhlMPcmD1EyAefLOCvztCIEwKGHc3oiFo8yArAuQqcY58fCbN709zHwJUL1rIMOXd7TxUcY88L3jOzJAUYpef3rl-bu_olydGY4TRjZ18zy7ez-Cv-2DhLftxA-LkoJDRmOQgTNyBXQIl9_oo1Zc9ZwplzV7VtXYSEA2Swt_nIWzI7tky6PPeRnMaDEROAJjbpsZNb8UXiw.ts

EXT-X-DISCONTINUITY

EXT-X-SCTE35-IN

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:23.474Z

EXTINF:2.000,live

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/CssD9FUuObFo4POd_Ybn56nPDxWlkYk0yk_IqcU0DGDOwdcplu-73s3hEo6EIa-cbJHWfKoErokSGEH_M43IW82cmrPw7Jxtfm6U622eqrgzDl4vfp11pB4UTQlFxw8nmddy7IloXdFGt_aJbLlkPBcTf8uqFCU9m2hsTCD06UCHUjQ-DQivpplluN_QfgSq7Zgipb8XdfQ4mjFJz4CjB2DX5w8dJ9zeGS9zUTfm324IHm6ESUC8msiqoIY362wLHmDTT9f2UsSKqRslmbohQBN7XRnbzSkibMrD46_mAnwiW-51u4uo3-le3Imlg0bS6XFtIx046QUTdOuofM3uoQWk14Bvy8ipFoImJGC4dri1YarMI9JgqkldeaD_upYbzu3igajZshWjqEPT5hV1oxLQjHgKQ_k3UWraihnj4ZB_pvZenlCHsnFfzjkZlbRY1eVl9uU9HN-DdYmAn5S7Oai0tJYnvKYNLheTsTuvHjR_pMcMIzFqFxs4jxphP3CfNMaQ-zHoQ07_gwYDXVQIBjvcgMERzczkJxhmTHdgn9z2NaIqnJlZYgeL479XOz2Ckx9-KdMe3drkxCASMbQ9y7o_CXpJztW1vEHSA_wFEhAuV2G9YjS2B740_7OYu8LTGgxfO-sxuamZP-ZYqhQ.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:25.474Z

EXTINF:2.000,live

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/CssDiTl8sU7PF7hjLzzoSPvHUGzeyB4PxpF2jSIbg1YYOpsmdZkXNNDNfkUcgyswKwSWnO6at1GdOoUBt8PeL-8vRRm9Qx0A7Tux9ADm9uft4MZUfJh_1PLfRqxz9qjj--nOOvcUM8e9vUnYvxCQc_Ir1QDYb6UEZ0384XrsPlOpjAuSwu0IkvriZt22Ukv4QktvVvV4AvRjlDydggp4Hq-F7cjEjziRdo659HUnvxwy2v35s6euo07SiqhetvGIk7Li9yPBxGLhJ1Ou8rEIyLP_IoQc52PXwx4Lb3NKJXV5laxx78nAZRMMcu18jFqcLZCM0o-FWZFBE3qaVIU_fyzhoD0lrOh6NXgeRepLf5F43FuTOLl8K2iHiK__J715TkmP7zQxPHPe_IlrDhmim7H4Peh8MBv97RtZTCTKLGqK4492GUKYOIIhH9eTqKSPyKtpmWaHE686C6gb2x1yweV6cIJhAduK6MrOEafIT8qMdGCJpX7UbMgbgIKiVkhahddftyuSKqZmBpgCicP4E04kdIQOGA3MUfvUaxQqnxjVDmwgw4-7QO2rFW-ECIQ7Jm-DZM5FXspSTK5iX4LK__tM--DEUz-EwxZfCx18EhBq44dvZnQmdZN4lonGP7kgGgyTOsw72VyZpEsGo-Q.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:27.474Z

EXTINF:2.000,live

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/CssDfoIX3KwXXkJI81wrRPRE1-rz35q0Z3IqSg9cJwiStDIqVHhkYsO62jHdsWnTpTkkvDBE8HqmFOu8Di3HRmLyuMnwdfGiYEh8r9Vcy2D-2geKLk-WWnfSmOgFNi2KPCTRRz0emA1KNi5w940szrR5K4CbLZrOu8mQ4PKfprKWeaaD4iAKsMAaVS2g1DLrZFayJKOdZK-WrXYwJ_WP9fp31f1CKGVMNJVljllvxWqk4d9jlFpke3aCFJJJ8VBAplGuOJ9E5agy0NFh_8hKJ8TC1qd0slFoyDDlXDeNXsZPy4_CaOp5hZA3wl4DDLNg8DR8u2ojHPkwF-lYE3rUR5Da1C8CV-LBDnHzzfEbzQyJvw-UZCDl8PN5Stn_JAXlf2drX82hsC-E6Rv47YCG4W9fhPI1EC1QX7WzGclEfgvU92ze7oJvwIWTp1LRPhZyygoI9bBEp2_XvECTeAjcUIOn60FoZA49H-ey70ulSSe9NCuiH2wLFZHFTmXHlF_YLjQCre6CffnwIOy_0cVQ_9gwdDcKiaEHcTJNDH5bqtG2OXL6YgMh6x93BpFa8DYCdDdxeWiIm6xPO-MqoMCXOV00IO5OF_EBQ48CpcgoEhCQ-KOBRF2Gb4BK7T4W6KuSGgwhUJffs3XS229gzU4.ts

EXT-X-PROGRAM-DATE-TIME:2019-03-16T05:18:29.474Z

EXTINF:2.000,live

https://video-edge-8c79b4.syd01.abs.hls.ttvnw.net/v1/segment/CssD_Ho-6B-GwcbeTR7ZsImVYwKMM5ioNlMzW2TYi1F0JQbQN-abmGkq7D4ZXm4_EiYnRkpXt-5fPv-4Q2nV3-ilb9IpvMR7McmDuCgiNjsYt11npSyYnm9YHJATD8Ey_ua3qmhG7Y3TC0WcyRHuTw8FKZjhgWCfCrNNT3f3b1tDMyczY4TTSqtLhorCRsYf7-QIEPoDufvr-OhN9LhGi2AyST-QU7BAEqsNtR9kpcF6WcGZKG0x-SVPOkx3EepJPEQ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j5D4GTsnCcaXoBQu1OtH0EnVFi54aEhCtN3cHil0bIXAzU1EUalcXGgyU0oclPZz34lYjBTY.ts```

Thanks, I also just got an ad. Looks like the playlist containing the EXT-X-DISCONTINUITY tag is the one with ads (and the following ones until the next tag). I wonder if those could simply be dropped...

According to this chrome extension the ad segments are marked as advertisements using the SCTE-35 flag

Edit: A better source for the SCTE-35 messages in HLS might be Amazons own documentation on it here.

Thus the beginning of the ad should be marked with SCTE35-OUT and the end with SCTE35-IN

I can confirm this.
I just had a "twitch prime" ad for the first time today when I launched a stream.

Some more info:

While testing with Tfue's stream, Twitch isn't currently showing me any preroll ads in my browser while logged in to my Twitch account. I can consistently get preroll ads while opening his stream in private browsing mode though. It seems that Twitch may have saved a flag server-side to prevent showing me ads for some period of time.

Streamlink consistently displays the preroll ads on Tfue's stream every time. Using Streamlink OAuth to Twitch doesn't seem to help at all there.

Testing with other streams is inconsistent, Tfue's is one of the few i've found which will consistently display the preroll ad in Streamlink, it's probably a good candidate for testing while he remains live.

I made a small hacky modification to the low latency test plugin which prevents preroll ads from being shown in Streamlink, I still get an ad-length delay when opening the stream though so it's not particularly helpful.

Change line 378 from:
elif line.startswith("#EXTINF"):
To:
elif re.match("#EXTINF:[0-9].[0-9]*,live", line):
Make sure you keep the spaces preceding the line.
Note: Might break stuff.

Edit: Above change does break the stream after downloading about 16 segments. Left in case someone wants to expand on it.

I fear that Twitch will refuse to send you the live stream segments until the time when the ad would be complete and that there may not be a way around it.

A simple solution that works is to block the ip serving ads. Use wireshark and block the entire subnet.

Changing chrome user agent to "Blackberry --9900" prevents ads from appearing.

Changing chrome user agent to "Blackberry --9900" prevents ads from appearing.

How does one do this in streamlink ?

Don't know if it's related but the Alternative Player For Twitch extension for Chrome and FF just started showing ads too (as of last night). Seems Twitch have changed something their end.

I'll comment here as there isn't an issue open on the uBlockOrigin repo and I don't have a reddit account.

The https://api.twitch.tv/api/channels/XXXXXXXX/access_token? request is what determines if server side ads are delivered. A regular request/response by a browser without an adblocker will look as follows:

https://api.twitch.tv/api/channels/quin69/access_token?need_https=true&oauth_token&platform=web&player_backend=mediaplayer&player_type=site

{"token":"{\"adblock\":false,\"authorization\":{\"forbidden\":false,\"reason\":\"\"},\"blackout_enabled\":false,\"channel\":\"quin69\",\"channel_id\":56649026,\"chansub\":{\"restricted_bitrates\":[],\"view_until\":REDACTED},\"ci_gb\":false,\"geoblock_reason\":\"\",\"device_id\":null,\"expires\":REDACTED,\"game\":\"Path of Exile\",\"hide_ads\":false,\"https_required\":true,\"mature\":false,\"partner\":false,\"platform\":\"web\",\"player_type\":\"site\",\"private\":{\"allowed_to_view\":true},\"privileged\":false,\"server_ads\":true,\"show_ads\":true,\"subscriber\":false,\"turbo\":false,\"user_id\":null,\"user_ip\":\"REDACTED\",\"version\":2}","sig":"REDACTED","mobile_restricted":false}

The token/sig are then used as part of the m3u8 request. Notice that in the response the 'server_ads' param is 'true'. If you modify the 'platform' param in the request to be something like '_' the response now has 'server_ads' set to 'false' and ads are no longer shown.

https://api.twitch.tv/api/channels/quin69/access_token?need_https=true&oauth_token=&platform=_&player_backend=mediaplayer

{"token":"{\"adblock\":false,\"authorization\":{\"forbidden\":false,\"reason\":\"\"},\"blackout_enabled\":false,\"channel\":\"quin69\",\"channel_id\":56649026,\"chansub\":{\"restricted_bitrates\":[],\"view_until\":REDACTED},\"ci_gb\":false,\"geoblock_reason\":\"\",\"device_id\":null,\"expires\":REDACTED,\"game\":\"Path of Exile\",\"hide_ads\":false,\"https_required\":true,\"mature\":false,\"partner\":false,\"platform\":\"_\",\"player_type\":null,\"private\":{\"allowed_to_view\":true},\"privileged\":false,\"server_ads\":false,\"show_ads\":true,\"subscriber\":false,\"turbo\":false,\"user_id\":null,\"user_ip\":\"REDACTED\",\"version\":2}","sig":"REDACTED","mobile_restricted":false}

Last time there were changes to the way they served ads they quickly made additional changes so it's likely that this method wont work for long.

Here is a test url which can be used with uBlockOrigin's userResourcesLocation (which changes the platform to '_' as mentioned above) https://gist.githubusercontent.com/pixeltris/1338ad540175499b90b3dc245de663be/raw/58154403783563f0370dd7a39bc1517c39a81c7c/gistfile1.txt

@vohzi
You can change HTTP headers via --http-header "key=value".
Setting the User-Agent to Blackberry --9900 does not prevent ads from being injected into the stream. I don't think they will check the User-Agent string, since it can easily be faked.


@pixeltris
Adding the platform=_ GET parameter to the access_token API endpoint call seems to be working. But yeah, that's something they could fix very easily.
If anyone wants to try it, see this diff:

diff --git a/src/streamlink/plugins/twitch.py b/src/streamlink/plugins/twitch.py
index 410a22b6..17ce4e0b 100644
--- a/src/streamlink/plugins/twitch.py
+++ b/src/streamlink/plugins/twitch.py
@@ -222,7 +222,7 @@ class TwitchAPI(object):
     # Private API calls

     def access_token(self, endpoint, asset, **params):
-        return self.call("/api/{0}/{1}/access_token".format(endpoint, asset), **params)
+        return self.call("/api/{0}/{1}/access_token".format(endpoint, asset), **dict(platform="_", **params))

     def token(self, **params):
         return self.call("/api/viewer/token", **params)

The SureStream page says it is only available on desktop devices. Might be the reason why changing the platform parameter disables ad injection.

This isn't just limited to desktop devices. I am encountering ads using Pocket Plays as well as of this morning.

If anyone wants to try it, see this diff:

so far so good. no pre-rolls across multiple streams of varying sizes.
edit: no streamer triggered ads either.

This isn't just limited to desktop devices. I am encountering ads using Pocket Plays as well as of this morning.

if i load a pre-fix streamlink extracted url into safari for ios, ads will play. adguard pro for ios, however, still works for the official twitch app (forcing a system wide filtered dns using a local vpn). from memory, system level blocking works a similar way on android - my guess is if you were to do the same with the official android twitch app, you won't see ads. both apps might be passing along their respective platform strings - with dns/vpn intercepting the ad requests - while pocket plays is relying on similar methodology to streamlink. or maybe not, but worth a test.

Can

@vohzi
You can change HTTP headers via --http-header "key=value".
Setting the User-Agent to Blackberry --9900 does not prevent ads from being injected into the stream. I don't think they will check the User-Agent string, since it can easily be faked.

@pixeltris
Adding the platform=_ GET parameter to the access_token API endpoint call seems to be working. But yeah, that's something they could fix very easily.
If anyone wants to try it, see this diff:

diff --git a/src/streamlink/plugins/twitch.py b/src/streamlink/plugins/twitch.py
index 410a22b6..17ce4e0b 100644
--- a/src/streamlink/plugins/twitch.py
+++ b/src/streamlink/plugins/twitch.py
@@ -222,7 +222,7 @@ class TwitchAPI(object):
     # Private API calls

     def access_token(self, endpoint, asset, **params):
-        return self.call("/api/{0}/{1}/access_token".format(endpoint, asset), **params)
+        return self.call("/api/{0}/{1}/access_token".format(endpoint, asset), **dict(platform="_", **params))

     def token(self, **params):
         return self.call("/api/viewer/token", **params)

Can you explain how to apply that change so I can test it? Thanks

It seems that the workarounds were patched? Getting ads inserted even after using platform="_", "platform=_" and platform=_
I don't mind seeing ads but they are all causing the stream to skip content to a few seconds ahead. Twitch is really burying themselves here.

Are you running the latest dev version?
streamlink 1.0.0+38.g9ae6756
I'm not getting ads on any channel.

Getting ads inserted even after using platform="_", "platform=_" and platform=_

What do you mean? This looks like you're trying to set CLI parameters, which doesn't make any sense.

I was also kind of able to get rid of the ads by skipping all the files between the SCTE-35 markers. However the playlist will not contain enough regular segments for a bit. For me the normal stream continued after about 15 seconds which is probably still shorter than the actual ad is.

I installed streamlink-1.0.0-20190317 from here, and I still see ads. The installer says 1.0.0+38.g9ae6756 so I assume it's the correct one.

@sfkpmr Please completely remove any old installs first. You might still be using an older version which is still installed on your system or the installer might not have updated all of the files (which is a known issue). Please provide a proper debug log (--loglevel debug)

I just did a clean install for the first time and I'm getting ads.

位 streamlink --loglevel debug
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.6.6
[cli][debug] Streamlink: 1.0.0
[cli][debug] Requests(2.21.0), Socks(1.6.7), Websocket(0.54.0)
usage: streamlink [OPTIONS] <URL> [STREAM]

Use -h/--help to see the available options or read the manual at https://streamlink.github.io

Could I get some instructions regarding what to do to disable ads?
Thanks.

@bastimeyer I was using the headers option. It seems that github cuts out the _ inside "".

@bastimeyer Correct, I was stuck on an old version. Tested a number of streams, and no pre-rolls yet! :)

For some reason the old files didn't seem to be affected at all. Had to manually delete them and reinstall.

@otmeek You are not using the latest development version, you are using the latest stable release (1.0.0)

@Satoshi64 It's regular markdown. Use `text` to format inline code. But regarding the parameter, it's not an HTTP header, but an HTTP GET parameter of a certain API request. You can't use any of Streamlink's CLI options to set this. Just upgrade Streamlink or replace the plugin file in order to make it work.


I will lock this thread now, since the the current ads workaround is still working and the issue solved. If you're having troubles getting it to work, please uninstall Streamlink and install the latest development release. More information can be found here:
https://streamlink.github.io/latest/install.html
https://streamlink.github.io/latest/install.html#source-code
https://streamlink.github.io/latest/install.html#windows-binaries

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TheSneakySniper picture TheSneakySniper  路  55Comments

bastimeyer picture bastimeyer  路  72Comments

gimli520 picture gimli520  路  106Comments

cdrage picture cdrage  路  43Comments

jacob1218 picture jacob1218  路  42Comments