alanxoc3 / radico8

A pico8 web radio.
Other
14 stars 13 forks source link

WIP: ADD YouTube Live health check #33

Closed ridgekuhn closed 1 year ago

ridgekuhn commented 1 year ago

FYI, I haven't tested this at all but I saw this was on your todo list in the YT chat and thought I might be able to help. I think it should work, but I wasn't sure about the contents of the youtube.env file. Could u add documentation for that or an example .env to the repo? I went w a variable named CHANNEL_NAME to check against the URL.

alanxoc3 commented 1 year ago

Thanks! That's looking good. 15 minutes is probably good.

Also, it's missing one piece. Restarting the "radico8-youtube" service won't fix the youtube stream unfortunately. You have to hit some API endpoint first that tells youtube you're starting a stream, then restarting the "radico8-youtube" service will fix the youtube stream.

Also, I could add a CHANNEL_NAME to that env file. The env file currently only has 1 line:

PASS=<youtube-stream-token>

I'm working on documentation rn...

alanxoc3 commented 1 year ago

Ok, I updated the main README with how you setup a server. It includes the content of those env files along with what you have in this PR (though it isn't merged yet).

I guess I'll stop procrastinating and try testing out that livestreaming api: https://developers.google.com/youtube/v3/live/getting-started

alanxoc3 commented 1 year ago

I'm merging this now so I can build on it.

ridgekuhn commented 1 year ago

My bad, that makes sense. Were you were doing that manually in the browser?

alanxoc3 commented 1 year ago

Yeah, I was clicking through the youtube studio to do that when the stream went down.

I actually just figured out an easier fix that doesn't require a timer. Here's the API parameter description: https://developers.google.com/youtube/v3/live/docs/liveBroadcasts#contentDetails.enableAutoStop

enableAutoStop defaults to true and you can't configure it through the UI, which kinda sucks. But you can set it to false through the API. False means the broadcast will never go down unless you manually stop it. If the server is having issues, the stream might show buffering for a while until radico8 is in a good state again.

I've been testing it for the past 30min-hour and the broadcast isn't going down. So that's great. I'll add some scripting/documentation in the repo then close that issue one issue.

alanxoc3 commented 1 year ago

Thanks for looking into it though. It gave me motivation to investigate too.

alanxoc3 commented 1 year ago

I'll probably end up removing the youtube healthcheck too. Systemd has been doing a good job at restarting radico8/radico8-youtube when it is in a bad state. And there isn't a need for it now since I found that API setting.

ridgekuhn commented 1 year ago

Oh that’s perfect. Weird that u can’t set that through the web UI. Now that you’re using the API, I wonder if it might be better to do just do the health check that way, but I read last night that doing so can use up a lot of API calls that count towards your account limit so that’s why I went w the web scraping route. Anyway, happy to help out even if it was just for motivation, lol!

On Feb 25, 2023, at 7:43 PM, Alan Morgan @.***> wrote:

 Thanks for looking into it though. It gave me motivation to investigate too.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

ridgekuhn commented 1 year ago

oh funny timing, u beat me to it about the API health check, lol

On Feb 25, 2023, at 7:50 PM, Alan Morgan @.***> wrote:

 I'll probably end up removing the youtube healthcheck too. Systemd has been doing a good job at restarting radico8/radico8-youtube when it is in a bad state. And there isn't a need for it now since I found that API setting.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.