Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The season is not set by year (as before) #30

Open
2 tasks done
Druidblack opened this issue Nov 24, 2024 · 11 comments
Open
2 tasks done

[Bug]: The season is not set by year (as before) #30

Druidblack opened this issue Nov 24, 2024 · 11 comments

Comments

@Druidblack
Copy link

I've read the documentation

Operating System

Linux (docker)

Your Bug Report

The season is exposed to bad weather (as before). After updating jf to 10.10.0 and the tube jf plugin to version 1.3.4. New videos are placed in the season 1 folder, and not as previously in the folder with the season by year of release.

111

Relevant Jellyfin log output

[2024-11-24 17:25:04.573 +03:00] [INF] Initiating automatic analysis task
[2024-11-24 17:25:04.749 +03:00] [INF] Running enqueue of items in library "Аниме"
[2024-11-24 17:25:05.474 +03:00] [INF] Running enqueue of items in library "Кино"
[2024-11-24 17:25:05.763 +03:00] [INF] Running enqueue of items in library "Recordings"
[2024-11-24 17:25:05.770 +03:00] [INF] Running enqueue of items in library "Передачи"
[2024-11-24 17:25:07.755 +03:00] [INF] Running enqueue of items in library "Аудиокниги"
[2024-11-24 17:25:07.755 +03:00] [INF] Running enqueue of items in library "Коллекции"
[2024-11-24 17:25:07.756 +03:00] [INF] Running enqueue of items in library "Комиксы (eng)"
[2024-11-24 17:25:07.756 +03:00] [INF] Running enqueue of items in library "Комиксы"
[2024-11-24 17:25:07.756 +03:00] [INF] Running enqueue of items in library "Музыка"
[2024-11-24 17:25:07.756 +03:00] [INF] Running enqueue of items in library "Youtube"
[2024-11-24 17:25:07.794 +03:00] [INF] [Mode: Introduction] Analyzing 4 files from "Ай, гитарист! [AI Guitarist]" season 1
[2024-11-24 17:25:10.462 +03:00] [INF] [Mode: Credits] Analyzing 4 files from "Ай, гитарист! [AI Guitarist]" season 1
[2024-11-24 17:25:17.844 +03:00] [INF] TubeArchivist->Jellyfin playback synchronization is currently disabled.
[2024-11-24 17:25:17.844 +03:00] [INF] "TAToJellyfinProgressSyncTask" Completed after 0 minute(s) and 0 seconds

Anything else?

It definitely started after upgrading to version 10.10.0, the plugin will update automatically to the latest version.

@ThisIsHetz
Copy link
Contributor

I'm confirming the same. I'd mentioned, over in the Discord, that I might open an issue after I first attempted a redeploy but I was delayed. I've since spun up a brand new instance of Jellyfin and the issue has persisted. I'm not well-versed enough in C# to pinpoint the breaking change but something seems to have been altered with Jellyfin itself so that it now prefers filenames when setting the season and episode numbers. It may be worth opening an issue on their GitHub, if someone hasn't already, since it looks like Jellyfin itself is ignoring the ParentIndexNumber out of all the provided metaadata. That is to say "Jellyfin seems broken, not the TA Plugin."

Anyway, if the VID/filename has anything along the lines of s#, e#, #x# or similar then Jellyfin will use that to assign Season/Episode numbers. For some reason VIDs mainly lead to Season 1 (JF probably defaults to 1 when it doesn't find a substring) but I've plenty of videos being placed in "Specials" (Season 0) and in other seasons. A few would also be out of order within their "Season" because a string like e12 in the filename would assign episode number 12 to the video.

For the moment I'm manually editing my Jellyfin's library.db in order to correct the metadata. I discourage anyone unwilling to risk breaking things further from doing the same but I'll detail the process below for the insistent.

Kludge - Not Advised

This will produce the TopParentId for the mounted library folders. We want to take note of the one associated with the TubeArchivist library. On my machine the folder is "/youtube" but it may be different for you if you've mounted it under another name.

SELECT DISTINCT TopParentId, Path FROM TypedBaseItems WHERE Type = "MediaBrowser.Controller.Entities.Folder";

That TopParentId can be used used in the query below to update the DB.

UPDATE TypedBaseItems
SET ParentIndexNumber = strftime("%Y", PremiereDate), SeasonName = "Season " || strftime("%Y", PremiereDate), IndexNumber = Null
WHERE TopParentId = "YOUR_TopParentID_HERE" and IsFolder = 0 and ProviderIds like "%TubeArchivist%";

Explanation:
All other metadata is being correctly sent, received and exists in the database. We can use strftime to get the year from the PremiereDate (when the video was posted to YouTube) of each entry. That's used to set the ParentIndexNumber (season number) and the SeasonName ("Season YYYY"). In the process we're also setting the IndexNumber (episode number) to Null.

We're targeting the youtube library with the TopParentId, specifying no folders (IsFolder = 0) and only entries where "TubeArchivist" appears in the ProviderIDs. I am fairly confident that should prevent the query from touching anything it shouldn't. That said - do so at your own risk.

There's probably a more concise way to write the query but it has been working for me while we await a fix. I threw the query into a Bash script, followed by a curl to the Jellyfin API to do a library refresh, which I run any time I've new videos in TA.

@hugalafutro
Copy link

If I were to delete a channel from jellyfin and then re-import it would put all videos in single Season 1?

Before it was Season 2023, Season 2024 etc which I liked, but now it's very disparate triggering my imagined ocd, so I'd rather have Season 1, Season 2 etc, than 2 different formats if that makes sense.

@tim-tx
Copy link

tim-tx commented Dec 26, 2024

I'm getting occasional inconsistencies even in the "new" season grouping, i.e. for one channel there is a "Season 3" with one episode, and a few episodes in Season 1 have non-zero episode numbers. These seem to just be random

@miltuss
Copy link

miltuss commented Dec 26, 2024

I also encounter the same problem. It's been over a month since the developers fixed this issue ☹️

We want a resolution to this very problematic problem. We need seasons by date

@ThisIsHetz
Copy link
Contributor

ThisIsHetz commented Dec 27, 2024

@hugalafutro

If I were to delete a channel from jellyfin and then re-import it would put all videos in single Season 1?

Based on what I have observed, I would say "no." "Season 1" seems to be what Jellyfin defaults to when it cannot determine otherwise. But if any Video IDs from the channel you're re-importing have a substring that Jellyfin determines to be Season/Episode numbers it will use them as such. A VID like BS6nGLmRrMI will end up in "Season 6" because of the S6 substring, as an example.

I have not tested the hypothesis but enabling embedding metadata in TubeArchivist, and setting the option to prefer embedded metadata inside Jellyfin for your TubeArchivist library, may be a solution. However, if that does work, it will only work on new downloads. I looked to the Discord for discussions on the matter and found that embedding of metadata only occurs upon download. At this time there is no built-in method of retroactively embedding metadata.

This means you'd need to come up with your own solution for retrieving metadata from your TubeArchivist instance to then provide to something like ffmpeg in order to embed it into your existing downloads. I'm not sure how feasible it would be to go about that programmatically.

EDIT: It does not appear that embedding metadata resolves anything. In retrospect that should have been obvious to me. "Season" simply doesn't exist among the metadata retrieved with yt-dlp and Jellyfin will not infer a season from the embedded "date" field. TubeArchivist itself would have to create and fill a "Season" field when it fills other metadata in order for it to work, but that probably shouldn't be the responsibility of the core application. "Season" isn't something that users who aren't using the plugin would likely ever need or want in their metadata.

@lamusmaser
Copy link

@ThisIsHetz
This means you'd need to come up with your own solution for retrieving metadata from your TubeArchivist instance to then provide to something like ffmpeg in order to embed it into your existing downloads. I'm not sure how feasible it would be to go about that programmatically.

This can be done, but it requires ffmpeg (or similar) to copy the file and make the embedded updates with the copy. I've got a similar script for fixing Radarr movies and it takes a good amount of time for each video. Capturing the metadata from TA/ES is actually the easier part.

@tim-tx
Copy link

tim-tx commented Dec 28, 2024

What about writing an nfo file for every video in the library, should be fast

@lamusmaser
Copy link

You can do that, but it will break TA filesystem scans.

@tim-tx
Copy link

tim-tx commented Dec 28, 2024

Maybe symlink videos to a separate dir then write nfo there, and that's your JF library

@miltuss
Copy link

miltuss commented Dec 28, 2024

I have the same problem too. I share the logs:

[00:04:17] [INF] [50] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Getting images for video: 🎥 CAMERA OBSCURA #2 / La fin (zTxNPp7PVBU)

[00:04:17] [INF] [50] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Thumb URI: /cache/videos/z/zTxNPp7PVBU.jpg

[00:04:17] [INF] [50] MediaBrowser.Providers.TV.SeriesMetadataService: Removing virtual season null in series Le Fossoyeur de Films

[00:04:17] [INF] [50] Emby.Server.Implementations.Library.LibraryManager: Removing item, Type: Season, Name: Saison inconnue, Path: , Id: 5a58a5ab-456a-a93f-efca-323ecffa5a32

[00:04:46] [INF] [44] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: TubeArchivist->Jellyfin playback synchronization is currently disabled.

[00:04:46] [INF] [44] Emby.Server.Implementations.ScheduledTasks.TaskManager: TAToJellyfinProgressSyncTask Completed after 0 minute(s) and 0 seconds

[00:05:48] [INF] [52] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: TubeArchivist->Jellyfin playback synchronization is currently disabled.

[00:05:48] [INF] [52] Emby.Server.Implementations.ScheduledTasks.TaskManager: TAToJellyfinProgressSyncTask Completed after 0 minute(s) and 0 seconds

[00:06:46] [INF] [43] Emby.Server.Implementations.IO.LibraryMonitor: Le Fossoyeur de Films (/data/Youtube/UCwbV8cTR4yBgFdfa_BXV2OA) will be refreshed.

[00:06:46] [INF] [52] MediaBrowser.Providers.TV.SeriesMetadataService: Creating Season Saison inconnue entry for Le Fossoyeur de Films

[00:06:46] [INF] [52] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: Starting /usr/lib/jellyfin-ffmpeg/ffprobe with args -analyzeduration 200M -probesize 1G -i file:"/data/Youtube/UCwbV8cTR4yBgFdfa_BXV2OA/_dTnfpmDAqg.mp4" -threads 0 -v warning -print_format json -show_streams -show_chapters -show_format

[00:06:46] [INF] [43] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: http://192.168.0.120:8040/api/video/_dTnfpmDAqg/: OK

[00:06:46] [INF] [43] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Getting metadata for video: Le plus beau film moche (_dTnfpmDAqg)

[00:06:46] [INF] [43] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Received metadata: 

{"channel":{"channel_banner_url":"/cache/channels/UCwbV8cTR4yBgFdfa_BXV2OA_banner.jpg","channel_description":"Bienvenue sur cette chaîne où l'on va explorer les mystères du cinéma, voyager et ne pas oublier de prendre un bon café au passage.\n\nPour vous procurer la revue ESTRANGE c'est par là !\nhttps://www.librairie-gallimard.com/livre/9782073021533-estrange-n-1-poussez-les-portes-du-monde-invisible-francois-theurel/\n\nLe visuel du bandeau est signé Lolikata (https://www.facebook.com/Lolikata-182798635070751/?fref=ts)","channel_id":"UCwbV8cTR4yBgFdfa_BXV2OA","channel_name":"Le Fossoyeur de Films","channel_tags":["dead watts fossoyeur cinéma cinema chronique francois theurel film genre analyse"],"channel_thumb_url":"/cache/channels/UCwbV8cTR4yBgFdfa_BXV2OA_thumb.jpg","channel_tvart_url":"/cache/channels/UCwbV8cTR4yBgFdfa_BXV2OA_tvart.jpg"},"tags":["beowulf","fossoyeur","film","cinema","theurel","analyse","critique","chronique","humour","zemeckis","performance","capture","3D","relief","mocap","viking","tolkien","gaiman","avary","adaptation"],"title":"Le plus beau film moche","description":"Beowulf, un film souvent considéré comme au mieux bizarre, au pire carrément moche. Mais y a-t-il plus derrière ? \n\nPour me suivre sur les réseaux : \nhttps://twitter.com/FrancoisTheurel \nhttps://www.instagram.com/francois_theurel/ \nhttps://www.facebook.com/LeFossoyeurDeFilms/ \n\nMerci aux complices de Pandora Création pour le tournage des facecams !\n\nEt pour aller plus loin sur Beowulf ! \n\nUn article passionnant sur les liens entre Beowulf et le 13ème Guerrier de John McTiernan : \nhttps://filmexposure.ch/2016/02/24/dessine-moi-un-heros/ \n\nUn tour des différentes adaptations :\nhttps://www.tor.com/2018/01/11/beowulf-on-the-big-screen-good-bad-and-even-worse/ \n\nUne analyse sur l'évolution de la figure de Beowulf dans la version 2007 : \nhttps://the-artifice.com/beowulf-transformation-into-an-unheroic-hero/ \n\nUn article bien énervé (mais intéressant) sur les libertés prises avec le po
nhttps://once-and-future-classroom.org/archives/?page_id=497 \n\nEt, croyez-le ou non, la page wiki contient des infos intéressantes sur la symbolique du film, un angle psychanalytique, et les rapports hommes-femmes : \nhttps://en.wikipedia.org/wiki/Beowulf_(2007_film)","published":"2020-06-17T00:00:00","vid_thumb_url":"/cache/videos/_/_dTnfpmDAqg.jpg","youtube_id":"_dTnfpmDAqg","player":{"duration":1861,"watched":false,"watched_date":0}}

[00:06:46] [INF] [43] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: http://192.168.0.120:8040/api/video/_dTnfpmDAqg/: OK

[00:06:46] [INF] [43] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Getting images for video: Le plus beau film moche (_dTnfpmDAqg)

[00:06:46] [INF] [43] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Thumb URI: /cache/videos/_/_dTnfpmDAqg.jpg

[00:06:46] [INF] [43] MediaBrowser.MediaEncoding.Encoder.MediaEncoder: Starting /usr/lib/jellyfin-ffmpeg/ffprobe with args -analyzeduration 200M -probesize 1G -i file:"/data/Youtube/UCwbV8cTR4yBgFdfa_BXV2OA/E4H4DMELpOA.mp4" -threads 0 -v warning -print_format json -show_streams -show_chapters -show_format

[00:06:46] [INF] [52] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: http://192.168.0.120:8040/api/video/E4H4DMELpOA/: OK

[00:06:46] [INF] [52] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Getting metadata for video: 🎥 CAMERA OBSCURA #1 / Quand tout bascule... (E4H4DMELpOA)

[00:06:46] [INF] [52] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Received metadata: 

{"channel":{"channel_banner_url":"/cache/channels/UCwbV8cTR4yBgFdfa_BXV2OA_banner.jpg","channel_description":"Bienvenue sur cette chaîne où l'on va explorer les mystères du cinéma, voyager et ne pas oublier de prendre un bon café au passage.\n\nPour vous procurer la revue ESTRANGE c'est par là !\nhttps://www.librairie-gallimard.com/livre/9782073021533-estrange-n-1-poussez-les-portes-du-monde-invisible-francois-theurel/\n\nLe visuel du bandeau est signé Lolikata (https://www.facebook.com/Lolikata-182798635070751/?fref=ts)","channel_id":"UCwbV8cTR4yBgFdfa_BXV2OA","channel_name":"Le Fossoyeur de Films","channel_tags":["dead watts fossoyeur cinéma cinema chronique francois theurel film genre analyse"],"channel_thumb_url":"/cache/channels/UCwbV8cTR4yBgFdfa_BXV2OA_thumb.jpg","channel_tvart_url":"/cache/channels/UCwbV8cTR4yBgFdfa_BXV2OA_tvart.jpg"},"tags":["theurel","fossoyeur","cinéma","camera","obscura","film","twin peaks","joker","critique","rêve","chronique","analyse","expérimental","melancholia","dark","laura palmer"],"title":"🎥 CAMERA OBSCURA #1 / Quand tout bascule...","description":"Ces moments hors du temps, magiques, on les a tous connus. Petite plongée dans leurs ténèbres et lumières...","published":"2020-04-03T00:00:00","vid_thumb_url":"/cache/videos/e/E4H4DMELpOA.jpg","youtube_id":"E4H4DMELpOA","player":{"duration":749,"watched":false,"watched_date":0}}

[00:06:46] [INF] [52] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: http://192.168.0.120:8040/api/video/E4H4DMELpOA/: OK

[00:06:46] [INF] [52] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Getting images for video: 🎥 CAMERA OBSCURA #1 / Quand tout bascule... (E4H4DMELpOA)

[00:06:46] [INF] [52] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: Thumb URI: /cache/videos/e/E4H4DMELpOA.jpg

[00:06:46] [INF] [52] MediaBrowser.Providers.TV.SeriesMetadataService: Removing virtual season null in series Le Fossoyeur de Films

[00:06:46] [INF] [52] Emby.Server.Implementations.Library.LibraryManager: Removing item, Type: Season, Name: Saison inconnue, Path: , Id: 5a58a5ab-456a-a93f-efca-323ecffa5a32

[00:06:50] [INF] [14] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: TubeArchivist->Jellyfin playback synchronization is currently disabled.

[00:06:50] [INF] [14] Emby.Server.Implementations.ScheduledTasks.TaskManager: TAToJellyfinProgressSyncTask Completed after 0 minute(s) and 0 seconds

[00:07:52] [INF] [46] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: TubeArchivist->Jellyfin playback synchronization is currently disabled.

[00:07:52] [INF] [46] Emby.Server.Implementations.ScheduledTasks.TaskManager: TAToJellyfinProgressSyncTask Completed after 0 minute(s) and 0 seconds

[00:08:54] [INF] [52] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: TubeArchivist->Jellyfin playback synchronization is currently disabled.

[00:08:54] [INF] [52] Emby.Server.Implementations.ScheduledTasks.TaskManager: TAToJellyfinProgressSyncTask Completed after 0 minute(s) and 0 seconds

[00:09:56] [INF] [3] Jellyfin.Plugin.TubeArchivistMetadata.Plugin: TubeArchivist->Jellyfin playback synchronization is currently disabled.

[00:09:56] [INF] [3] Emby.Server.Implementations.ScheduledTasks.TaskManager: TAToJellyfinProgressSyncTask Completed after 0 minute(s) and 0 seconds

2024-12-28_Sélection_001

@tim-tx
Copy link

tim-tx commented Dec 31, 2024

Based on some tests I believe this to be more of an issue with Jellyfin than the plugin.

I tried making a simple skeleton plugin that just sets IndexNumber (ie episode) to some integer (52) and nothing else. I set this plugin to be the only Episode Metadata provider for my library. In some cases this worked, in other cases the episode number was set to some other value. In my test library the filenames are uuids and apparently my test plugin was only successful in setting an Episode number (52) when the second field of the uuid filename both started and ended with a letter instead of a number. For example for the filename bf3b3590-be7f-11ef-a885-250694b0925f.mp4, this would get Episode number 52 because be7f starts and ends with a letter. In another case 085958e0-927a-11ef-859a-f5d8aac99cd2.mp4, Jellyfin would decide to ignore my plugin and set the episode number to 927 (the numeral in the second field of the filename). So apparently you don't even need the pattern "E##" to set the episode number (or maybe a filename that looks like a uuid just matches some other part of a regex) and Jellyfin will always prioritize the filename above whatever provider is specified.

I think this kind of behavior from Jellyfin is really a mistake. I'm guessing it's written like this due to the common practice of media collectors organizing everything by files and folders (probably before software like Jellyfin, or anything with a database, even existed) where naming was very important. There's no reason why you can't use file names to guess metadata, but it should not be the first priority, or at least it should be configurable.

Are there any possible workarounds?

  1. Embed metadata in files Not a solution according to @ThisIsHetz
  2. NFO files. I haven't tested this. Assuming you could do symlinking as I mentioned above so as not to break the TA library, I'm not sure this would work anyway, I'm pretty sure I have written NFOs with a Season number of 1 and no Episode number only to find they had been imported with some other value for Season and some random (filename-based I guess) number for Episode.
  3. Use the web API to overwrite imported data. I think this is how the old TA-JF plugin worked.
  4. Edit DB with a query as in the second comment on this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants