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

Upgradinatorr - Improved series searching #183

Merged
merged 11 commits into from
Jul 20, 2024

Conversation

washedszn
Copy link
Contributor

Description

This PR refactors the searching logic within Upgradinatorr to allow for improved series searching, which reduces the number of potential hits upgradinatorr triggers. It does this by introducing a new config parameter for the sonarr instance called season_monitored_threshold. This threshold is then used to make a decision during media filteration, whereby if the percentage of episodes monitored within a season is less than the threshold, upgradinator will then mark the season as unmonitored, resulting in no search request being sent to sonarr for that season. The media processing has been updated to support these changes.

Example

season_monitored_threshold set to 0.9
image

2/8 = 25% of episodes within this season are monitored. Therefore, since 0.25 is less than our threshold of 0.9, upgradinator will not request a search.

Debug logs for the above example (has some improved logging missing from it): notifiarr log link

Reason

I don't want season packs to be grabbed when I have already started watching a season, which results in unnecessary download usage. Was curious about how searches are handled on sonarrs end of things and it seems like a pack could be grabbed despite episodes being unmonitored, so I looked into implementing a solution within upgradinatorr. Managed to get my desired results, whilst maintaining all existing functionality.

If you want to read more about the sonarr side of this, I asked in their support discord here.

Development

Thought I'd explain how I went about contributing to your repo. After cloning the fork, I setup radarr and sonarr on my local machine so I could test the upgradinatorr script with a small library with no indexers. Once I was sure about my implementation, I added it to my server and tested it on there with my main library with all my indexers. The implementation is working as expected and I'll continue to use the fork on my server, so I'll continue to test it myself.

Config I tested with:

upgradinatorr:
  log_level: debug
  dry_run: false
  instances:
    radarr_1:
      count: 5
      tag_name: upgraded
      unattended: true
    sonarr_1:
      count: 5
      tag_name: upgraded
      unattended: true
      season_monitored_threshold: 0.9

Also one last note, I was really stumped as to what the best name of the new argument should be, I'm still not really happy with season_monitored_threshold. Feel free to make a request/suggestion on renaming it.

@washedszn washedszn changed the title Improved series searching Upgradinatorr - Improved series searching Jul 5, 2024
@Drazzilb08
Copy link
Owner

Neat idea. When I get a moment. I'll look into this.

@Drazzilb08 Drazzilb08 changed the base branch from master to dev July 5, 2024 13:53
@washedszn
Copy link
Contributor Author

washedszn commented Jul 5, 2024

Want me to fix the merge conflicts? Looks pretty simple - just caused by the new tags variables, from the allow ignore tags feature Found a bug so I fixed that as well as the conflicts

@Drazzilb08
Copy link
Owner

It's been a whirlwind weekend, I haven't had a chance to look this over, glad to see you found issues and fixed them.

@washedszn
Copy link
Contributor Author

washedszn commented Jul 8, 2024

No problem! Take your time. It's a pretty difficult script to refactor once knowing it'll all work, as I'm using it I'm discovering issues/improvements. I believe there's an efficiency improvement that can be done, taking a look at that today

I was wrong... Did realise I hadn't updated a docstring though

@Drazzilb08
Copy link
Owner

So couple things to look into

  1. The script needs to continue to work if the argument season_monitored_threshold is not w/in the YML file as to not break people's configs who don't have it within their config files
  2. There needs to be some documentation w/in the sample to help new users on the reason for this addition and how they can best use it if they do (keeping in mind this is an optional addition and the variable can be completely commented or omitted if they do not wish that aspect to be used (basically operate as it always has been).

All in all I like the implementation. Sorry I don't have time to fully read over the code 100% I skimmed through it while I'm sitting in my car at my kids evening events.

I'm always up for code improvements and refactors that make the code make more sense as well as better documentation (I'm not a coder by trade and this is 100% self taught..)

@washedszn
Copy link
Contributor Author

The default value for season_monitored_threshold is 0, which means that the default behaviour when users don't set the variable is the same as before this feature was added - minus how the script performs searches: Prior to the implementation, the script would send a search request to sonarr for a series, letting sonarr handle searching everything within it, whereas now the script will search specific seasons (search season 1, wait, search season 2, wait etc).

I'll update the sample config, wasn't really sure where to document this till now.

Please don't be sorry! It's my first time contributing code to an open source, so it's quite fun and I have a bunch of time on my hands at the moment.

@Drazzilb08 Drazzilb08 merged commit b56f76b into Drazzilb08:dev Jul 20, 2024
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.

2 participants