ZeroQI / YouTube-Agent.bundle

Plex Metadata Agent for Movies and TV Series libraries
452 stars 43 forks source link

How are posters sourced and how is the primary poster determined? #66

Closed Jordan-Nelson closed 3 years ago

Jordan-Nelson commented 3 years ago

Forgive me if this is in the documentation somewhere. I looked but could not find it.

I am not sure if this is really an issue, or if the YouTube API just doesn't work the way that I would expect. I would expect that the poster for an episode would match the thumbnail for the episode on YouTube. This isn't the case about half of the time. Instead, I will see a thumbnail from a different episode used. When I edit the episode in Plex and view posters, the poster I would expect (the thumbnail from YouTube) is usually second in the list of a few posters.

Are the posters being pulled in simply the posters being provided by the YouTube API? If so, how is it determined which poster is used when multiple posters exist? Does the YouTube API specify a "primary" poster, or any sort of order?

Jordan-Nelson commented 3 years ago

I dug into the YouTube API as well as the source code.

From the YouTube API docs thumbnails has a default key

default – The default thumbnail image. The default thumbnail for a video – or a resource that refers to a video, such as a playlist item or search result – is 120px wide and 90px tall. The default thumbnail for a channel is 88px wide and 88px tall.

And it does look like YouTube-Agent is attempting to use that here:

https://github.com/ZeroQI/YouTube-Agent.bundle/blob/352bb68242a669a6520f1f95ea70952df9338800/Contents/Code/__init__.py#L223

From the YouTube API docs it seems like every video should have a default. Is that not the case? It seems like YouTube-Agent is only using the default if it exists, and is otherwise falling back on high/standard.

How are some (maybe all) videos getting multiple poster options? It seems like YouTube-Agent is only trying to pull 1 in. Am I missing something?

Jordan-Nelson commented 3 years ago

Here is the API response for one of the videos that doesn't have the poster that I would expect. The thumbnails all match the poster that I would expect. Somehow there are two other posters being pulled in.

Any idea where are those two other posters coming from?

{
  "kind": "youtube#videoListResponse",
  "etag": "l9-Wrxz6uv5b-XWAMN8cTslfcRc",
  "items": [
    {
      "kind": "youtube#video",
      "etag": "1NIngLGQB_bAczal-Hli6nOU51c",
      "id": "91J-BfRyeVE",
      "snippet": {
        "publishedAt": "2021-01-24T14:00:02Z",
        "channelId": "UCXgZyyqFpxgil9bBjyUXIJQ",
        "title": "It DISAPPEARED on its way to Canada - The van went MISSING",
        "description": "Last week, Marie was doing the happy dance because we got a confirmation that our van was on its way from the United States. This week, the van disappeared. It left Providence, in Rhode Island, but it hasn't arrived to Quebec City yet. Luckily, our friends at Vanlife MTL showed up!\n\nNEW VIDEO EVERY SUNDAY\nSUBSCRIBE: https://bit.ly/2TRtuTk\n\nVANLIFE MTL\nhttps://www.vanlifemtl.com/\n\nCONNECT WITH US\nINSTAGRAM: https://www.instagram.com/vanlife.sagas/\n\nVANLIFE SAGAS BOUTIQUE\nhttps://boutique.vanlifesagas.com\n\nCATCH UP ON OUR BUILDE SERIES\n01 - We Bought A New Van: http://bit.ly/boughtanewvan\n\nCATCH UP ON OTHER VIDEOS:\nWe Sold Our Van: https://bit.ly/3oQyGo4 \n10 Things We Wish We Knew: https://bit.ly/3siIBFl \n10 Things We’d Change On Our Van: https://bit.ly/3pVP1Iv\n\nWHAT’S IN OUR CAMERA BAG\nCanon 5d Markiii: https://amzn.to/2Xk3uSp \n14 mm lens: https://amzn.to/2Pju2Pa \n16-35 mm lens: https://amzn.to/3fraP9e \n50 mm lens: https://amzn.to/33iHziy \n24-105 mm lens: https://amzn.to/2Pd0Nhf \n100-400 mm lens: https://amzn.to/2EJWTKR \n\n_______\n\nWHO WE ARE? WHAT’S WITH OUR ACCENT?\n\nWe're Dom & Marie, a French Canadian couple who love Nutella toast and live in a van. Marie is the brain (Ph.D student) and Dom's the dreamer (Creative director).\n\nWe have spent the last 2 years travelling around North America in our Promaster 136'' named Vanessa. In 2020, after a 12-month trip that was cut short because of Covid, we decided to sell our van to start a new project: a bigger van.\n\nOur goal is to inspire others to start #vanlife and to help build their very own home on wheels.",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/91J-BfRyeVE/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/91J-BfRyeVE/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/91J-BfRyeVE/hqdefault.jpg",
            "width": 480,
            "height": 360
          },
          "standard": {
            "url": "https://i.ytimg.com/vi/91J-BfRyeVE/sddefault.jpg",
            "width": 640,
            "height": 480
          },
          "maxres": {
            "url": "https://i.ytimg.com/vi/91J-BfRyeVE/maxresdefault.jpg",
            "width": 1280,
            "height": 720
          }
        },
        "channelTitle": "Vanlife Sagas",
        "tags": [
          "vanlife",
          "campervan",
          "campervan hacks",
          "vanlife hacks",
          "campervan tips",
          "vanlife tips",
          "van tricks",
          "best accessories in van",
          "best accessories in campervan",
          "vanlife tips and tricks",
          "van hacks",
          "tiny house",
          "tiny living",
          "off grid",
          "off grid house",
          "vanlife sagas",
          "trent and allie",
          "exploring alternative",
          "alternative living",
          "winter camping",
          "winter van life",
          "heater",
          "van build",
          "DIY van conversion",
          "van conversion",
          "eamon and bec",
          "vanlife problems",
          "campervan conversion",
          "van life",
          "camper"
        ],
        "categoryId": "22",
        "liveBroadcastContent": "none",
        "defaultLanguage": "fr-CA",
        "localized": {
          "title": "It DISAPPEARED on its way to Canada - The van went MISSING",
          "description": "Last week, Marie was doing the happy dance because we got a confirmation that our van was on its way from the United States. This week, the van disappeared. It left Providence, in Rhode Island, but it hasn't arrived to Quebec City yet. Luckily, our friends at Vanlife MTL showed up!\n\nNEW VIDEO EVERY SUNDAY\nSUBSCRIBE: https://bit.ly/2TRtuTk\n\nVANLIFE MTL\nhttps://www.vanlifemtl.com/\n\nCONNECT WITH US\nINSTAGRAM: https://www.instagram.com/vanlife.sagas/\n\nVANLIFE SAGAS BOUTIQUE\nhttps://boutique.vanlifesagas.com\n\nCATCH UP ON OUR BUILDE SERIES\n01 - We Bought A New Van: http://bit.ly/boughtanewvan\n\nCATCH UP ON OTHER VIDEOS:\nWe Sold Our Van: https://bit.ly/3oQyGo4 \n10 Things We Wish We Knew: https://bit.ly/3siIBFl \n10 Things We’d Change On Our Van: https://bit.ly/3pVP1Iv\n\nWHAT’S IN OUR CAMERA BAG\nCanon 5d Markiii: https://amzn.to/2Xk3uSp \n14 mm lens: https://amzn.to/2Pju2Pa \n16-35 mm lens: https://amzn.to/3fraP9e \n50 mm lens: https://amzn.to/33iHziy \n24-105 mm lens: https://amzn.to/2Pd0Nhf \n100-400 mm lens: https://amzn.to/2EJWTKR \n\n_______\n\nWHO WE ARE? WHAT’S WITH OUR ACCENT?\n\nWe're Dom & Marie, a French Canadian couple who love Nutella toast and live in a van. Marie is the brain (Ph.D student) and Dom's the dreamer (Creative director).\n\nWe have spent the last 2 years travelling around North America in our Promaster 136'' named Vanessa. In 2020, after a 12-month trip that was cut short because of Covid, we decided to sell our van to start a new project: a bigger van.\n\nOur goal is to inspire others to start #vanlife and to help build their very own home on wheels."
        },
        "defaultAudioLanguage": "en-CA"
      },
      "contentDetails": {
        "duration": "PT15M51S",
        "dimension": "2d",
        "definition": "hd",
        "caption": "false",
        "licensedContent": true,
        "contentRating": {},
        "projection": "rectangular"
      },
      "statistics": {
        "viewCount": "8034",
        "likeCount": "780",
        "dislikeCount": "4",
        "favoriteCount": "0",
        "commentCount": "261"
      }
    }
  ],
  "pageInfo": {
    "totalResults": 1,
    "resultsPerPage": 1
  }
}
Jordan-Nelson commented 3 years ago

I deleted all the videos, chose the "empty trash" option in Plex (to try to clear any meta data that might be still there) and then re-downloaded the videos. I still see the same poster that I saw before. For the particular video I posted above, its still showing a poster from a different video that I don't have downloaded.

Am I doing something wrong or do I misunderstand something? Where are these other posters coming from?

ZeroQI commented 3 years ago

Plex calls it the episode thumbnail, metadata field is 'thumbs', a poster is vertical so that is very misleading to me...

I had issues with fields that should be there missing, hence the fallback...

if you use bad naming convention and the numbering given by the scanner changes, your Plex episode will get the preview from the original ep number metadata.

Please check the agent log output for your series, it will indicate the screenshot/preview used and you can check it is accurate I am only adding one screenshot per episode so i would recreate a new library for tests, ensuring to give the channel (or better playlist ID) with no subfolder

Jordan-Nelson commented 3 years ago

tl;dr - I am going to close this. I don't think the agent was pulling in the incorrect poster metadata. It was on my disk. Deleting it and starting fresh cleared everything up.

I managed to see in the log that it was finding those posters on disk. It seems like I had some old metadata that was never getting deleted. I had assumed that I had deleted the all the metadata from the library by deleting all the media, running a scan, and then choosing "empty trash", but I guess that is not the case.

After failing to find a good way to clear out all old metadata, I just deleted the whole folder of metadata for the lib after I deleted it lib itself. I deleted all the media, deleted the library in plex, found the metadata folder and deleted that, and then re-downloaded the media and recreated the lib. I am sure that it is not the "right" way to do it, but it does't seem like Plex has an easy to way to clear out old metadata and start over.

Once I cleared all old metadata from disk, the agent was able to bring in the new metadata which matched what I expected.

Thanks for your help.