Plex is an awesome system which aspirations to become more than just a place to play acquired content and to become the center of your media world. Which as it grows it’s got the capability to do.
That being said, the first thing Plex could do is get entwined with the behemoth which is YouTube
Something I find poorly presented on the Android and Roku YouTube apps are subscription videos so I started looking for a way of having plex present me with the latest videos from my YouTube subscriptions along with my Media, podcasts and music giving me one application across multiple platforms I could use to watch or listen to my content.
So I know I’m not the only person to ask this, there are a few threads and some broken git code when searching github, reddit, forums and the like for getting YouTube subscription content into Plex.
What I was looking for was a “sonarr/radarr” like web app which I could download specific youtube channel content or find a plex native method.
It seemed through my searching that the glue to get any of this working was an application called youtube-dl
Something found very quickly was having the most up to date version of youtube-dl is imperative. It appears Google updates a lot of code around YouTube access often, and this can break youtube-dl and anything which subsequently uses it.
After a few days of trials, I’ve got something working which let’s me watch the latest videos from my YouTube subscriptions in Plex.
I’m doing the following on Ubuntu 19.04, and the first thing to get is youtube-dl. I read a lot of places saying
snap install youtube-dl
Would get me the latest version of the app, for me this wasnt the case and I kept getting messages like
“This video is unavailable”
Solved this by getting the latest binary from the website
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
This got the latest version which fixed my problems and allowed me to get rid of errors.
YouTube-subscription-DL — presetup
The next part of the puzzle was downloading my subscriptions. I could use Youtube-dl to download, however I found some code on github called YouTube-subscription-DL
The instructions refer to a version 10.15.3 of nodejs and I got 10.15.2 from the Ubuntu repositories so I used the instructions at
This installed nodejs 11 and the appropriate npm version
Setup the Youtube API
The next point is to setup access to the Youtube API which the readme.MD on the git page documents really well, its free and my only observation is to read and follow the instructions, not assume. (I assumed)
- Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
- On the Add credentials to your project page, click the Cancel button.
- At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click the Save button.
- Select the Credentials tab, click the Create credentials button and select OAuth client ID.
- Select the application type Other, enter the name “YouTube Data API Quickstart”, and click the Create button.
- Click OK to dismiss the resulting dialog.
- Click the file_download (Download JSON) button to the right of the client ID.
- Move the downloaded file to the root path of where you cloned this repo, and rename it client_secret.json.
In reality, this is where for me the magic happens, I can direct the script where to download the files to (see NFS Mount later), i can define the metadata and thumbnail being downloaded and how youtube-dl works.
Out of the box however the unchanged config file
- Automatically output to the /Downloads folder on your PC
- put them into their own folders per channel
- Remember previous downloads and skip them if they are reuploaded
- Create .mkv files instead of the default (usually .webm)
mv ./youtube-dl.conf ~/.config/youtube-dl.conf
will move it to the correct folder on macos/linux,
Mount Central Storage
I have 3 plex servers (reasons) and as such, I’ve got my media on shared storage. To access this the most reliable protocol seems to be NFS, as I run the script from a control laptop, i mounted the NFS share as /shared/media on the laptop, and updated the config file above to reflect this, once done the youtube videos download to the shared media folder and then they are indexed automatically and available within Plex.
Run the script
npm install --production to install dependencies
Make the script executable
sudo chmod +x ./yt-subs.sh
Then run the script with
When you run the command the first time it will ask you to log in, you’ll be authorizing yourself with the project you just made, when you’re done just paste the code into the console.
The first time you run it, it will download your subscriptions from the past 24 hours.
Once the script is run once, the next time it is run it will only download new videos in your subscription feed.
Within Plex it’s then just a case of Adding a new Video source, using Other Videos, point to the shared folder and let plex index the content.
I’ve then setup a Cron job to run the script nightly..
4 5 * * * /run/the/script