bitfocus/companion-module-youtube-live

YouTube API

rmdoprado opened this issue · 49 comments

Describe the feature
I would like to request a YouTube API integration. It will be great to be able to start/stop Live Streaming direct from Bitifocus Companion.

Is this platform dependent (windows, mac, ..)?
Not applicable

If documentation is required to implement, do you know where to find it?
If applicable, add screenshots, protocol description PDFs, etc to help the developers along
https://developers.google.com/youtube/v3/live/getting-started
https://developers.google.com/youtube/v3/live/docs/liveStreams

Usecases
Anybody who is using YouTube Live Streaming will be able to start/stop their live stream from a single location. For example, we deployed a ATEM, AJA HELO to allow us to live streaming our services, we automated everything to use a Elgato Stream Deck using Bitifocus, and the only task that we were not able to accomplish, it is the YouTube Live Streaming end event.

I might take a look into this, @Rodrigomarcondess. I use YouTube live streaming as well, and this is an issue for us too, because we have to have someone logged into the account just to click stop streaming.

@josephdadams This would be a huge help for us too. So annoying being able to automate everything with the streamdeck except starting and stopping Youtube Live.

I usually set the stream to auto start when I send data. But it won’t auto stop. :)

@josephdadams Ah I see. However I think that only works for Youtube Live without creating events. For instance, if we pre-create events instead of just streaming to the channel, I believe you have to start them in addition to stopping them.

We typically pre create our events (reusing the same stream key too) and there’s a setting for auto start. This may help: https://support.google.com/youtube/answer/6088828?hl=en

But the auto stop when we stop sending data is what gets us. I’d really like to separate the need for my volunteers to have to log into the YouTube account altogether just to stop the stream.

The same here, we use AJA HELO which has a pre-scheduled events, and start streaming automatically to our Live Stream page, and it stop sending data automatically, however we still need to login in YouTube to stop the event....

@josephdadams, did you have any chance to create a stop streaming YouTube API?

No, I’ve just been living my life.

An addition to this could be support for feedback (if possible) for esay monitoring of streaming quality, and maybe number of viewers.

Just and idea.

So I am working on development of YouTube module currently. So here is a little progress report. I have already implemented OAuth authorization for accessing YouTube data API using Googleapis library. Right now, I am focusing on building little frontend for stream creation. For frontend I decided to use onboard Electron.
Here is how the workflow with the module will look like:

  1. Creating access credentials in Google API console: (downloading json file required for access authentication for API) Don't worry it is not difficult. :-)
  2. Creating folder which will act as place where all authentication data will be stored. Contents of this folder will be: previosly mentioned json file and second json file with authentication token which will be created and stored by the module so the user will not have to authorize the module for access to YouTube account every time)
  3. Adding instance of the module to the Companion. There will be two configuration parameters:
    Path to previously mentioned folder with authentication data (text-box) and check-box. When this checked box will be enabled (1, on, ....) a page for creating YouTube stream will appear (this is currently in development)
  4. After applying all configuration, the module will create defined streams (if there are some) and load all streams from YouTube, whether they are running or waiting for start.
  5. Then, there will be 3 actions
  • start stream, in the options there will be drop-down menu with list of all non-running streams
  • stop stream, in the options there will be drop-down menu with list of running streams
  • add stream, will simply fire up previously mentioned frontend (UI) for stream creation

Management of streams on multiple YouTube channels should be possible, there is only new instance to be added with corresponding authentication folder

@melimat I am very interested in this too and eagerly await your progress. I’m happy to be a beta tester!

So, right now, I would say, the module for youtube is pretty usable. It can start/stop/toggle planned broadcasts on YouTube and also provides feedback for broadcast lifecycle state and video livestream health.
link to repo: https://github.com/bitfocus/companion-module-youtube-live
I need to mention, I do not work alone, after I was provided with this repository, my friend @JakubVanek joined the development. Also guys from bitfocus are really helpful.

Great job guys! Thank you for contributing!

Most excellent! I'll test as soon as I can. Thanks so much for working on this!

So, I apologize for the noob question, but on a Mac, how can I install this module? I read the companion module development guide (which is quite nice, by the way) but it doesn't explain how to install someone else's module, specifically on a Mac. . . Thanks in advance!

Hi @whizkidTRW!

I have quickly looked into the Companion 2.0 package for Mac and I don't know how to add it there. However, it should be possible to git-clone the main Companion repository, then clone this module to the lib/module subdirectory and then follow DEVELOPER.md.

git clone https://github.com/bitfocus/companion.git                     companion
git clone https://github.com/bitfocus/companion-module-youtube-live.git companion/lib/module/youtube-live
# < developer.md >

Best regards,

Jakub

Hi all,
Development update:
youtube-live module was added into Companion by core developers. Now it is available in experimental releases: https://bitfocus.io/companion/download/builds/

Hi all,
You have probably noticed, that youtube-live module is available in the newest version of Companion (v 2.1) in its fully working state

So I’m using this now in production and it works great. Is there a way to add a preset that toggles an event based on the stream key specified? Or just whatever the current live event is? That way we don’t have to reconfigure companion each week just to control a new event.

Is there a way to add a preset that toggles an event based on the stream key specified?

I think this is implementable, but there are some caveats. Currently buttons are bound to specific YT events/broadcasts. The good thing about this is that each event has exactly one stream bound to it and YouTube makes it easy to obtain the ID of that stream. Finding the event ID corresponding to a stream ID is more difficult: one stream key can be bound to multiple events & multiple YT events have to be checked to see if they are bound to the given stream ID.

Or just whatever the current live event is?

This would allow us to preserve the current event->stream mapping, but we would still have to choose one event from zero to N live events. Picking the newest or the oldest one might be sufficient though.

While it does feel a bit hackish to me, I would instead propose adding a "default event" field to the module configuration. Then a special event named "default" could be selected for each button/feedback/.... This would keep the configuration deterministic and it would simplify this type of reconfiguration.

What we need is the next live event of the channel loaded in a toggle button in Companion when we start Companion (or refresh the youtube info). That way we do not have to change the button every week. It is almost the same question of whizkidTRW, but related to the channel.

Amazing work! Tested out the module and no apparent bugs yet:)

Would be amazing to have that feature mentioned earlier that would allow the latest stream created to be selected. We have probably a set of 5-6 buttons (such as refresh, start stream, end stream, stream status, etc.) that have to be updated individually every time we create a new stream (having an option to select the newest event would be PERFECT).

Please do let us know if there is any way we could help ::)

I agree, this is a fantastic add on for automating youtube control.

I managed to set it up at home without real hassle using the provided guide and deployed it on streaming site just by importing the companion configuration.

After testing, I second that I would like to have a few streams that could be configured in the button setup to be stream 1, 2, 3 etc. and using corresponding variables for button text in such a way that the Stream Deck configuration can be "statically defined" and still be able to show and test/start/stop and get feedback status on the streams configured in the Youtube channel.

In our configuration, a Church, we typically have one active stream pending for each Sunday and it would be really nice not having to change all the parameters for the youtube buttons just to get the new stream to show up.

I agree, this is a fantastic add on for automating youtube control.

I managed to set it up at home without real hassle using the provided guide and deployed it on streaming site just by importing the companion configuration.

After testing, I second that I would like to have a few streams that could be configured in the button setup to be stream 1, 2, 3 etc. and using corresponding variables for button text in such a way that the Stream Deck configuration can be "statically defined" and still be able to show and test/start/stop and get feedback status on the streams configured in the Youtube channel.

In our configuration, a Church, we typically have one active stream pending for each Sunday and it would be really nice not having to change all the parameters for the youtube buttons just to get the new stream to show up.

I am in the exact same boat. I just setup streaming for my church and I am looking for ways to make things easier for our volunteers so I do not need to be running the live stream every Sunday. I am almost where I want to be and this kind of update to automatically have it work with the next live stream would be great.

I know this has been dormant for a while, don't know if anyone is still interested.

I notice that, if I set "How many broadcasts to fetch from YouTube" to 1, and periodically execute a "YouTube: Reload everything from YouTube" the the volunteers only need to click on the various "Broadcast" drop-downs and the right answer is the only one available to them. Still more work - and more access to the configuration pages - than I'd like for them, but it's bearable.

I like to have a button that shows YouTube's reported statuses with the variable text, $(YouTube:health:aBcDeFghI)\n$(YouTube:lifecycle:aBcDeFghI) but copying these from the variable list and putting them on the button is really a bridge too far for the volunteers.

I'd love if someone could make these work with index numbers instead of the literal names of the streams

Hi,
I have a first alpha version for testing: https://wetransfer.com/downloads/a86a62aa2e3ef5473c3e6c09d5c8789e20210806135531/adc1d441547cdbd47b824824ce9f3abb20210806135604/d2a05b?utm_campaign=WT_email_tracking&utm_content=general&utm_medium=download_button&utm_source=notify_recipient_email
In the presets you will find an extra category "Upcoming". This has a latch button which will display the upcoming broadcast. First press will start the broadcast, second press will stop the broadcast. The feedback is standard like other feedbacks. If you add a button to refresh the youtube info, the next upcoming broadcast will be loaded. Can you please run some tests? It is still alpha!!

My apologies @fbosman, but I won’t be downloading an .exe file to test this out. What exactly is that file anyways? Seems fishy to me. Too much of a risk.

Why not create a fork of the project?

Thanks.

@fbosman Any update on the new feature and/or Pull Request?

It worked during my first test but unfortunately I just get a "instance(YT): YT Broadcast query failed: TypeError: Cannot read property 'id' of undefined" error ever since my first reboot. Any ideas?

@fbosman, do you have the possibility to check in your update to your forked repo?

Hi,
Due to holiday and illness I was not able to setup a forked repo. I made the changes on the JavaScript library and am busy to set them up for the typescript sources. This will take me this week or so as I have to do this in my free time.
I'm sorry the development cannot be faster.

No problem @fbosman, thanks for breaking the silence. 😀

Hope you are well now, take care!

I really hope that this can be updated to work in the following fashion:

  • Add variables for CurrentScheduled stream, which look at the list of scheduled livestream events and by their scheduled time picks the one which is either ongoing now, or closest to now in the future.
  • (much lower priority) Add support for various languages in the output strings or status strings.

This will allow us to configure one button, once and for all, that will always automatically be tied to the nearest future or current show. The language support will make this more useful globally.

I am a developer and although I have zero experience with this particular environment and programming language, I can read the code and try to figure it out on my own. But I would appreciate some help or pointers. I will probably fork the code soon and take a stab at it.

@scientastic - Support for the variables for the next scheduled stream is now merged in #64 #66
I don't think an official release has been made since it merged, but if you build source or grab one of the nightly's it's in there. Been using this functionality for a few weeks and it's a game changer!
Screen Shot 2022-01-17 at 12 24 12 PM
Screen Shot 2022-01-17 at 12 24 53 PM
Screen Shot 2022-01-17 at 12 25 13 PM

Thanks! I actually did fork the code and started looking at it and saw the "unfinished_" variables. I suspected it was in progress but hadn't had a chance to get further.

Is there a good quick guide to how to build this module and then start using it? I have the 'companion' project cloned and am going through the developer guide, but maybe you could help me cut to the chase?

Thanks again!

Easiest way to run a recent dev build is to grab one of the latest versions from https://bitfocus.io/user/downloads .

Once you sign in, click the beta builds link here:
Screen Shot 2022-01-17 at 10 18 48 PM

That page has the most recent test builds that should have the code. If you want to build it yourself you can get started here: https://github.com/bitfocus/companion/wiki/Module-Development. It will depend on your platform and specific setup on how to best do that.

Thanks again! I will probably work with the beta builds and not try to build myself at the moment. However, I have been all over the Wiki and don't yet see any instructions for 1. compiling/building a module and 2. how to load it into Companion once it is built. I'm not a Node developer so maybe it is something that seems obvious to everyone on the project but is not obvious to me? Anyways, a brief write-up on that would be very welcome :)

@scientastic currently there isn't a way build individual modules then "load" them to Companion. The software has to be built as a single package. The beta builds are the way to go.

I see, thanks. The fact that the modules have their own separate github repos was confusing me. I now see they also exist in 'companion/node_modules' as well.

Yeah, they used to live in companion/lib/module/ as git submodules but that became a scaling problem. The separate repos are for permissions control since there are a ton of developers and the load in the Companion repo would be unmanageable in terms of pull requests and issues for the individual modules. Keeps things tidy this way. And eventually we're working toward what you've asked for documentation on, but that day has not yet arrived.

Am I supposed to have to frequently reauthenticate my authorization token? I just started using this module on a weekly basis for my church's live stream and every week I have to go in and reauthenticate for some reason. I don't see an option anywhere obvious in the google services API for a "keep alive" or something similar. Am I missing something, or is this just how it works?

Thanks for all of your efforts! Aside from the frequent login issue I'm experiencing, this does the job well!

This is related to #72.