iBicha / UnityYoutubePlayer

Play YouTube videos in Unity
The Unlicense
336 stars 63 forks source link

HTTPError 429: 'Too Many Requests' #36

Closed MTM-AG closed 4 months ago

MTM-AG commented 3 years ago

Hello, I am using this plugin to play youbue videos on Andorid and iOS. Since today I have noticed that my application closes when the video should start. This only happens on Android devices, while no problems on iOS. Even in the Unity editor everything works normally, without exception. How can this problem be solved?

iBicha commented 3 years ago

Please provide some crashlogs or any exception messages

MTM-AG commented 3 years ago

unfortunately I don't find any exceptions, as it only happens if I run the application on the device. I also tried only your example scene but the same thing happens

iBicha commented 3 years ago

Welp, it's virtually impossible to help without any clue on why something didn't work. If this issue happens consistently, look up how to gather logcat logs from an Android device.

MTM-AG commented 3 years ago

This is the exception that I get even today in the Unity editor, it also happens with your example

-Exception: HTTP/1.1 500 Internal Server Error ResponseError:{"error":"Command failed: /app/tools/bin/youtube-dl -f \"best\" --dump-json https://www.youtube.com/watch?v=sPyAQQklc1s\nERROR: Unable to download webpage: HTTP Error 429: Too Many Requests (caused by <HTTPError 429: 'Too Many Requests'>); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\n","stderr":"ERROR: Unable to download webpage: HTTP Error 429: Too Many Requests (caused by <HTTPError 429: 'Too Many Requests'>); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\n","stdout":""} System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () (at <9577ac7a62ef43179789031239ba8798>:0) YoutubePlayer.YoutubeDl+<GetVideoMetaDataAsync>d__51[T].MoveNext () (at Packages/com.ibicha.youtube-player/Runtime/YoutubeDl.cs:70) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () (at <9577ac7a62ef43179789031239ba8798>:0) YoutubePlayer.YoutubePlayer+<GetRawVideoUrlAsync>d__8.MoveNext () (at Packages/com.ibicha.youtube-player/Runtime/YoutubePlayer.cs:52) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () (at <9577ac7a62ef43179789031239ba8798>:0) YoutubePlayer.YoutubePlayer+d9.MoveNext () (at Packages/com.ibicha.youtube-player/Runtime/YoutubePlayer.cs:68) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.GetResult () (at <9577ac7a62ef43179789031239ba8798>:0) YoutubePlayer.YoutubePlayer+d10.MoveNext () (at Packages/com.ibicha.youtube-player/Runtime/YoutubePlayer.cs:91) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.GetResult () (at <9577ac7a62ef43179789031239ba8798>:0) YoutubePlayer.YoutubePlayer+d7.MoveNext () (at Packages/com.ibicha.youtube-player/Runtime/YoutubePlayer.cs:39) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b6_0 (System.Object state) (at <9577ac7a62ef43179789031239ba8798>:0) UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at :0) UnityEngine.UnitySynchronizationContext:ExecuteTasks()

iBicha commented 3 years ago

-Exception: HTTP/1.1 500 Internal Server Error ResponseError:{"error":"Command failed: /app/tools/bin/youtube-dl -f "best" --dump-json https://www.youtube.com/watch?v=sPyAQQklc1s\nERROR: Unable to download webpage: HTTP Error 429: Too Many Requests (caused by <HTTPError 429: 'Too Many Requests'>); please report this issue on https://yt-dl.org/bug .

This is an indicator that the server is sending too many requests. This is because you're using a free shared instance with all users of this package. This will happen if there's too many users at once. You can try to host the server yourself. See https://github.com/iBicha/UnityYoutubePlayer#how-do-i-host-my-own-youtube-dl-server

MTM-AG commented 3 years ago

Doing as you indicated, how many simultaneous users can it hold? Because in my case, I would have a very high audience

iBicha commented 3 years ago

Doing as you indicated, how many simultaneous users can it hold?

This is not very quantifiable, since Youtube itself changes this from time to time. There's few hints here https://github.com/ytdl-org/youtube-dl#http-error-429-too-many-requests-or-402-payment-required

IF you have a lot of users playing the same videos, it might be worth caching the response from youtube, bu that needs to be implemented in youtube-dl-server

iBicha commented 4 months ago

Closing, this is no longer relevant since version 3.0.0