ZeroQI / YouTube-Agent.bundle

Plex Metadata Agent for Movies and TV Series libraries
468 stars 44 forks source link

Subtitle and Caption Support #151

Closed cxtal closed 1 month ago

cxtal commented 1 month ago

Hi! The plugin is great and I have been using it for a while without too much trouble having it constantly update my library when downloading with yt-dlp. The scanner part of the plugin seems to lack any support for subtitles or captions added as a separate .srt and/or .vtt file. The solution is to embed the subtitles into the clip by using the --embed-subs yt-dlp switch but it does not seem as clean of a solution as having the subtitle file separate. Also, some YouTube channels are entirely mute, with just the captions / subtitles explaining what is going on such that having subtitle and/or caption support seems imperative.

Would it be possible to add support for recognizing subtitles as per the official Plex documentation? Thanks for the good work!

ZeroQI commented 1 month ago

Plex manages the subtitles through local media assets agent.

The audio decoding is not part of the metadata agent or scanner, but plex itself...

cxtal commented 1 month ago

Hello again! The "local media assets" agent is well-enabled for the YouTube collection however the subtitles are not picked up at all, regardless how many times the collection has its metadata refreshed. By contrast, regular TV shows that are not downloaded from YouTube seem to recognize the subtitle file.

Here is an excerpt of some files downloaded off of YouTube:

20240905 - Primitive Technology - Primitive Technology Water Bellows smelt [UdjVnGoNvU4].en.vtt
20240905 - Primitive Technology - Primitive Technology Water Bellows smelt [UdjVnGoNvU4].mp4

and here is, say, the pilot of X-Files show:

The X-Files - S01E01 - Pilot.en.srt
The X-Files - S01E01 - Pilot.mp4

For some reason ti seems that only the subtitles for the X-Files show are loaded when opening up the video with Plex. Doing the same using Windows Media Player seems to work for both shows.

Is there perhaps a problem with how the plugin interacts with the "local media asset"? Or maybe it has to do with the naming convention that makes Plex not recognize the subtitle? The Plex documentation would indicate that the naming is correct. The temporary solution has been to add the subtitles to the movie file, but perhaps there is a way to get Plex to recognize the subtitle file.

ZeroQI commented 1 month ago

X-files with standard vrt file ok Youtube series with fucked up vtt format doesn't work...

Yeah about that... After a brief STFW, VTT format not fully supported in ffmpeg used by plex... Source: https://www.reddit.com/r/PleX/comments/mogubs/does_plex_support_vtt_subtitles/

Youtube agent is a metadata agent but subtitles are data, not metadata... Or more crudely like the british say, not my monkey, not my circus...

cxtal commented 1 month ago

Hello again and thanks for replying! from the Reddit conversation you cited, for what it's worth, it turns out that WebVTT is an unsupported format only when it is embedded as a subtitle codec S_TEXT/WEBVTT. The official Plex documentation would imply that VTT is a supported subtitle format. Just comparing SRT and VTT side-by-side the only obvious difference I can see is that VTT has a header whereas SRT does not.

Youtube agent is a metadata agent but subtitles are data, not metadata...

It does make sense for subtitles to be data instead of metadata, pedantically speaking! I mentioned "refresh metadata" because the Plex documentation page on subtitles advises to trigger a "refresh metadata" to make sure Plex recognizes embedded subtitles. So, I guess Plex consider subtitles to be metadata. There is little mention on whether one should just rescan the entire library or just "refresh metadata" in case the subtitles are not embedded but separate files from the documentation page.

I ran two tests:

Not saying you addon is at fault but these tests seem to indicate that at the very least the VTT / SRT distinction does not matter when it comes to separate subtitle files.

vtt_external

srt_external

Or more crudely like the british say, not my monkey, not my circus...

I like the one with "gentlemen, thaw your chicken".

ZeroQI commented 1 month ago

These are interesting tests as it compare similar formats.

Subs are data but if managed by local media assets agent,refresh meta would call meta agents and refresh them indeed, but if you look at the source, this agent do not handle sub's at all. .

The one test to rule out the agent is to change the library agent (or do another library pointing to same folder with a different agent) and see if vtt subs work If so the agent matters....

If that is the case, the only place that could have an impact are variables accept_from and contributes_to lines 616 and 621. If another agent works, adding the content of working agent there would fix