From 4dfc250287aa60734588cf07ec3ba3417ac286b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 17 Oct 2018 00:21:24 -0400 Subject: [PATCH] Fix for Subliminal exception: 'list' object has no attribute 'lower'. This is panni's fix. --- libs/subliminal/subtitle.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/libs/subliminal/subtitle.py b/libs/subliminal/subtitle.py index 83beab63a..53313a7c7 100644 --- a/libs/subliminal/subtitle.py +++ b/libs/subliminal/subtitle.py @@ -6,6 +6,8 @@ import os import chardet import pysrt +import types + from .score import get_equivalent_release_groups from .video import Episode, Movie from .utils import sanitize, sanitize_release_group @@ -238,11 +240,24 @@ def guess_matches(video, guess, partial=False): if video.resolution and 'screen_size' in guess and guess['screen_size'] == video.resolution: matches.add('resolution') # format - # Guessit may return a list for `format`, which indicates a conflict in the guessing. - # We should match `format` only when it returns single value to avoid false `format` matches - if video.format and guess.get('format') and not isinstance(guess['format'], list) \ - and guess['format'].lower() == video.format.lower(): - matches.add('format') + if 'format' in guess: + formats = guess["format"] + if not isinstance(formats, types.ListType): + formats = [formats] + + if video.format: + video_format = video.format + if video_format in ("HDTV", "SDTV", "TV"): + video_format = "TV" + logger.debug("Treating HDTV/SDTV the same") + + for frmt in formats: + if frmt in ("HDTV", "SDTV"): + frmt = "TV" + + if frmt.lower() == video_format.lower(): + matches.add('format') + break # video_codec if video.video_codec and 'video_codec' in guess and guess['video_codec'] == video.video_codec: matches.add('video_codec')