This is a Metadata Agent for downloaded YouTube videos. It works by looking up metadata on YouTube using the YouTube video id. It is important to have this id in the filename, otherwise this agent can’t do the lookup. You can change the way the id is found in your filenames (through the Agent’s preferences). This value is a regular expression and requires 1 named group called id
The default value is: [(?P<id>.{11})]
This will find the YouTube id in names, like for example: Person Of Interest Soundtrack - John Reese Themes (Compilation) [OR5EnqdnwK0].mp4
Dude thank you so much. I was just asking my wife how I was going sort all these incredible YouTube shorts in Plex without having to do a bunch of manual editing. You have hopefully saved the day. I’ll be sure to give this a try once I get home.
Sorry to be one of those guys who revives an old(ish) thread...
This is fantastic for single YouTube videos, but I'd like to "upgrade it" so it can be used for entire playlists as well. In this situation it would obviously make more sense to have the videos within a TV Shows library rather than a Movies library.
AFAIK YouTube's API doesn't seem to provide a way of knowing whether a video belongs to a playlist according to it's ID. What might prove useful though is if the Playlist's ID is included in the video's parent folder name.
To clarify:
/"Playlist Name" [Playlist ID]
/"Video Name" [Video ID]
I'll look into tackling this one myself, although I've never written anything for Plex before or anything that uses YouTube's API (so I could be entirely wrong about getting information about a playlist from a video ID).
I'm actually trying to figure out a way to subscribe to YouTube channels and/or playlists in a rss podcast catcher, in a way that'll either download the associated metadata and store it locally for plex to read from, or have a plex agent grab it online based on the video id in the file name...
Not sure how this is going to be done yet... was about to post about it... just an idea i had the other day, because I spat it at the fact you need to re add all the videos you want in a queue when "casting" to a chrome cast... you can cast a playlist, but can't save the current queue as a playlist to re listen to later... figured if i could rss podcast a playlist of mine on youtube to collect them, the catcher will download, and plex can be my goto for music videos as well as movies/tv...
I'm actually trying to figure out a way to subscribe to YouTube channels and/or playlists in a rss podcast catcher, in a way that'll either download the associated metadata and store it locally for plex to read from, or have a plex agent grab it online based on the video id in the file name...
Not sure how this is going to be done yet... was about to post about it... just an idea i had the other day, because I spat it at the fact you need to re add all the videos you want in a queue when "casting" to a chrome cast... you can cast a playlist, but can't save the current queue as a playlist to re listen to later... figured if i could rss podcast a playlist of mine on youtube to collect them, the catcher will download, and plex can be my goto for music videos as well as movies/tv...
You can use youtube-dl and script it to automatically download new episode added to a playlist :)
1. Channel name and / or Playlist name can be used to group the videos in Library.
ex: TEDTalks | TED-ed
Currently, even if the videos are stored under specific folders Plex Library shows all videos in a flat view.
2. Category tag in youtube can be used as Genre in Plex.
Since the post is old I am hoping there is time and demand for developing this agent a little more.
Thanks in advance.
I'm having a play with this tonight and the Plex Extended Personal Scanner... it's a little better than the default scanners for picking up dated ordered items that might make youtube videos easier to organise.
If my thinking is correct I should be able to have the following.
Channel Name/ Year/ File name
**EDIT**
Wouldn't work because this is a movie scanner and the Plex Extended Personal Scanner is for TV Shows... No biggy.
The problem is that Youtube stopped supporting the v2 API that this agent relies on.
I've managed to get the agent working with the v3 API, but it requires an API key. (anyone can get one, but the one I'm using is tied to my personal google account)
Unless the original author re-writes the agent to scrape the page instead of using the API, not sure there's a way to get around the requirement for an API key tied to a person.
--Update--
I've submitted a pull request to the original author with my changes. It requires signing up for an API key and entering it through the agent preferences.
The problem is that Youtube stopped supporting the v2 API that this agent relies on.
I've managed to get the agent working with the v3 API, but it requires an API key. (anyone can get one, but the one I'm using is tied to my personal google account)
Unless the original author re-writes the agent to scrape the page instead of using the API, not sure there's a way to get around the requirement for an API key tied to a person.
--Update--
I've submitted a pull request to the original author with my changes. It requires signing up for an API key and entering it through the agent preferences.
The problem is that Youtube stopped supporting the v2 API that this agent relies on.
I've managed to get the agent working with the v3 API, but it requires an API key. (anyone can get one, but the one I'm using is tied to my personal google account)
Unless the original author re-writes the agent to scrape the page instead of using the API, not sure there's a way to get around the requirement for an API key tied to a person.
--Update--
I've submitted a pull request to the original author with my changes. It requires signing up for an API key and entering it through the agent preferences.
Your updates work perfectly Craquehead. Many, many thanks! :wub:
For anyone else looking to fix the YouTube agent using Craquehead's updates, here are the instructions:
Open your Plex plugins directory (you can right click on the Plex icon in the taskbar on windows) and extract the zip file there.
Start your Plex server
Get a YouTube API v3 key
Log into your Google account, go to the Developer's Console, and click "Create Project" and call it something like "Plex YouTube Agent" so it's easy to figure out what it is later
Click "APIs & auth" on the left
Under "YouTube APIs", click "YouTube Data API", then "Enable API"
Click on "Credentials" on the left under "APIS & auth"
Under "Public API access" click Create new Key
Select Server key and finish the creation process
On the right you should see a section called "Key for server applications", where you should copy the long API key
Open your Plex media manager and click on settings, then server, then agents
Click on "YouTube" under the Movies agents tab
Click the settings icon next to the YouTube agent line item and enter your API key in the second field
To update any mis-tagged YouTube videos, open their details screen in Plex, select the more icon "..." and click "unmatch"
Does this still work? I’ve installed the plugin and selected the Youtube agent in Plex but it doesn’t seem to add any metadata.
I set up a test movie library with the scanner set to plex movie scanner, the agent to Youtube and the default regular expression (because I’ve got no idea how they work).
Youtube-dl is set up to name downloads as [channel name] - [upload date] - [video name] - [video ID].[ext] so the id is always at the end of the filename before the extension. :-?
@onegear said:
Does this still work? I’ve installed the plugin and selected the Youtube agent in Plex but it doesn’t seem to add any metadata.
I set up a test movie library with the scanner set to plex movie scanner, the agent to Youtube and the default regular expression (because I’ve got no idea how they work).
Youtube-dl is set up to name downloads as [channel name] - [upload date] - [video name] - [video ID].[ext] so the id is always at the end of the filename before the extension. :-?
The default regular expression requires the video id to be in square brackets, it doesn’t matter where in the filename the id is. You have to change the regular expression if your filenames are different.
Example of a filename that works with the default regular expression: Person Of Interest Soundtrack - John Reese Themes (Compilation) [OR5EnqdnwK0].mp4