[PLUGIN] YouTube for Volumio

Hello,

This may come a bit late but I have made some changes to the YouTube plugin to allow specifying your own API credentials in the plugin settings.

The API key used by the official YouTube plugin is broken as of this writing, so you cannot access YouTube without first granting Volumio to your YouTube account. However, even after granting such access, sometimes the plugin fails with Quota Exceeded errors. This is because the quotas associated with the API credentials used by the official YouTube plugin have exceeded due to too many requests (the credentials are shared by all users of the plugin). It is therefore ideal to instruct the plugin to use your own API credentials, which would mean all quotas are reserved only for you (whether or not you grant access to your YouTube account). The attached plugin caters for this.

Before using the plugin, you need to create the credentials in your Google Developer Console as follows:

  1. Go to your Google Developer Console

  2. Create a Project (click ‘Select a Project’, then ‘New Project’).

  3. On the left menu, choose Library, then enter “YouTube Data API v3” in the search box. In the search results, click on the API and enable it.

  4. Then choose Credentials on the left menu. This is the place where you will create your API credentials.

  5. Click ‘Create Credentials’, choose ‘API Key’. An API Key will be created and you can optionally choose to restrict it to the YouTube Data API v3.

  6. Then click ‘Create Credentials’ again and choose ‘OAuth client ID’.

  7. You will be asked to configure the consent screen, so let’s do that. On the configuration page:

    • Set Application name (e.g. volumio-youtube-your-username). This name will be shown during the process where you grant Volumio access to your YouTube account
  • Click ‘Add scope’, then check the box for ‘YouTube Data API v3 …/auth/youtube.readonly’

  • Click Save.

  1. You will be brought back to the Create OAuth Client ID page. Choose ‘Other’ for Application type and provide a name (e.g. volumio-youtube-client). Click Create.
  2. Done! You have just created the API credentials needed for YouTube access. On the Credentials page, you will see the API key and Client ID. The Client Secret can be obtained by clicking the Edit icon corresponding to the Client ID.

To install the plugin:

  1. If you have the official YouTube plugin installed, you should uninstall it first, followed by a Volumio restart. To restart Volumio, you can enter the following in the console:
volumio@volumio:~$ volumio vrestart
  1. Download the attached zip file and place it in your Volumio home directory (/home/volumio)
  2. In Volumio console, enter the following:
volumio@volumio:~$ cd /home/volumio
volumio@volumio:~$ mkdir volumio_youtube_install
volumio@volumio:~$ cd volumio_youtube_install
volumio@volumio:~/volumio_youtube_install$ miniunzip ../<name of zip file downloaded>
volumio@volumio:~/volumio_youtube_install$ volumio plugin install
  1. You can delete the volumio_youtube_install directory after installation is complete
volumio@volumio:~/volumio_youtube_install$ cd ..
volumio@volumio:~$ rm -rf volumio_youtube_install

Using the API credentials with our plugin:

  1. Open Volumio web interface in your browser, go to Plugins->Installed Plugins and enable the YouTube plugin. Then click Settings.

  2. The default is to use the credentials provided by the official YouTube plugin. To change that:

    • Under API Settings, turn off the ‘Default’ switch.
  • In the corresponding fields that appear, enter the API key, Client ID and Client secret you created in your Google Developer Console.

  • Click Save.

  1. A dialog will appear reminding you to use new Code for granting Volumio access to your YouTube account.
  2. Note the change in the Code shown under Account Access. You may have to wait up to 10 seconds to see the change.
  3. Use the new Code for granting access to your YouTube account. The process is the same as with the official YouTube plugin. Note that you might get a “This app isn’t verified” warning in the process. This is normal since you haven’t gone through the Google verification step after creating the OAuth Client ID, but it is nonetheless safe to proceed by clicking ‘Advanced’ and 'Go to '.
  4. If you change the API settings again, you will need to grant / regrant access with new Code.

Please feel free to test it and point out any issues or suggestions. If this works well then maybe this can be merged into the official plugin… :unamused:
youtube-api-20191110.zip (5.7 MB)

1 Like