pymedusa / Medusa

Automatic Video Library Manager for TV Shows. It watches for new episodes of your favorite shows, and when they are posted it does its magic.
https://pymedusa.com
GNU General Public License v3.0
1.74k stars 271 forks source link

Custom Quality: Search continues with better quality Allowed instead of only Preferred quality #11710

Open fredhen opened 1 month ago

fredhen commented 1 month ago

Describe the bug When making use of custom quality an episode that is already downloaded with a quality in the Allowed list will be upgraded to another quality in the Allowed list instead of only the Preferred list.

To Reproduce Steps to reproduce the behavior:

  1. Create a custom quality set such as the screenshot in the screenshots section which allows any 720p & 1080p, but prefers 4k.
  2. Have an episode with quality from the Allowed list download (daily search in my case).
  3. See it get upgraded to an episode of higher quality in the Allowed list through a daily search or backlog search.

The log is below, but this is what is seen and causes an upgrade from 1080p HDTV to 1080p WEB-DL (I'm assuming WEB-DL is considered higher quality compared to HDTV):

2024-05-09 11:41:39 INFO     SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Episodes [11] of season 11 are needed with this quality for Showname
2024-05-09 11:41:39 DEBUG    SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: 'Showname' S11E11 status is: 'Downloaded'. Accepting result with quality '1080p WEB-DL'. Reason: New quality is higher quality (and allowed). Accepting new quality
2024-05-09 11:41:39 DEBUG    SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: Allowed, Preferred = [ 720p HDTV, 1080p HDTV, 720p WEB-DL, 1080p WEB-DL, 720p BluRay, 1080p BluRay ] [ 4K UHD TV, 4K UHD WEB-DL, 4K UHD BluRay ] Found = [ 1080p WEB-DL ]
2024-05-09 11:41:39 INFO     SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Quality of Showname.S11E11.1080p.WEB.h264-ELEANOR is 1080p WEB-DL

Expected behavior As described in https://github.com/pymedusa/Medusa/wiki/Quality-Settings#custom-qualities only a single release from the Allowed list should be downloaded:

In short, if qualities are set in both the Allowed and Preferred categories, Medusa will download up to one release from the allowed category and one release from the preferred category even if a higher quality preferred release is released at a later date.

Screenshots image image

Medusa (please complete the following information):

Debug logs (at least 50 lines): General > Advanced Settings > Enable debug

``` 2024-05-09 11:41:47 INFO SNATCHQUEUE-SNATCH-56 :: [34a67cf] Downloading ShownameS11E11.1080p.WEB.h264-ELEANOR with size: 2.49 GB from Indexer, through a SearchType.BACKLOG_SEARCH search 2024-05-09 11:41:47 INFO SNATCHQUEUE-SNATCH-56 :: [34a67cf] Beginning to snatch release: ShownameS11E11.1080p.WEB.h264-ELEANOR 2024-05-09 11:41:47 INFO SEARCHQUEUE-BACKLOG-35839 :: [34a67cf] Updating exception_cache and exception_season_cache 2024-05-09 11:41:47 INFO SEARCHQUEUE-BACKLOG-35839 :: [34a67cf] Beginning backlog search for: The Neighborhood 2024-05-09 11:41:45 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] 56: Formatting pattern: Season %S -> Season 11 2024-05-09 11:41:45 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Found codec for Showname. Episodename 2024-05-09 11:41:45 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Using cache item for ShownameS11E11.1080p.HEVC.x265-MeGusta 2024-05-09 11:41:45 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Parsed /volume2/Series/Showname/Season 11/Showname - S11E11 - Episodename into title: Showname, season: 11, episode: [11], episode_title: Episodename, type: episode, parsing_time: 0.2579982280731201, absolute_episode: [], quality: Unknown, total_time: 0.25919675827026367 2024-05-09 11:41:45 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Matched release /volume2/Series/Showname/Season 11/Showname - S11E11 - Episodename to a series in your database: Showname. using guessit title: Showname 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] New guessit parse for item /volume2/Series/Showname/Season 11/Showname - S11E11 - Episodename 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Trying guessit cache for item /volume2/Series/Showname/Season 11/Showname - S11E11 - Episodename 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] 56: Formatting pattern: %SN - S%0SE11 - %EN -> Showname - S11E11 - Episodename 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Found codec for Showname. Episodename 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Using cache item for ShownameS11E11.1080p.HEVC.x265-MeGusta 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Parsed /volume2/Series/Showname/Season 11/Showname - S11E11 - Episodename into title: Showname, season: 11, episode: [11], episode_title: Episodename, type: episode, parsing_time: 0.2558748722076416, absolute_episode: [], quality: Unknown, total_time: 0.2570028305053711 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Matched release /volume2/Series/Showname/Season 11/Showname - S11E11 - Episodename to a series in your database: Showname. using guessit title: Showname 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] New guessit parse for item /volume2/Series/Showname/Season 11/Showname - S11E11 - Episodename 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Trying guessit cache for item /volume2/Series/Showname/Season 11/Showname - S11E11 - Episodename 2024-05-09 11:41:44 INFO SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Downloading ShownameS11E11.1080p.WEB.h264-ELEANOR with size: 2.49 GB from Indexer 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] No results to sort. 2024-05-09 11:41:44 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Combining single and multi-episode results 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Picked Showname.S11E11.1080p.WEB.h264-ELEANOR as the best result. 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Computed result scores: Score Release 80.00 Showname.S11E11.1080p.WEB.h264-ELEANOR 80.00 Showname.S11E11.1080p.WEB.h264-ELEANOR 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Penalizing release Showname.S11E11.1080p.WEB.h264-ELEANOR (contains undesired word(s)) 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Penalizing release Showname.S11E11.1080p.WEB.h264-ELEANOR (contains undesired word(s)) 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Sorting the following results: ['Showname.S11E11.1080p.WEB.h264-ELEANOR', 'Showname.S11E11.1080p.WEB.h264-ELEANOR'] 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Found wanted results. 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Episodes [11] of season 11 are needed with this quality for Showname 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: 'Showname' S11E11 status is: 'Downloaded'. Accepting result with quality '1080p WEB-DL'. Reason: New quality is higher quality (and allowed). Accepting new quality 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: Allowed, Preferred = [ 720p HDTV, 1080p HDTV, 720p WEB-DL, 1080p WEB-DL, 720p BluRay, 1080p BluRay ] [ 4K UHD TV, 4K UHD WEB-DL, 4K UHD BluRay ] Found = [ 1080p WEB-DL ] 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Quality of Showname.S11E11.1080p.WEB.h264-ELEANOR is 1080p WEB-DL 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Showname.S11E11.WEBRip.x264-XEN0N is an unwanted quality, rejecting it 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Quality of Showname.S11E11.WEBRip.x264-XEN0N is SDTV 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] No episodes [11] of season 11 are needed with this quality for Showname 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: 'Showname' S11E11 status is: 'Downloaded'. Ignoring result with quality '1080p HDTV'. Reason: New quality is same/lower quality (and not preferred). Ignoring new quality 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: Allowed, Preferred = [ 720p HDTV, 1080p HDTV, 720p WEB-DL, 1080p WEB-DL, 720p BluRay, 1080p BluRay ] [ 4K UHD TV, 4K UHD WEB-DL, 4K UHD BluRay ] Found = [ 1080p HDTV ] 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Quality of Showname.S11E11.1080p.HEVC.x265-MeGusta is 1080p HDTV 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Episodes [11] of season 11 are needed with this quality for Showname 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: 'Showname' S11E11 status is: 'Downloaded'. Accepting result with quality '1080p WEB-DL'. Reason: New quality is higher quality (and allowed). Accepting new quality 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: Allowed, Preferred = [ 720p HDTV, 1080p HDTV, 720p WEB-DL, 1080p WEB-DL, 720p BluRay, 1080p BluRay ] [ 4K UHD TV, 4K UHD WEB-DL, 4K UHD BluRay ] Found = [ 1080p WEB-DL ] 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Quality of Showname.S11E11.1080p.WEB.h264-ELEANOR is 1080p WEB-DL 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] No episodes [11] of season 11 are needed with this quality for Showname 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: 'Showname' S11E11 status is: 'Downloaded'. Ignoring result with quality '720p HDTV'. Reason: New quality is same/lower quality (and not preferred). Ignoring new quality 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] 56: Allowed, Preferred = [ 720p HDTV, 1080p HDTV, 720p WEB-DL, 1080p WEB-DL, 720p BluRay, 1080p BluRay ] [ 4K UHD TV, 4K UHD WEB-DL, 4K UHD BluRay ] Found = [ 720p HDTV ] 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Quality of Showname.S11E11.720p.HDTV.x264-SYNCOPY is 720p HDTV 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Showname.S11E11.HDTV.x264-TG is an unwanted quality, rejecting it 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Quality of Showname.S11E11.HDTV.x264-TG is SDTV 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Transaction with 1 queries executed 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [Indexer] :: [34a67cf] Performing episode search for Showname 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Using backlog search providers 2024-05-09 11:41:39 DEBUG SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Internal name cache for Showname set to: show name, Showname 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Building internal name cache for Showname 2024-05-09 11:41:39 INFO SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Finished processing 4560 scene exceptions. 2024-05-09 11:41:38 INFO SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Updating exception_cache and exception_season_cache 2024-05-09 11:41:38 INFO SEARCHQUEUE-BACKLOG-56 :: [34a67cf] Beginning backlog search for: Showname ```

Additional context At first I thought it may be due to https://github.com/pymedusa/Medusa/wiki/Qualities-Changes but the last paragraph states that it will only continue to look in the Preferred list:

If you have qualities in BOTH lists, it will accept any quality in the Allowed list, and continue looking for a better quality in the Preferred list, until it finds one. Once Medusa finds a match in the preferred list, it stops looking.

In general I don't have a problem with this except that it has the capability of using up block data to download on episode of similar quality (1080p HDTV vs 1080p WEB-DL) and in my specific use case it is also overwriting an episode with a preferred compression (based on preferred words in the screenshot above) with an episode with an undesired compression as I prefer 265 over 264.

I'm not entirely sure if it will be considered a bug, but does seem to be one when comparing the behaviour against the documentation, but if it's considered not a bug is there a possibility of adding some logic in to also consider preferred words before downloading the episode. In this case the result is penalized due to the undesired word, but still used due to it being a higher quality, but I would suggest not downloading it due to the existing result having a desired word (and still cached).