Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can Not Play video any more - XCDYouTubeVideoErrorDomain Code=-3 #525

Closed
JmyW opened this issue May 18, 2021 · 41 comments
Closed

Can Not Play video any more - XCDYouTubeVideoErrorDomain Code=-3 #525

JmyW opened this issue May 18, 2021 · 41 comments

Comments

@JmyW
Copy link

JmyW commented May 18, 2021

Start from today(or maybe yesterday). Most of videos are failed to play. The error is returned "XCDYouTubeVideoErrorDomain Code=-3".

https://www.youtube.com/watch?v=AgFeZr5ptV8
https://www.youtube.com/watch?v=bnVUHWCynig
https://www.youtube.com/watch?v=clJsnBoVQDA

Could anyone help? thanks in advance.

@fightveryexplosion
Copy link

I'm having the same issue since this morning.
The failures seem to be random, the same video is sometimes available to be played and sometimes fails.
I have not found the root cause of this all yet, but it seems like the issue lies with YouTube's get_video_info URL sometimes returning a 404 error.
The following is the print of the NSHTTPURLResponse I get when trying to access the get_video_info in the -(void) handleVideoInfoResponseWithInfo:(NSDictionary *)info response:(NSURLResponse *)response handler inside XCDYouTubeVideoOperation.m

<NSHTTPURLResponse: 0x2834e8180> { URL: https://www.youtube.com/get_video_info?el=embedded&hl=ja&ps=default&video_id=dy90tA3TT1c } { Status Code: 404, Headers { "Alt-Svc" = ( "h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"" ); "Cache-Control" = ( "no-cache" ); "Content-Length" = ( 0 ); "Content-Type" = ( "text/html; charset=utf-8" ); Date = ( "Tue, 18 May 2021 06:10:38 GMT" ); Expires = ( "Tue, 27 Apr 1971 19:44:06 GMT" ); Server = ( "YouTube Frontend Proxy" ); "Set-Cookie" = ( "VISITOR_INFO1_LIVE=YqCzchuOn6U; path=/; domain=.youtube.com; secure; expires=Sun, 14-Nov-2021 06:10:38 GMT; httponly", "YSC=hmbP_-FCTAY; path=/; domain=.youtube.com; secure; httponly" ); "Strict-Transport-Security" = ( "max-age=31536000" ); p3p = ( "CP=\"This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en for more info.\"" ); "x-content-type-options" = ( nosniff ); "x-frame-options" = ( SAMEORIGIN ); "x-xss-protection" = ( 0 ); } }

If anyone has any idea how to solve this I would love to hear about it!
I'll update as well if I figure this out...

@bark1n9
Copy link

bark1n9 commented May 18, 2021

Same here! Sometimes it fails other times it works fine.

@tristiando
Copy link

I got the same error:
"Failed to decode response from https://www.youtube.com/get_video_info?el=embedded&hl=en&ps=default&video_id=vlDzYIIOYmM"

@JaydeepVirani303
Copy link

Sometime, i got two error:-
Domain: XCDYouTubeVideoErrorDomain
Code: -2
User Info: {
NSLocalizedDescription = "Invalid parameters.";
NSURL = "https://www.youtube.com/get_video_info?el=detailpage&hl=en&ps=default&video_id=";
}

Domain: XCDYouTubeVideoErrorDomain
Code: -3
User Info: {
}

Please suggest me right path, my application is live on appstore and many user will get same error.

@fightveryexplosion
Copy link

I still have no idea what is actually causing this.
However, since the 404 errors seem to be random I realised that just retrying when they happen seem to make most videos able to play. I'm not sure if this is the best way of handling this though, but at least in my case it has reduced the number of errors from happening almost 80% of the time to a very small percentage.

By adding the following code to XCDYouTubeVideoOperation.m, just below the error handling for HTTP 429 errors (around row 373 or so), it is possible to retry when this error happens.

if ([(NSHTTPURLResponse *)response statusCode] == 429)
{
    // error handling for 429 errors
}

/** ↓ Insert from here **/
if ([(NSHTTPURLResponse *)response statusCode] == 404 && responseString.length == 0)
{
    [self handleConnectionError:[NSError errorWithDomain:XCDYouTubeVideoErrorDomain code:XCDYouTubeErrorEmptyResponse userInfo:@{NSLocalizedDescriptionKey : @"The response is empty."}] requestType:requestType];
    return;
}
/** ↑ Insert end **/

if (responseString.length == 0)
{

If anyone have any better solutions, please share them!

@knbx
Copy link

knbx commented May 19, 2021

I tried the approach above, but in my testing this didn't seem to have much effect at all. I even increased the amount of retries, but once there's a 404 it seems to be unavailable for a little while:

screenshot

@joro1
Copy link

joro1 commented May 19, 2021

Unfortunately I have nothing new to add (re fixes) except to confirm as of today I'm noticing this same issue. Looking forward to learning more, i.e. what can be done to quickly fix.

@bark1n9
Copy link

bark1n9 commented May 19, 2021

Could this be related? https://issuetracker.google.com/issues/186560114

@markeins
Copy link

Unfortunately I have nothing new to add (re fixes) except to confirm as of today I'm noticing this same issue. Looking forward to learning more, i.e. what can be done to quickly fix.

Same here, I started experiencing the bug today...

@alejandro-ulloa-dev
Copy link

Same here, videos are not reproducing

@manobal
Copy link

manobal commented May 20, 2021

Same here... none of the videos are playing..

@fightveryexplosion
Copy link

Hmm, I did add a few other changes as well, like incorporating #524, apart from retrying on 404 errors.
I am now able to play all videos. It's strange that the same doesn't seem to work for you guys..
My way of retrying doesn't seem to be the best way of handling this error anyway, so I am still interested in any solutions you can find.

@joro1
Copy link

joro1 commented May 20, 2021

Hmm, I did add a few other changes as well, like incorporating #524, apart from retrying on 404 errors.
I am now able to play all videos. It's strange that the same doesn't seem to work for you guys..
My way of retrying doesn't seem to be the best way of handling this error anyway, so I am still interested in any solutions
you can find.

Adding your 404 retry code (w/ no other changes) does seem to be solving the issue for me*, i.e. in (as specified in your previous response) I added your code to XCDYouTubeVideoOperation.m:

if ([(NSHTTPURLResponse *)response statusCode] == 404 && responseString.length == 0) {
..

Thank you, very much appreciated.
However, wondering if this is just a temporary issue @ YouTube (seemingly w/ get_video_info) or if this signals a major change in how moving forward we can access YT video data in-app.

*PS I checked how many Xs the retry code is triggered and it's consistently 2Xs before the method (handleConnectionSuccessWithData:) continues successfully w/o retrying. Reason why this works (consistently after retrying 2Xs) is beyond my understanding, just happy it does (work, for now).

@mjroldan
Copy link

Same issue encounter today. any update on this?

Domain: XCDYouTubeVideoErrorDomain Code: -3 User Info: { } The operation couldn’t be completed. (XCDYouTubeVideoErrorDomain error -3.)

@JmyW
Copy link
Author

JmyW commented May 20, 2021

@fightveryexplosion Thanks a lot for the great work and sharing. In my case, it's solved. Appreciate!
@mjroldan Have you tried the solution fightvertexplosion shared? It indeed works.

@mjroldan
Copy link

@fightveryexplosion Thanks a lot for the great work and sharing. In my case, it's solved. Appreciate!
@mjroldan Have you tried the solution fightvertexplosion shared? It indeed works.

Not yet so far but do we have any solution without having resubmit the app to app store?

@FazilMuhammed
Copy link

How can fix this error please help anyone

@asyncdigital
Copy link

looks like the get_video_info API is either temporarily not available or disabled completely from youtube. Opening this page -https://www.youtube.com/get_video_info?video_id=B4CRkpBGQzU
in browser gives a 404.

If this API starts working (Youtube controls it), this repo might start working again.

@trung10101995
Copy link

trung10101995 commented May 20, 2021

Same here! all my videos
[XCDYouTubeKit] Video operation finished with error: The operation couldn’t be completed. (XCDYouTubeVideoErrorDomain error -3.)
Domain: XCDYouTubeVideoErrorDomain
Code: -3
User Info: {
}

@knbx
Copy link

knbx commented May 20, 2021

@fightveryexplosion Interesting, I also used that PR as a base, but for me the 429 error handling is at line 218 not 373.

Do you see the first call (get_video_info?el=embedded) fail and the second (get_video_info?el=detailpage) work when you test? Just wondering aloud how the tweak seems to work for some and not for others.

Hopefully that API is simply bugged and fixed by Google. The official library doesn't help our tvOS app...

@joro1
Copy link

joro1 commented May 20, 2021

looks like the get_video_info API is either temporarily not available or disabled completely from youtube. Opening this page -https://www.youtube.com/get_video_info?video_id=B4CRkpBGQzU
in browser gives a 404.

Same issue, I was also getting 404 error(s) even when testing get_video_info from a browser,
however in app @fightveryexplosion retry fix works for me and always after the second try — don’t know why this succeeds after retrying twice because I assume the underlying call is also to get_video_info (which as we experienced is now always returning 404 errors from the browser).

@JaydeepVirani303
Copy link

@fightveryexplosion Great, it's working, thanks!
But i got another issue like i could not get captionURLs and autoGeneratedCaptionURLs, i need to show caption in video. Before it was working ,but after applying this solution i could not get above parameter. Anyone know about this issue please help me, thanks.

@knbx
Copy link

knbx commented May 20, 2021

I did some more testing and noticed that the retry tweak works when I'm on a VPN to the US (from EU). Curiously, I still see the 404 errors when inspecting my network calls, but a few seconds later video stream data arrives regardless. When the VPN is disabled, this never happens.

Might be useful for the others who reported the tweak not working to test this if they have a lot of users outside the EU.

@jatin19121990
Copy link

@0xced
I have Generated PR For #526
Please review it and let me know

@knbx
Copy link

knbx commented May 20, 2021

Just wanted to confirm that the fix above also works in the EU, awesome!

@joro1
Copy link

joro1 commented May 20, 2021

Thanks @jatin19121990, this works for me too.
(Commented out the retry code posted earlier and replaced with this fix.)

@fightveryexplosion
Copy link

Wow, thank you! This works for me as well, without the need for retrying! @jatin19121990 you're the best!
And to think all it took to fix this was one additional parameter to the get_video_info request, lmao.

@joro1
Copy link

joro1 commented May 21, 2021

Wow, thank you! This works for me as well, without the need for retrying! @jatin19121990 you're the best!
And to think all it took to fix this was one additional parameter to the get_video_info request, lmao.

@fightveryexplosion, your retry worked too, a clever temporary fix that had our app up and running last night before today's parameter addition. Thanks again.

@JmyW
Copy link
Author

JmyW commented May 21, 2021

@jatin19121990 @fightveryexplosion Thank you both so much for solving this issue. And thanks for all people joining discussion and sharing status. Since it's confirmed fixed by both ways from multiple participants, I'm closing this issue.

@JmyW JmyW closed this as completed May 21, 2021
jatin19121990 added a commit to jatin19121990/XCDYouTubeKit that referenced this issue May 21, 2021
…y-more---XCDYouTubeVideoErrorDomain-Code=-3-0xced#525

Can Not Play video any more - XCDYouTubeVideoErrorDomain Code=-3 0xced#525
@ryanfrancesconi
Copy link

ryanfrancesconi commented May 24, 2021

Does this merge need a SPM release to show?

@GregoireTapptic
Copy link

@0xced could we get a new release with this fix please?

nanameue-odan pushed a commit to nanameue-odan/XCDYouTubeKit that referenced this issue May 27, 2021
alexeichhorn added a commit to alexeichhorn/XCDYouTubeKit that referenced this issue May 30, 2021
…y-more---XCDYouTubeVideoErrorDomain-Code=-3-0xced#525

Can Not Play video any more - XCDYouTubeVideoErrorDomain Code=-3 0xced#525
@joro1
Copy link

joro1 commented Jun 16, 2021

I'm again encountering the same error we had (and previously resolved) last month, i.e.

https://www.youtube.com/get_video_info is failing w/ 404 error again
^^ specifically in my application calls to e.g. '[XCDYouTubeClient getVideoWithIdentifier:' fail.

For the past month the addition of parameter html5=1, i.e. as per @jatin19121990 was working, but as of the past ~12 hours it stopped working again, see:
8389cd3

I re-applied the following, i.e. specifically @fightveryexplosion retry fix, see:
#525 (comment)

^^ The retry fix seems to work for almost videos I've so far tried, I'm assuming Youtube has again added (or removed) a parameter requirement for their 'get_video_info' endpoint, but until another fix comes along applying the @fightveryexplosion fix as per 525#issuecomment-843923468 resolves the issue, i.e. quoting @fightveryexplosion (thank you again, @fightveryexplosion):

XCDYouTubeVideoOperation.m

around row 373 or so), it is possible to retry when this error happens.

if ([(NSHTTPURLResponse *)response statusCode] == 429)
{
// error handling for 429 errors
}

/** ↓ Insert from here */
if ([(NSHTTPURLResponse )response statusCode] == 404 && responseString.length == 0)
{
[self handleConnectionError:[NSError errorWithDomain:XCDYouTubeVideoErrorDomain code:XCDYouTubeErrorEmptyResponse userInfo:@{NSLocalizedDescriptionKey : @"The response is empty."}] requestType:requestType];
return;
}
/
↑ Insert end **/

if (responseString.length == 0)
{

@GregoireTapptic
Copy link

Same here :(

@bark1n9
Copy link

bark1n9 commented Jun 16, 2021

Same

@christopherafbjur
Copy link

I'm experiencing the same issue. This PR 8389cd3 has been working as of a couple of days ago but now I'm experiencing this again. Video plays sometimes, but sometimes not and when not this is the error message I keep seeing:

[XCDYouTubeKit] Video operation finished with error: The operation couldn’t be completed. (XCDYouTubeVideoErrorDomain error -3.)
Domain: XCDYouTubeVideoErrorDomain
Code:   -3

@Oleh-Poremskyy
Copy link

I'm experiencing the same issue. It worked but now I see the error again: "Error Domain=XCDYouTubeVideoErrorDomain Code=-3". Please help

@devbest555
Copy link

devbest555 commented Jun 18, 2021

same issue. it worked before and I am not getting error but doesn't play the video today.
Common videos work fine but only "LIVE NOW" videos don't work

@asyncdigital
Copy link

asyncdigital commented Jun 18, 2021 via email

@rcaram22
Copy link

Same here, it's not working once again.

@datenstau
Copy link

This post https://stackoverflow.com/a/68054873/3937348 covered this issue, too.

The currently working url for get_video_info seems to be https://www.youtube.com/get_video_info?video_id={{videoId}}&eurl=https%3A%2F%2Fyoutube.googleapis.com%2Fv%2F{{videoId}}&html5=1&c=TVHTML5&cver=6.20180913

@EParedez
Copy link

EParedez commented Jul 3, 2021

a small fix (XCDYouTubeVideoOperation.m), version 2.15.2

- (void) startNextRequest
{
	if (self.eventLabels.count == 0)
	{
		if (self.requestType == XCDYouTubeRequestTypeWatchPage || self.webpage)
		{
			if (self.ranLastEmbedPage == NO) {
				[self startLastEmbedPageRequest];
				return;
			}
			[self finishWithError];
		}
		else
		{
			[self startWatchPageRequest];
		}
	}
	else
	{
		NSString *eventLabel = [self.eventLabels objectAtIndex:0];
		[self.eventLabels removeObjectAtIndex:0];
		
        NSDictionary *query = @{ @"video_id": self.videoIdentifier, @"eurl": @"https%3A%2F%2Fyoutube.googleapis.com%2Fv%2Fonz2k4zoLjQ", @"html5": @"1", @"c": @"TVHTML5", @"cver": @"6.20180913" }; // only this is new
		NSString *queryString = XCDQueryStringWithDictionary(query);
		NSURL *videoInfoURL = [NSURL URLWithString:[@"https://www.youtube.com/get_video_info?" stringByAppendingString:queryString]];
		[self startRequestWithURL:videoInfoURL type:XCDYouTubeRequestTypeGetVideoInfo];
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests