Youtubeexplode: Some videos work on localhost but not on server!

Created on 18 Jun 2019  路  28Comments  路  Source: Tyrrrz/YoutubeExplode

Hello,
I have some videos that play well on localhost but don't work on the server, ex;
https://youtu.be/Nnqk-yGzYYg
https://youtu.be/4uE-tqe0xsQ

Please advise.

duplicate

Most helpful comment

Update to latest version

All 28 comments

Possible Causes:

  1. Server is in a different country = videos might be blocked in that country.
  2. Server provider is blocking calls to youtube.

Possible Causes:

  1. Server is in a different country = videos might be blocked in that country.
  2. Server provider is blocking calls to youtube.

Thanks for this, but both items don't apply!

  1. Do they fail each time?
  2. Server OS?
  3. .net core/.net framework/mono version
  4. What error is returned?
  1. Do they fail each time?
  2. Server OS?
  3. .net core/.net framework/mono version
  4. What error is returned?
  1. They were working well before, this has happened a few days ago and always fail to load.
  2. Windows Server.
  3. 4.5 and not sure about the mono version.
  4. There is no specific error, the videos just not loading, other videos are working well and this has been reported by several users.

Please note: the videos are working fine on the local machine!

Could you give the above videos a try?

@SlowLogicBoy Any ideas? Is possible to try the videos at your end?

The IP which requested the stream info set and the IP which later accesses a stream should match.
Stream URLs are valid for specific IP.

@Tyrrrz it doesn't work for me when I create the video and trying to watch it from the same IP, so I think your assumption couldn't be the reason.
Why does it work on localhost?
BTW: this happens with some videos and other videos work fine, could you try to the videos yourself?

I hope to get this solved ASAP. Thanks in advance.
Your help is appreciated.

I can download those videos locally.

it doesn't work for me when I create the video and trying to watch it from the same IP

If i understood correctly the stream URLs are resolved server-side, which means they are valid to be requested by the server itself, not the originator of a web request.

Can you give an example URL that fails?

Thanks @Tyrrrz!

I made a test website and here are 2 links:
http://wesbyte-001-site3.etempurl.com/w/acoq
http://wesbyte-001-site3.etempurl.com/w/Mboq

Please note, the same script loads other videos successfully and the videos that are not working now were working before without issues.

Please advise ASAP.

@Tyrrrz @SlowLogicBoy any ideas?

Yes, as you've mentioned, the IP is the same but it's not my IP and not your IP

But the first video doesn't work but the second one works while the server IP is the same in both cases, so why do you think the IP is the issue? and is there a workaround for this?

Hm, in my case both of them didn't work

Apart from that, I honestly don't know.
A workaround is to either get video stream info set on frontend (e.g. via Blazor) or return a video stream as a stream instead of a URL from the backend.

Please try this URL http://wesbyte-001-site3.etempurl.com/w/zmo and look into the HTML source code to get the URL (it works), it will work and you may be able to compare it to http://wesbyte-001-site3.etempurl.com/w/acoq (it doesn't work)
BTW: The streaming URL seems to expire after a while that's why you didn't get it to work.

FYI: my requirements is to display the video and not to download it.

Yes, that works. I really don't know what to advise regarding the reasons for why the second one fails besides the IP difference, maybe it's not enforced on all videos.

Consider making a controller action that returns a Stream and use GetMediaStreamAsync to route the data to the client.

I'm using GetVideoMediaStreamInfosAsync is that the same as GetMediaStreamAsync ?

No, those are different.
GetVideoMediaStreamInfosAsync requests a list of streams and their metadata.
GetMediaStreamAsync resolves an actual stream from metadata

Apart from that, I honestly don't know.
A workaround is to either get video stream info set on frontend (e.g. via Blazor) or return a video stream as a stream instead of a URL from the backend.

I'll give GetMediaStreamAsync a try and let you know the result, re. your above comment, do you have a code sample to get the stream instead of the URL?

I appreciate your help on this :)

You can probably take some inspiration from https://github.com/SlowLogicBoy/YoutubeExplode.AspNetCore.Mvc

You can probably take some inspiration from https://github.com/SlowLogicBoy/YoutubeExplode.AspNetCore.Mvc

Thanks, @Tyrrrzi ! I think this is to download the video and not to display it in the bowser ... Am I correct?

@Tyrrrz and @SlowLogicBoy I got the below error which could help:

YoutubeExplode.Exceptions.UnrecognizedStructureException: Could not find signature decipherer function name. at YoutubeExplode.YoutubeClient.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 YoutubeExplode.YoutubeClient.d__43.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 VB.VB$StateMachine_1_GetVideoStream.MoveNext()

Update to latest version

The update did the trick. Thanks a million :)))))

You're welcome :)

Was this page helpful?
0 / 5 - 0 ratings