pixeltris / TwitchAdSolutions

7.21k stars 424 forks source link

The video download was cancelled. Please try again. (Error #1000) #259

Closed drspod closed 2 weeks ago

drspod commented 3 weeks ago

Browser: Firefox 126.0.1 (Desktop) Filter: video-swap-new (uBO)

Since a couple of days ago I have been experiencing streams regularly cutting out with this error: "The video download was cancelled. Please try again. (Error #1000)" This happens every couple of minutes or so, and usually at the moment when an ad would have been run.

twitch-error

The problem is resolved when commenting out the line twitch.tv##+js(twitch-videoad) from my filter list, so it must be caused by the filter script in some way. The problem also does not occur on channels that do not show ads (eg. because I am subscribed to the channel).

Checking the network log, I see that whenever this problem occurs, it coincides with an error returned to the following request:

GET /v1/playlist/CucFj1A3LztPPs0VDhiF3 <... snipped ...>.m3u8 HTTP/1.1
Host: video-weaver.cdg10.hls.ttvnw.net
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0
Accept: application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br, zstd
Referer: https://www.twitch.tv/
Origin: https://www.twitch.tv
DNT: 1
Sec-GPC: 1
Connection: keep-alive
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
Priority: u=4
HTTP/1.1 400 Bad Request
vary: Accept-Encoding
date: Mon, 10 Jun 2024 15:48:40 GMT
content-length: 0
access-control-allow-origin: *

I have tried clearing my browser cache and cookies but this did not change the behavior.

twitch-error2

Please let me know if there is any additional information I can provide to help debug this issue. Thank you.

xunkar commented 3 weeks ago

I will say that this is also happening with video-swap-new and vaft, using uBlock Origin or Tamper Monkey. The console logs the following error when it happens:

An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#%7B%22version%22%3A%223.8.7%22%2C%22message%22%3A12%2C%22args%22%3A%5B%22slug%22%2C%22%7B%5Cn%20%20%5C%22__typename%5C%22%3A%20%5C%22Game%5C%22%2C%5Cn%20%20%5C%22name%5C%22%3A%20%5C%22Just%20Chatting%5C%22%2C%5Cn%20%20%5C%22displayName%5C%22%3A%20%5C%22Just%20Chatting%5C%22%2C%5Cn%20%20%5C%22id%5C%22%3A%20%5C%22509658%5C%22%5Cn%7D%22%5D%7D

followed by

Player stopping playback - error MediaPlaylist:4 (ErrorInvalidData code 0 - Response body is not a valid M3U8.)

Elaws commented 3 weeks ago

Same error with vaft, very regularly, on a stream without ads.

randomrandom01 commented 3 weeks ago

Same error with purple commercial breaks

YofarDev commented 3 weeks ago

Until it's fixed, is there a way to catch the error and just restart the player when it happens?

Afali95 commented 3 weeks ago

Same here, I think Twitch may have updated its code in a way to block the adblocking Script. I hope there's a new script in the futur

stevenya97 commented 3 weeks ago

I will say that this is also happening with video-swap-new and vaft, using uBlock Origin or Tamper Monkey. The console logs the following error when it happens:

An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#%7B%22version%22%3A%223.8.7%22%2C%22message%22%3A12%2C%22args%22%3A%5B%22slug%22%2C%22%7B%5Cn%20%20%5C%22__typename%5C%22%3A%20%5C%22Game%5C%22%2C%5Cn%20%20%5C%22name%5C%22%3A%20%5C%22Just%20Chatting%5C%22%2C%5Cn%20%20%5C%22displayName%5C%22%3A%20%5C%22Just%20Chatting%5C%22%2C%5Cn%20%20%5C%22id%5C%22%3A%20%5C%22509658%5C%22%5Cn%7D%22%5D%7D

followed by

Player stopping playback - error MediaPlaylist:4 (ErrorInvalidData code 0 - Response body is not a valid M3U8.)

If you have multiple scripts enabled in Tampermonkey or both uBo script applied and userscripts enabled, the scripts can conflict with each over trying to grab the clean m3u8 video stream and you can see that error. Try using only one solution/script

stevenya97 commented 3 weeks ago

Until it's fixed, is there a way to catch the error and just restart the player when it happens?

Are you still seeing this happen? I can't reproduce it. I'm trying to find the div where this error appears. Theoretically it is simple to have a userscript check for the error appearing every couple of seconds and reload if detected. Would be better if I could just scan the exact place it'll be instead of scanning the entire page

drspod commented 3 weeks ago

Are you still seeing this happen? I can't reproduce it.

Yes, I only had to watch a stream for 10min before it reproduced the issue. This time the error response was a 502 Bad Gateway instead of the 400 Bad Request. Regardless of whatever is going on in twitch's backend, the script needs to handle any HTTP error returned from this request and not crash the stream.

GET /v1/playlist/Ct0FNAPBim<... snipped ...>.m3u8 HTTP/1.1
Host: video-weaver.cdg10.hls.ttvnw.net
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0
Accept: application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br, zstd
Referer: https://www.twitch.tv/
Origin: https://www.twitch.tv
DNT: 1
Sec-GPC: 1
Connection: keep-alive
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
Priority: u=4
HTTP/1.1 502 Bad Gateway
content-length: 107
cache-control: no-cache
content-type: text/html
access-control-allow-origin: *

The twitch player fails with the same "The video download was cancelled. Please try again. (Error #1000)" error.

xunkar commented 3 weeks ago

If you have multiple scripts enabled in Tampermonkey or both uBo script applied and userscripts enabled, the scripts can conflict with each over trying to grab the clean m3u8 video stream and you can see that error. Try using only one solution/script

Do you mean just uBlock Origin, or specifically running with the userResources set to vaft or video-swap-new? I do have uBlock Origin on, but reset the userResources property before installing vaft through TamperMonkey.

However, I got rid of the "twitch.tv##+js(twitch-videoad)" filter like someone mentionned, and so far I've had no new errors.

pixeltris commented 3 weeks ago

@stevenya97 no it's definitely a problem with the script I just haven't had time to address it.

The problem is when it detects an ad it returns an empty m3u8 response which results in the error on every midroll.

https://github.com/pixeltris/TwitchAdSolutions/blob/8632ee23ad2537527f09f6c1d3192036ea12eca3/video-swap-new/video-swap-new.user.js#L190-L192

There is also another issue which I think is due to not properly handling error codes such as 404. These ones should be slightly more rare such as when a stream is restarted but I'm not certain on that. Hopefully passing the correct error code to the player fixes those.

https://github.com/pixeltris/TwitchAdSolutions/blob/8632ee23ad2537527f09f6c1d3192036ea12eca3/video-swap-new/video-swap-new.user.js#L206-L218

This is a duplicate of #228. I'll leave this open and try to fix stuff up this weekend.

stevenya97 commented 3 weeks ago

@pixeltris Noted, thanks. I must have confused this with a different previous issue. I only tested with prerolls no midrolls which could be why I didn't come across this error.

pixeltris commented 2 weeks ago

Should be fixed in https://github.com/pixeltris/TwitchAdSolutions/commit/644ac7a8217880597db52b506ae4d3ded287bedc