Fixed support for lists in audio_codec match guessing

This commit is contained in:
Vitiko 2021-05-15 08:11:03 -04:00 committed by GitHub
parent 9993f123f1
commit 9f401cbb67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 6 deletions

View File

@ -410,6 +410,17 @@ MERGED_FORMATS = {
MERGED_FORMATS_REV = dict((v.lower(), k.lower()) for k in MERGED_FORMATS for v in MERGED_FORMATS[k])
def _has_match(video, guess, key) -> bool:
value = getattr(video, key)
if value is None:
return False
guess_value = guess.get(key)
if isinstance(guess_value, list):
return any(value == item for item in guess_value)
return value == guess_value
def guess_matches(video, guess, partial=False):
"""Get matches between a `video` and a `guess`.
@ -514,12 +525,11 @@ def guess_matches(video, guess, partial=False):
logger.info("Release group matched but source didn't. Remnoving release group match.")
matches.remove("release_group")
# video_codec
if video.video_codec and 'video_codec' in guess and guess['video_codec'] == video.video_codec:
matches.add('video_codec')
# audio_codec
if video.audio_codec and 'audio_codec' in guess and guess['audio_codec'] == video.audio_codec:
matches.add('audio_codec')
if _has_match(video, guess, "video_codec"):
matches.add("video_codec")
if _has_match(video, guess, "audio_codec"):
matches.add("audio_codec")
return matches