[REL] YouTube Metadata Agent

scanner-agent-dev

#1

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.{11})\]

This will find the YouTube id in names, like for example:
Person Of Interest Soundtrack - John Reese Themes (Compilation) [OR5EnqdnwK0].mp4

Download and source

Download: https://github.com/sander1/YouTube-Agent.bundle/archive/master.zip
Source: https://github.com/sander1/YouTube-Agent.bundle

Installation

See the How do I manually install a channel? support article.


#2

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.


#3

excellent! thank you!


#4

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).

Does anyone else have any thoughts?

Cheers


#5

This'd be great... 

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...


#6

This'd be great... 

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 :)


#7

This is fantastic. Thanks a lot Castle Keeper.

May I suggest the following;

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.


#8

This is fantastic. Thanks a lot Castle Keeper.

May I suggest the following;

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. 

Is anyone still working on this? Mines managed to just pull http://youtube.com/devicesupportfor the video titles. Nothing else. 


#9

Is anyone still working on this? Mines managed to just pull http://youtube.com/devicesupportfor the video titles. Nothing else. 

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. 


#10

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. 

Hopefully they are added :)


#11

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:

  1. Go to Craquehead's GitHub repository and download a zip of the latest code
  2. Shut down your Plex server
  3. Open your Plex plugins directory (you can right click on the Plex icon in the taskbar on windows) and extract the zip file there.
  4. Start your Plex server
  5. Get a YouTube API v3 key
    1. 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
    2. Click "APIs & auth" on the left
    3. Under "YouTube APIs", click "YouTube Data API", then "Enable API"
    4. Click on "Credentials" on the left under "APIS & auth"
    5. Under "Public API access" click Create new Key
    6. Select Server key and finish the creation process
    7. On the right you should see a section called "Key for server applications", where you should copy the long API key
  6. Open your Plex media manager and click on settings, then server, then agents
  7. Click on "YouTube" under the Movies agents tab
  8. Click the settings icon next to the YouTube agent line item and enter your API key in the second field
  9. To update any mis-tagged YouTube videos, open their details screen in Plex, select the more icon "..." and click "unmatch"

#12

The agent has been updated to work without the (v2) API.


#13

The agent has been updated to work without the (v2) API.

Thanks for the update :).


#14

Is this only for Movies and not TV Shows?

I'm downloading a Let's Play and want to use this agent to populate each episode's metadata.


#15

The source code says movies
https://github.com/Craquehead/YouTube-Agent.bundle/blob/master/Contents/Code/__init__.py


#16

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. :-?


#17

@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


#18

Ahh ok thanks, I completely missed the brackets in your original post! I've tweaked my youtube-dl settings to add them in.

Is there any way to get it to populate the summary with the Youtube video description?


#19

@onegear said:
Is there any way to get it to populate the summary with the Youtube video description?

It should already do this :) I'll check this later tonight, maybe something is broken.


#20

@sander1 said:

@onegear said:
Is there any way to get it to populate the summary with the Youtube video description?

It should already do this :) I'll check this later tonight, maybe something is broken.

Some things have changed a bit on YouTube's side. I'm working on an update!