Schaka / janitorr

Cleans your Radarr, Sonarr, Jellyseerr and Jellyfin before you run out of space
GNU General Public License v3.0
263 stars 5 forks source link

Jellystat is looking only for movies history, not for shows #50

Closed Eldarock closed 1 month ago

Eldarock commented 1 month ago

Hello ! First : Thanks for this software, really useful !

Next :

I tried to configure the application, and everything was looking good, except one thing : One show was set to be deleted, but i knew that i watch at this show some days ago, so i dig a bit.

Jellyfin, Jellyseer, Jellystat all activated and setup correctly. Debug mode showed me that janitor access to Jellystat and update history correctly but... only for movies. Shows are fine, but no trace of jellystat in logs, only sonarr/Jellyseer, so some recently watched show are marked as to be deleted.

Is that a bug, or is that a hidden settings for that somewhere that i missed ?

Schaka commented 1 month ago

Are you sure you watched THAT season? There's currently a feature only available on the develop branch that makes it possible to have a single episode reset the timer for the entire show (in JellyStat support).

By default, it will delete it season by season and you need to have seen an episode of the season you're looking at.

Otherwise as per usual, attach a log file and your config (redact sensible info).

Eldarock commented 1 month ago

Yup, sure.

Looks at this jellystat history :

HPI was watched, season 1 and 2 like 3 weeks ago. image

But Janitor deleted this seasons. Maybe it's because of the language of the show ? Jellystat shows me the title in french (HPI), and sonarr shows me the english title (HIP). Obviously i didn't save the logs because i'm an idiot, but i can try to replicate the error if you want to.

Media deletion config :

media-deletion: enabled: true movie-expiration: 5: 60d 20: 120d season-expiration: 5: 90d 20: 180d

Schaka commented 1 month ago

If you can, please get me a log file with trace logging. I use IMDB, TMDB and TVDB IDs to match media in Jellystat with Sonarr, depending on what's available.

So if it can find a match, it should say so. It's going to log any watch history it finds for a matched TV show/season. It should give you enough insight to see if it generally works or not.

Schaka commented 1 month ago

I just re-testet this on my server.

Found a show that was meant to be deleted (but couldn't), watch episode 1 of Season 2:

2024-08-08T08:54:30.361Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.sonarr.SonarrRestService       : Can't delete season [still seeding - file exists] (/data/torrents/tv/The Rising of the Shield Hero S02 1080p CR WEB-DL AAC2.0 Dual Audio H.264-OldT/The Rising of the Shield Hero Season 2 S02E13 1080p CR WEB-DL AAC2.0 Dual Audio H.264-OldT.mkv), id: 28, imdb: tt9529546
2024-08-08T08:54:30.361Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.sonarr.SonarrRestService       : Can't delete season [still seeding - file exists] (/data/torrents/tv/Nathan.for.You.S03.1080p.AMZN.WEB-DL.DD+2.0.x264-SiGMA/Nathan.for.You.S03E08.The.Hero.1080p.AMZN.WEB-DL.DD+2.0.x264-SiGMA.mkv), id: 128, imdb: tt2297757
2024-08-08T08:54:30.361Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.sonarr.SonarrRestService       : Can't delete season [still seeding - file exists] (/data/torrents/tv/Mr.and.Mrs.Smith.2024.S01.1080p.AMZN.WEB-DL.DDP5.1.H.264-FLUX/Mr.and.Mrs.Smith.2024.S01E08.A.Breakup.1080p.AMZN.WEB-DL.DDP5.1.H.264-FLUX.mkv), id: 130, imdb: tt14044212
2024-08-08T08:54:30.361Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.sonarr.SonarrRestService       : Can't delete season [still seeding - file exists] (/data/torrents/tv/Station.19.S01.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb/Station.19.S01E10.Not.Your.Hero.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv), id: 149, imdb: tt7053188
2024-08-08T08:54:30.361Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.sonarr.SonarrRestService       : Can't delete season [still seeding - file exists] (/data/torrents/tv/Invincible.2021.S02.1080p.AMZN.WEB-DL.DDP5.1.H.264-FLUX/Invincible.2021.S02E08.I.THOUGHT.YOU.WERE.STRONGER.1080p.AMZN.WEB-DL.DDP5.1.H.264-FLUX.mkv), id: 152, imdb: tt6741278
2024-08-08T08:55:47.433Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.radarr.RadarrRestService       : Can't delete movie [still seeding - file exists] (/data/torrents/movies/Asteroid.City.2023.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.HEVC-XEBEC.mkv), id: 3, imdb: tt14230388
2024-08-08T08:55:47.433Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.radarr.RadarrRestService       : Can't delete movie [still seeding - file exists] (/data/torrents/movies/The.Matrix.1999.2160p.UHD.BluRay.TrueHD.7.1.DV.x265-W4NK3R.mkv), id: 99, imdb: tt0133093
2024-08-08T08:55:47.652Z  INFO 1 --- [   scheduling-1] c.g.s.j.cleanup.TagBasedCleanupSchedule  : Tag based cleanup disabled, do nothing
2024-08-08T08:55:47.652Z  INFO 1 --- [   scheduling-1] c.g.s.j.c.WeeklyEpisodeCleanupSchedule   : Episode based cleanup disabled, do nothing

After watching that episode for longer than 60 seconds:

2024-08-08T09:06:52.614Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.sonarr.SonarrRestService       : Can't delete season [still seeding - file exists] (/data/torrents/tv/Nathan.for.You.S03.1080p.AMZN.WEB-DL.DD+2.0.x264-SiGMA/Nathan.for.You.S03E08.The.Hero.1080p.AMZN.WEB-DL.DD+2.0.x264-SiGMA.mkv), id: 128, imdb: tt2297757
2024-08-08T09:06:52.614Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.sonarr.SonarrRestService       : Can't delete season [still seeding - file exists] (/data/torrents/tv/Mr.and.Mrs.Smith.2024.S01.1080p.AMZN.WEB-DL.DDP5.1.H.264-FLUX/Mr.and.Mrs.Smith.2024.S01E08.A.Breakup.1080p.AMZN.WEB-DL.DDP5.1.H.264-FLUX.mkv), id: 130, imdb: tt14044212
2024-08-08T09:06:52.614Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.sonarr.SonarrRestService       : Can't delete season [still seeding - file exists] (/data/torrents/tv/Station.19.S01.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb/Station.19.S01E10.Not.Your.Hero.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv), id: 149, imdb: tt7053188
2024-08-08T09:06:52.614Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.sonarr.SonarrRestService       : Can't delete season [still seeding - file exists] (/data/torrents/tv/Invincible.2021.S02.1080p.AMZN.WEB-DL.DDP5.1.H.264-FLUX/Invincible.2021.S02E08.I.THOUGHT.YOU.WERE.STRONGER.1080p.AMZN.WEB-DL.DDP5.1.H.264-FLUX.mkv), id: 152, imdb: tt6741278
2024-08-08T09:07:18.920Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.radarr.RadarrRestService       : Can't delete movie [still seeding - file exists] (/data/torrents/movies/Asteroid.City.2023.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.HEVC-XEBEC.mkv), id: 3, imdb: tt14230388
2024-08-08T09:07:18.920Z  INFO 1 --- [   scheduling-1] c.g.s.j.s.radarr.RadarrRestService       : Can't delete movie [still seeding - file exists] (/data/torrents/movies/The.Matrix.1999.2160p.UHD.BluRay.TrueHD.7.1.DV.x265-W4NK3R.mkv), id: 99, imdb: tt0133093
2024-08-08T09:07:19.161Z  INFO 1 --- [   scheduling-1] c.g.s.j.cleanup.TagBasedCleanupSchedule  : Tag based cleanup disabled, do nothing
2024-08-08T09:07:19.161Z  INFO 1 --- [   scheduling-1] c.g.s.j.c.WeeklyEpisodeCleanupSchedule   : Episode based cleanup disabled, do nothing
Eldarock commented 1 month ago

In your case, it can't be deleted just because it's seeding nope ? No trace of jellystat history here. Meanwhile, i did some others tests, and if i activate the "whole-tv-show": true, it looks like jellystat history is getting checked.

Schaka commented 1 month ago

You misunderstand the logs.

Look at the very first line. I only kept the rest in for clarity, since these aren't DEBUG or TRACE logs. After watching 2 minutes of the first episode of season 2 of the first show mentioned in the above, it doesn't appear anymore.

This is because Janitorr decided it is now out of the window that it would need to be in to expire.

Eldarock commented 1 month ago

Another example that i tried this morning (on 1.5.0) : image Shows season 6 last watched less than 3 month ago

config setted :

season-expiration: 20: 180d # 6 months

leaving soon set to 14d

Logs :

2024-08-08T10:30:37.046-04:00 INFO 1 --- [ main] c.g.s.janitorr.JanitorrApplicationKt : Started JanitorrApplicationKt in 0.247 seconds (process running for 0.272) 2024-08-08T10:30:54.199-04:00 TRACE 1 --- [ scheduling-1] c.g.s.j.mediaserver.MediaServerService : Season folder - Source: /mnt/user/shows/The Good Doctor (2017)/Season 06, Target: /mnt/user/leaving-soon/tv/media/The Good Doctor (2017)/Season 06 2024-08-08T10:30:54.199-04:00 TRACE 1 --- [ scheduling-1] c.g.s.j.mediaserver.MediaServerService : Creating season folder /mnt/user/leaving-soon/tv/media/The Good Doctor (2017)/Season 06 2024-08-08T10:30:54.200-04:00 DEBUG 1 --- [ scheduling-1] c.g.s.j.mediaserver.MediaServerService : Creating episode link from /mnt/user/shows/The Good Doctor (2017)/Season 06/The Good Doctor (2017) - S06E10 - Quiet and Loud.mkv to /mnt/user/leaving-soon/tv/media/The Good Doctor (2017)/Season 06/The Good Doctor (2017) - S06E10 - Quiet and Loud.mkv 2024-08-08T10:30:54.236-04:00 INFO 1 --- [ scheduling-1] c.g.s.j.s.sonarr.SonarrRestService : Dry run - not deleting any TV shows without files or monitoring 2024-08-08T10:30:54.285-04:00 DEBUG 1 --- [ scheduling-1] c.g.s.j.jellystat.JellystatRestService : Updating history - user Thomas watched Le Monde de Nemo at 2024-06-29T19:44:36.270Z 2024-08-08T10:30:55.194-04:00 INFO 1 --- [ scheduling-1] c.g.s.j.cleanup.TagBasedCleanupSchedule : Tag based cleanup disabled, do nothing 2024-08-08T10:30:55.194-04:00 INFO 1 --- [ scheduling-1] c.g.s.j.c.WeeklyEpisodeCleanupSchedule : Episode based cleanup disabled, do nothing

I don't paste all the jellystat updating history, but there are all related to movies, not shows. Maybe i don't understand something ?

Schaka commented 1 month ago

Was that show (in the example) watcher longer than 60s econds? From your logs and your config, I can't tell much. It's a bit limited.

In Jellyfin, when you check the meta data for the good doctor (season 06) does it contain any IMDB, TMDB, etc?

Jellystat uses one simple function. It gets the id of the show/season from Jellyfin first and then searches its own watch history.

If it finds season 6 in your example, it would log that it found it. It's possible individual seasons do not have the correct meta data or ID in Jellyfin. If you active the whole-show flg, it would not go season by season.

This is more likely than not missing data on your end somehow.

Eldarock commented 1 month ago

Episode was watched entirely

Metadata in jellyfin for this episode : imdb : tt23727902 tvdbId : 9472624

Metadata for this season in jellyfin : TheTVDB Season Id 2006665

Oh boy, maybe that's because i'm using theTVDB ?

Edit : Yup, looks like it's because season don't have an imdb ID. If i set the whole-tv-show: true, it check the ID of the all show, who have an imdb ID, and jellystat is working for the show.

So i guess, it's on the jellyfin side there is a problem, not setting id in the season metadata.

Sorry for taking your time :)

Schaka commented 1 month ago

So the matching works as follows:

For me, this works perfectly. I just ran everything again with TRACE logging on my server and can't see any problems.

If your debugging logging fails to show any watch history, it's because it couldn't match anything to the Jellyfin ID it found.

I added some more trace logging in the latest :develop image. Feel free to use that.

Eldarock commented 1 month ago

I will continue to debug with the new traces logs as soon as it's available the native image. Thanks a lot again for your time, really appreciated.

Schaka commented 1 month ago

You can try this via :native-develop now.

Eldarock commented 1 month ago

Looks like if i let janitorr check for the season and not the whole show, the search is not working :

The imdb is not null here (see the example below), so i don't really understand where the problem is now, because it's working if i set the whole-show option to true. It looks like a problem in my Jellyfin setup maybe ? Honestly, it drive me a bit crazy for now haha.

2024-08-09T08:37:40.242-04:00 TRACE 1 --- [ scheduling-1] c.g.s.j.jellystat.JellystatRestService : Could not find any matching media server id for /mnt/user/shows/The Good Doctor (2017)/Season 06/The Good Doctor (2017) - S06E01 - Afterparty.mkv IMDB: tt6470478 TMDB: null TVDB: 328634 Season: 6

Schaka commented 1 month ago

If you look at the full show in Jellyfin, what's the meta data? Does it match what it shows in the log? Is it in a library that is of type Series?

The check for seasons checks that:

I noticed you use Spanish (?) as your Jellyfin language. It's possible that I have a language requirement in my code my accident. Could you please set the language in the profile of your Janitorr user to English and see if that fixes it? If it does, I have to try and rework my matching logic. Granted, it may be related to server language, not client language.

If you go to the season page in Jellyfin, it should show something like this: image

What does it look like for you?

I was hoping the Name returned by this call in Jellyfin would not be localized for seasons.

Eldarock commented 1 month ago

Yup, the metadata are correct for the full show, that's why i think when the whole-show is enabled, the match works. for debugging purpose, all show imdbId : tt6470478, the same we saw in the log in my previous message.

I'm using french fyi, i setted the language for the janitorr user to english, without success.

But i found why with your code snippet and your explanation, you were right :

val seasonMatches = candidate.Type == "Season" && candidate.Name.contains("Season")

In french, it looks like that (Title : Season 6 in english) in metadata :
image

If i change it to "Season 6" instead, the check is working good for this season. Maybe you can check if the season number is not empty instead ? it will works for all language i think, but i don't know if there will be side effects.

Schaka commented 1 month ago

You may try again. I made it language agnostic, by assuming it's always "word \\".

The right way would be to read the local from Jellyfin/Emby and then get the correct word for "Season" from the Jellyfin translation, but for now that's more work than I'm willing to do. It's gone on the TODO list.

Eldarock commented 1 month ago

Yeah, looking good now for the french saison title.

BUT (and i'm sorry for bad news), some tv show don't have "Season X" has title. I have multiple examples :

True Detective Season 4, have title : "Night Country" All the Bridgerton season have a different title than "Season X"

tested with tvdb, and themoviedb metadata fetcher.

I got some others show who have the same issue, but it's a minority now, the language issue is gone. But i think you don't want to check the title, but if it's a season "type", if there is a season number and it's a digit and a not empty title maybe ?

And a quick note for you : Thanks a lot, really appreciated to talk with you, you are really helpful. Thanks for your time and your work again :)

Schaka commented 1 month ago

Can you post some example of what those seasons look like in Jellyfin? Is your season folder on your hard drive called Season 03 or Night Country in this example?

My biggest problem is that a number exists in Sonarr and I need to match that number to what exists in Jellyfin/Emby.

And no worries. I'm happy to help if someone reports a bug that hasn't happened in my case. I would highly recommend you adjust the naming structure for your files according to TRaSH Guides if you haven't done so yet.

Eldarock commented 1 month ago

I'm already using TraSH guides yep.

Path on drive is : shows/True Detective (2014)/Season 04 Metadata in Jellyfin (Display language : english, language metadata : french, just to be precise) : image

Schaka commented 1 month ago

Thank you. It seems Jellyfin uses the index and shows it as "Season number" in the meta data editor.

I adjust it to where I now also use the index as a backup. You can test it again.

This will also be in the next release.

Eldarock commented 1 month ago

It's looks perfect now. No more unmatched show/seasons with the latest native version :) Issue can be closed i think. Good work !