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

feat: remove requests of unmonitored movies/seasons during scan #817

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

bonswouar
Copy link

@bonswouar bonswouar commented Jun 14, 2024

Description

Quick & easy first implementation of Monitoring status support in Radarr:
When a movie - which was monitored before - is unmonitored, it won't appear as "requested" in Jellyseerr anymore

Issues Fixed or Closed

@bonswouar bonswouar changed the title feat: set movie status to unknown if unmonitored from radarr during scan feat: set movie status to unknown if unmonitored from radarr during scan [WIP] Jun 14, 2024
@Fallenbagel Fallenbagel marked this pull request as draft June 15, 2024 04:50
@Fallenbagel
Copy link
Owner

Converted to draft as the title states "WIP". Once it's ready feel free to make this pr ready for review

@bonswouar
Copy link
Author

@Fallenbagel Thanks I didn't think about the Draft feature

This is a WIP but it's basically working as I'd expect.
But I could update it with a more specific Monitoring status support if you think it's a good idea?

Only drawback is that if you have lots of Unmonitored movies in Radarr the scan should be slower, as it will request each unmonitored movie in db every time. Let me know if you have some thoughts about this

@bonswouar
Copy link
Author

FYI I've been using this for months and it works as expected.
I suspect some other users might need this functionality, couldn't we merge it?

A more complete monitoring status support wouldn't be very useful imo, at least I didn't encounter any use case

@bonswouar bonswouar changed the title feat: set movie status to unknown if unmonitored from radarr during scan [WIP] feat: set movie status to unknown if unmonitored from radarr during scan Sep 27, 2024
@gauthier-th gauthier-th marked this pull request as ready for review September 27, 2024 14:10
Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be merged if it's only Radarr. Could you implement the same logic for Sonarr seasons?
And shouldn't there be a setting to enable/disable this behavior? You may have unmonitored a movie/tv show but still want to keep it as requested.

@gauthier-th gauthier-th linked an issue Oct 6, 2024 that may be closed by this pull request
1 task
Copy link

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@github-actions github-actions bot added the merge conflict Cannot merge due to merge conflicts label Nov 10, 2024
@github-actions github-actions bot removed the merge conflict Cannot merge due to merge conflicts label Nov 10, 2024
@bonswouar
Copy link
Author

bonswouar commented Nov 10, 2024

@gauthier-th I've added the Setting, disabled by default

Also I've tried to add the same behaviour for Sonarr, but I encountered an issue:

  • Some (specific) seasons are still shown as "Requested", I don't understand how as I get the new log message "Removing request for ..." for those. Plus I've added a check in processShow() directly, so I really don't see where that could happen in the code. If you've got any clue?

Also, not really related to this issue afaik, but still looks like the same kind of problem:
I've noticed during my debugging that some Seasons are shown as "Available" although they don't contain any file in Sonarr (and are not monitored).
I'd guess it's related to If the season is already marked as available, we force it to stay available (to avoid competing scanners), but I'm really not sure why this condition exists despite the comment (why not at least check if it has any episode instead of relying entirely on the previous status?!)

@bonswouar bonswouar changed the title feat: set movie status to unknown if unmonitored from radarr during scan feat: remove requests of unmonitored movies/seasons during scan Nov 10, 2024
@bonswouar
Copy link
Author

I'll squash the commits when everything's approved

Meanwhile any hint on Sonarr weird behaviour is welcome! I probably missed something, don't know much about the project nor Typescript

Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the way things are done are not consistent between Radarr and Sonarr.
Why do you change the status of the Media entity for movies while you remove the SeasonRequest for series?
It may be linked to the issue you experienced.

src/i18n/locale/fr.json Outdated Show resolved Hide resolved
src/components/Settings/SettingsMain/index.tsx Outdated Show resolved Hide resolved
server/lib/scanners/sonarr/index.ts Outdated Show resolved Hide resolved
server/lib/scanners/sonarr/index.ts Outdated Show resolved Hide resolved
Comment on lines 288 to 291
: settings.main.removeUnmonitoredFromRequestsEnabled &&
!season.monitored &&
season.episodes == 0
? MediaStatus.UNKNOWN
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change necessary? Isn't the Sonarr scanner job enough?

Copy link
Author

@bonswouar bonswouar Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be necessary. It is part of Sonarr scanner job though!

  • At the beginning of the job I check if there is any SeasonRequest and delete it if necessary
  • And here I check the Status of the Season, as every Season is parsed and its Status checked/updated, it should set un-monitored season with no file to UNKNOWN (as for Movies)

@gauthier-th
Copy link
Collaborator

Also, not really related to this issue afaik, but still looks like the same kind of problem: I've noticed during my debugging that some Seasons are shown as "Available" although they don't contain any file in Sonarr (and are not monitored). I'd guess it's related to If the season is already marked as available, we force it to stay available (to avoid competing scanners), but I'm really not sure why this condition exists despite the comment (why not at least check if it has any episode instead of relying entirely on the previous status?!)

There are several jobs that update the status of a Media: Radarr/Sonarr jobs, and Jellyfin/Emby/Plex jobs, hence the comment about competing jobs.

@bonswouar
Copy link
Author

bonswouar commented Nov 11, 2024

It looks like the way things are done are not consistent between Radarr and Sonarr. Why do you change the status of the Media entity for movies while you remove the SeasonRequest for series? It may be linked to the issue you experienced.

For clarity, there are two potential "problems" with un-monitored medias that I've been trying to fix:

  1. Scenario 1
    Nothing is requested. But the movie was originally added (from Radarr directly) with the status monitored. It's been un-monitored later

    • In Jellyseerr it will always be shown as "Requested", which imo is a real issue (it really doesn't match Radarr behaviour, and the user can't know nor do anything about it, will never be able to really request it, etc)
      • => That's my first commit specifically for this problem, for Movies only (and there is no Request in this case, despite the visible "Requested" status)
  2. Scenario 2
    Something is requested, but manually un-monitored before it completes. For Movies it's not really a problem imo, as the admin can as easily delete a request from Jellyseerr than un-monitor a Movie from Radarr. But for Shows it becomes more complicated as an admin can't EDIT a Request

    • Thus if for example multiple Seasons of a Show are Requested, but only 1 kept & all the other ones unmonitored from Sonarr, the user won't be able to request again the other ones.
      • => That's the main goal of my second commit for Shows

I can certainly add 1/ for Shows for consistency, but not sure many users automatically import monitored Shows from Sonarr and un-monitor them before they're downloaded. Actually I'm pretty sure that's also what this change does: Season not monitored && no episode = Status UNKNOWN
I hope my explanation & use cases do make sense!

@bonswouar
Copy link
Author

bonswouar commented Nov 11, 2024

There are several jobs that update the status of a Media: Radarr/Sonarr jobs, and Jellyfin/Emby/Plex jobs, hence the comment about competing jobs.

I still don't get the logic, why "If the season is already marked as available, we force it to stay available"?
What if the season is not available anymore??!
The referencing code is:

(season.totalEpisodes === season.episodes && season.episodes > 0) ||
            existingSeason.status === MediaStatus.AVAILABLE

And I don't get why we don't check anything on this second line (i.e existingSeason.status === MediaStatus.AVAILABLE && season.episodes > 0)
But anyway that should be a separate issue I guess as it's not about monitor status

EDIT: Well I did try this simple change, and it seems to fix this issue for one season that was always shown as Available before (although it has been deleted some time ago)

@bonswouar
Copy link
Author

bonswouar commented Nov 11, 2024

@gauthier-th I went with your recommendations, and marked as resolved the comments I was sure about.
I'll let you have a look at my other answers

Not sure why/how, but during my last tests the problem seems fixed!
Although, after running 2 Sonarr scans, I still had:

Removing request for Season X of tmdbId XXXX as it is unmonitored

with the same Season/ID, twice in the log. Which means the first time didn't work, right?

Is there something I should know about async deletion in typescript or something? This seems a bit random

@gauthier-th
Copy link
Collaborator

I still don't get the logic, why "If the season is already marked as available, we force it to stay available"?
What if the season is not available anymore??!

There is another job, "Media Availability Sync" that runs and mark the media as unavailable if necessary.

Is there something I should know about async deletion in typescript or something? This seems a bit random

It could come from your forEach loops. For instance in the processUnmonitoredSeason you are using an async function inside a forEach loops, but forEach loops don't wait the end of the async function to run the next item. IMHO It's better to use a for loop to iterate over an array than a forEach, because of this async function concurrency.

Let me review it one more time with the change you made and with your comments in mind.

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

Successfully merging this pull request may close these issues.

Support monitor type for Radarr
3 participants