Tyrrrz / YoutubeExplode

Abstraction layer over YouTube's internal API
MIT License
2.95k stars 493 forks source link

GetVideoAsync fails on unavailable videos #155

Closed tuanbs closed 6 years ago

tuanbs commented 6 years ago

I'm using the latest version 4.3.3 and got the error message: Video [KOOtkK1F734] is not available and cannot be processed. Code: 150. Reason: This video is not available... Its Youtube url is: https://www.youtube.com/watch?v=KOOtkK1F734.

Details:

at YoutubeExplode.YoutubeClient.<GetVideoInfoAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at YoutubeExplode.YoutubeClient.<GetVideoAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Web.Controllers.WebApi.FilesController.<GetYoutubeInfoByYoutubeVideoUrl>d__8.MoveNext() in

Thanks in advance for any help. Cheers.

SlowLogicBoy commented 6 years ago

Well you can't get unavailable videos form youtube.

Tyrrrz commented 6 years ago

Indeed, the error is actually accurate, the video cannot be opened.

tuanbs commented 6 years ago

But I can download it using youtube-dl. What's wrong with YoutubeExplode?

Tyrrrz commented 6 years ago

I would be more curious what is it that Youtube-dl is doing that lets it download unavailable videos

tuanbs commented 6 years ago

I would be more curious what is it that Youtube-dl is doing that lets it download unavailable videos

Hi, I mean the video is available from this url: https://www.youtube.com/watch?v=KOOtkK1F734 and I'm able to download it using youtube-dl. But YoutubeExplode cannot download it.

shaked6540 commented 6 years ago

I'm getting video unavailable too, it is probably region locked

Giggitybyte commented 6 years ago

I feel there needs to be more of a descriptive error message here from the lib. Video not available without any real context or anything to go off of isn't great. It be nice if we could get an enum or something that allows us end users to programmatically figure out why something is unavailable and do something about it.

shaked6540 commented 6 years ago

I don't think youtube supplies that information

shaked6540 commented 6 years ago

just to confirm, youtube-dl cant download it either: https://image.prntscr.com/image/hUSlVy6fTIinLksIcfaN1A.png

tuanbs commented 6 years ago

just to confirm, youtube-dl cant download it either: https://image.prntscr.com/image/hUSlVy6fTIinLksIcfaN1A.png

I can download it:

screenshot 2018-10-06 09 33 35
Giggitybyte commented 6 years ago

Works on my machine.

Giggitybyte commented 6 years ago

I also believe it is totally possible to get the reason for unavailability. There are websites out there that allow you to check if a video is region locked, so I don't see why YoutubeExplode couldn't do that too. I'd imagine there'd also be ways to parse the page and figure out if a video is age restricted, copyright claimed, etc.

smartbracker commented 6 years ago

YoutubeExplode working here, this video https://www.youtube.com/watch?v=KOOtkK1F734

Tyrrrz commented 6 years ago

I think this is indeed country block and YtDl is doing something to circumvent it, probably. Although it's weird that it still failed for @shaked6540

smartbracker commented 6 years ago

I'm not sure and I did not stop to study.

Seens youtube-dl use a common User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0 YoutubeExplode use exclusive User-Agent. YoutubeExplode (github.com/Tyrrrz/YoutubeExplode)

If someone with error this video is not available, want try change User-Agent header.

Maybe it will not change anything, but it does not hurt to try.

shaked6540 commented 6 years ago

I just tried that, same error I think its blocking by IP and not user agent

Tyrrrz commented 6 years ago

I can't download with yt-dl either. image

Tyrrrz commented 6 years ago

It looks like it's in fact not country blocked, at least for me.

tuanbs commented 6 years ago

Today I got another error message: Additional text encountered after finished reading JSON content: }. Path '', line 1, position 15048.

Details:

at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.Linq.JToken.Parse(String json, JsonLoadSettings settings)
   at YoutubeExplode.YoutubeClient.<GetVideoEmbedPageConfigAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at YoutubeExplode.YoutubeClient.<GetVideoPlayerContextAsync>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at YoutubeExplode.YoutubeClient.<GetVideoMediaStreamInfosAsync>d__40.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Web.Controllers.WebApi.FilesController.<GetYoutubeInfoByYoutubeVideoUrl>d__8.MoveNext() in 

There were just some of videos in my website got this error when I posted this issue. But now all of videos have this error. Any help or idea would be much appreciated. Thanks in advance.

SlowLogicBoy commented 6 years ago

@tuanbs this is a different issue #164 is what you are looking for.