Skip to content

Commit

Permalink
Don't replace allowed quality unless from preferred quality (#11711)
Browse files Browse the repository at this point in the history
* Don't replace allowed quality unless from preferred quality

* Update common.py

* Update common.py

* Update common.py

* Update test_should_replace.py

---------

Co-authored-by: Dario <[email protected]>
  • Loading branch information
fredhen and medariox authored Dec 10, 2024
1 parent c27f52f commit 6349562
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions medusa/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,7 @@ def should_replace(ep_status, old_quality, new_quality, allowed_qualities, prefe
if new_quality in preferred_qualities:
return True, 'New quality is preferred. Accepting new quality'

if new_quality > old_quality:
return True, 'New quality is higher quality (and allowed). Accepting new quality'
else:
return False, 'New quality is same/lower quality (and not preferred). Ignoring new quality'
return False, 'Existing quality is allowed and new quality is not a preferred quality. Ignoring new quality'

else:
# Allowed quality should never be replaced
Expand Down
4 changes: 2 additions & 2 deletions tests/test_should_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
'manually_searched': False,
'expected': False
},
{ # p6: Snatched Proper 720p HDTV and found 720p BluRay, and 720p BluRay is not preferred but allowed: yes
{ # p6: Snatched Proper 720p HDTV and found 720p BluRay, and 720p BluRay is not preferred but allowed: no
'ep_status': SNATCHED_PROPER,
'cur_quality': Quality.HDTV,
'new_quality': Quality.HDBLURAY,
Expand All @@ -83,7 +83,7 @@
'download_current_quality': False,
'force': False,
'manually_searched': False,
'expected': True
'expected': False
},
{ # p7: Downloaded 720p HDTV and found 720p BluRay, 720p BluRay is not explicity allowed but it's preferred: yes
'ep_status': DOWNLOADED,
Expand Down

0 comments on commit 6349562

Please sign in to comment.