iBicha / UnityYoutubePlayer

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

Exception: HTTP/1.1 503 Service Unavailable #39

Closed iBicha closed 2 years ago

iBicha commented 3 years ago

If you get an exception in the lines of:

Exception: HTTP/1.1 503 Service Unavailable
ResponseError:<!DOCTYPE html>
    <html>
      <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta charset="utf-8">
        <title>Application Error</title>
        <style media="screen">
...

Check https://unity-youtube-dl-server.herokuapp.com/v1/video?url=https://www.youtube.com/watch?v=1PuGuqpHQGo&schema=url if you see a Application error page, it likely means that the free server instance have exceeded its free usage limits for this month (when you use this package as is, you're sharing one free instance with all other developers using this package, and their users as well).

To work around this, host your own instance of the youtube-dl-server

ubergeekseven commented 3 years ago

I spun up a version on heroku but, how in the world do I stop unity from reverting to the dependency versions of the code? I can trick it on one script without it reverting by saving, it reverts, control+z and save. As long as I do not compile again, it works until the next change and reverts.

iBicha commented 3 years ago

I spun up a version on heroku but, how in the world do I stop unity from reverting to the dependency versions of the code? I can trick it on one script without it reverting by saving, it reverts, control+z and save. As long as I do not compile again, it works until the next change and reverts.

Can you share your setup, and what's being reverted?

ubergeekseven commented 3 years ago

I followed your setup information. I added to the manifest.json file the way you explained in the git readme. It seems that unity attempts to download and overwrite the changed files if there is a difference from the files coming in from the manifest. I modified the "youtubeplayer.cs" to add public static string youtubeUrl. I needed static to reference and replace the url from another script. Changing the server in the YoutubeDl.cs file to my own. I have to save all multiple times to trick unity until I build the game again. It will revert but, seems to only revert after the first change and save within a certain time. No idea what that time amount is. I can get it to work now but, I always have to do the trick if I make changes again after opening the scripts provided by you. I have not ever used the manifest before so, not sure what I am doing really. the dependencies coming in from the manifest did make it easy to use. Just cannot change much or use some variables in other scripts.

iBicha commented 3 years ago

Packages are immutable, you're not supposed to change them. It's expected that they get reverted. YoutubeDl as a field where you can set the url. In your game project, create a script in your Assets folder, that has this script:

using UnityEngine;
using YoutubePlayer;

class SetupCustomYoutubeDlServer
{
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    static void SetUrl()
    {
        YoutubeDl.ServerUrl = "YOUR URL HERE";
    }
}
ubergeekseven commented 3 years ago

Oh. I didn't know I could pass that through like that. I saw the custom server reference in the post about setting up your own. I couldn't find that entry anywhere. Now I know. Thank you for that. How would you pass a new url for the YouTube video? Is there a built in method?

ubergeekseven commented 3 years ago

Forget my last question. I get it now. I think I know how I can do it without having access to the url in that demo script.

PrathamGwari commented 3 years ago

Hey you said the free server has exceeded its free usage limit for THIS month. I hope everything will start working from tomorrow because today is the last day of the month, am I right?

iBicha commented 3 years ago

I added my credit card to the account, and it should have a 1000 dyno hours per month now. This issue should (or maybe will) go away. It is still recommended that you host your own instances and scale them as you need to avoid huge latency. The default server that comes with this repo is for demo purposes only.

ubergeekseven commented 3 years ago

@iBicha I have not figured out a way to set the YouTube url for YouTubeplayer.Cs from another script. I am using a text input box that you copy the url into. I then have a button that stores the url. However, if I attempt to access the youtubeUrl public setting from that other script, I get an error stating it must be set to static. If I change the variable to public static string, it reverts because it's immutable. I have a method of reverting without it changing back but, I know there is a better way to do this advertising to your code. I just do not know how I should attempt to pass the url to the script so that it plays.

My setup requires that a user inputs a url on the fly for a projection mapping system that allows videos from multiple sources to play. YouTube being one of those options.

I'm sure you have insight into how I can achieve this. I've stuck with my little hack to keep things moving along. Once compiled, it all works but, I'd prefer not to have to do that if possible.

iBicha commented 3 years ago

@iBicha I have not figured out a way to set the YouTube url for YouTubeplayer.Cs from another script. I am using a text input box that you copy the url into. I then have a button that stores the url. However, if I attempt to access the youtubeUrl public setting from that other script, I get an error stating it must be set to static. If I change the variable to public static string, it reverts because it's immutable. I have a method of reverting without it changing back but, I know there is a better way to do this advertising to your code. I just do not know how I should attempt to pass the url to the script so that it plays.

My setup requires that a user inputs a url on the fly for a projection mapping system that allows videos from multiple sources to play. YouTube being one of those options.

I'm sure you have insight into how I can achieve this. I've stuck with my little hack to keep things moving along. Once compiled, it all works but, I'd prefer not to have to do that if possible.

There's multiple examples on how to do that. The simplest way would be:

public class SimpleYoutubeVideo : MonoBehaviour
{
    void Start()
    {
        GetComponent<VideoPlayer>().PlayYoutubeVideoAsync("https://www.youtube.com/watch?v=1PuGuqpHQGo");
    }
}
iBicha commented 2 years ago

For the time being looks like putting my credit card info enabled the instance to be live during the whole month. I will close the issue for now, and reopen if there's still significant downtime.