ZeroQI / YouTube-Agent.bundle

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

Use locally downloaded posters rather than youtube link? #63

Closed garbled1 closed 3 years ago

garbled1 commented 3 years ago

I'd like to reduce my API and youtube calls as much as possible, as I have a really extensive library, and it causes problems when updating items..

Is it possible to use a local image for the thumb/poster? I wouldn't mind taking a crack at this myself, but I'm a bit unsure of how to do it...

picture                         = HTTP.Request(thumb).content

Like presumably I'd change that to just reference the file, but I'm not sure how.. just a filename there? or do I need a special function? do I also have to change this?

      metadata.posters[thumb] = Proxy.Media(picture, sort_order=1)

Thanks for your great work.

ZeroQI commented 3 years ago

Local poster load is already managed by the local media assets secondary agent It would be easy to test for a local poster and if not present, load the youtube one, true...

garbled1 commented 3 years ago

Yeah, I would really like this.. right now I have libraries with like 500 some odd videos in them, and when I add one new video, and it updates metadata, it rescans the entire thing, presumably calling youtube 500 times for the thumbnail. And then after, then the local asset runs, and finds my file, and sets the poster.

But I would like to avoid the 500 calls to youtube in the first place. In theory with info.json and .jpg/.png files for all of them, I can do everything internally and not have to hit them. (especially if they ever start to crack down on usage or something)

ZeroQI commented 3 years ago

Rescan only on folder change metadata should be only on new series

Now if you use grouping folders, well it rescan all every time so will update meta each time...

garbled1 commented 3 years ago

I keep having problems like this:

image

My file layout is a directory per channel.

If I click "refresh metadata" on the video there with the missing metadata (epsiode 644), the agent rescans metadata for every single video, not just the one.

Once a collection gets to this size, then I end up with the problem that no matter how many times I say "refresh metadata" it never fixes the video. Even though the log shows it happily processing the info.json file and finding the title, it just doesn't update plex or something? I also get nervous because then suddenly it's making 500+ calls to youtube for thumbnails, which seems obnoxious seeing as I have them right here on the drive. (which is why I want this feature :) )

My suspicion is that because I don't have info.json's for the first 300 videos in this one, then i'm killing the API token and then for some reason the rest all fail? dunno.. I'm lost..

ZeroQI commented 3 years ago

That is the likely situation. Analyzing the agent logs would allow to confirm

Code could be ammended to skip the screenshot of it is already present, with maybe an agent setting...

garbled1 commented 3 years ago

youtube.log com.plexapp.system.log

I don't understand for example, at the bottom:

2021-01-15 12:30:48,781 (7fe0a6ffd700) :  INFO (__init__:325) - Searching for "20190802 - So_you_want_an_Ultra_Low_Maintenance_reef_tank_This_is_everything_we_learned_ULM_Tank_Trials_Ep-24 [aYnxTH_Iitc].info.json". Searching in "/var/lib/plexmediaserver/alcyone/video/Misc/Youtube/Bulk_Reef_Supply [UCcJv2rQDivg8NwXIxydJ86A]".
2021-01-15 12:30:48,885 (7fe0a6ffd700) :  INFO (__init__:328) - Directory /var/lib/plexmediaserver/alcyone/video/Misc/Youtube/Bulk_Reef_Supply [UCcJv2rQDivg8NwXIxydJ86A] contains 2708 files
2021-01-15 12:30:48,886 (7fe0a6ffd700) :  INFO (__init__:333) - Found 1 matches.
.........
2021-01-15 12:30:49,277 (7fe0a6ffd700) :  INFO (__init__:354) - [ ] title:    "So you want an Ultra Low Maintenance reef tank? This is everything we learned! ULM Tank Trials Ep-24"

So it totally finds the info.json for this one, but then doesn't bother to update the metadata in plex. Or it does and plex ignores it?

image

ZeroQI commented 3 years ago

I see the title not updated... Let's see... "(init:354)" so Line 354: episode.title = filterInvalidXMLChars(Dict(video_details, 'title')); Log.Info('[ ] title: "{}"'.format(Dict(video_details, 'title')))

Let's update with the below and check the log again as the title was there before the call to filterInvalidXMLChars() episode.title = filterInvalidXMLChars(Dict(video_details, 'title')); Log.Info('[ ] title: "{}" => "{}"'.format(Dict(video_details, 'title'),episode.title))

If the title is correct in the after section "before => after" then Plex doesn't update your database, so it needs fixing if it is butchered in the after part, filterInvalidXMLChars() is bad...

garbled1 commented 3 years ago
2021-01-25 12:44:07,100 (7f250d7fa700) :  INFO (__init__:321) - populate_episode_metadata_from_info_json() - series_root_folder: /var/lib/plexmediaserver/alcyone/video/Misc/Youtube/Bulk_Reef_Supply [UCcJv2rQDivg8NwXIxydJ86A], filename: 20181206 - How_do_I_mix_Red_Sea_Reef_Foundation_A_B_and_C_equal_to_premixed_solutions_AskBRStv [eppNFni3630].mp4
2021-01-25 12:44:09,221 (7f250d7fa700) :  INFO (__init__:354) - [ ] title:    "How do I mix Red Sea Reef Foundation A, B, and C equal to premixed solutions? | #AskBRStv" => "How do I mix Red Sea Reef Foundation A, B, and C equal to premixed solutions? | #AskBRStv"

So it's not updating the db. What does that mean? Need to plex dance the collection out? Or is something else going on there?

I basically notice that when plex does its nightly scan, almost all the youtube series are checked, and it re-downloads the thumbnail, which kinda goes back to my original request.. :)

garbled1 commented 3 years ago

So if I keep having the issue where the youtube agent finds the data properly but plex doesn't update, where do I look next? Is it a bug in plex? Is there anything I can do to fix this? Sometimes the plex dance fixes this, sometimes not.. I'm stumped here.

ZeroQI commented 3 years ago

Clean bundles, optimise database, Plex Dance, repair corruption maybe

Seem to me like a Plex issue, maybe install plex on another machine with same library to test

garbled1 commented 3 years ago

So I mucked about, and basically once the library crosses around the 700-800 item mark, it just starts doing this.

So on that note, is there any way I can split the library in two by date? Right now I have ASS setup to split seasons by year, but is there some way I can create a "channel name" and "channel name - older years" ? The problem is even if I split the two directories, your plugin looks at the channel key and then plex combines them.

But back to the original point of this request, do you know what function I would call to use the local jpg thumb? I wouldn't mind taking a crack at the local images thing myself, but I'm not sure I grok the Plex API here..

ZeroQI commented 3 years ago

You could do a folder with playlist id and one with channel I'd Just name the local poster for the local media assets secondary agent

garbled1 commented 3 years ago

hrmm... playlist and then channel doesn't fix it.. It actually made it worse. Now none of the videos in the main channel have descriptions.

Also, every time I rescan metadata I blow my API usage out because it downloads the posters again...