Skip to content

Commit

Permalink
Merge pull request #436 from guessit-io/feature/fix-wrong-audio-detec…
Browse files Browse the repository at this point in the history
…tion

Invalid audio detection
  • Loading branch information
ratoaq2 committed Apr 23, 2017
2 parents dc1f017 + 6d6842d commit ad775aa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions guessit/options.py
Expand Up @@ -161,8 +161,8 @@ def load_config(options):
if configurations:
configurations.append(options)
return merge_configurations(*configurations)
else:
return options

return options


def merge_configurations(*configurations):
Expand Down
2 changes: 1 addition & 1 deletion guessit/rules/properties/country.py
Expand Up @@ -56,7 +56,7 @@ def convert(self, alpha2):
return 'UK'
return str(babelfish.Country(alpha2))

def reverse(self, name):
def reverse(self, name): # pylint:disable=arguments-differ
# exceptions come first, as they need to override a potential match
# with any of the other guessers
try:
Expand Down
6 changes: 4 additions & 2 deletions guessit/rules/properties/language.py
Expand Up @@ -76,7 +76,7 @@ def codes(self): # pylint: disable=missing-docstring
def convert(self, alpha3, country=None, script=None):
return str(babelfish.Language(alpha3, country, script))

def reverse(self, name):
def reverse(self, name): # pylint:disable=arguments-differ
with_country = (GuessitConverter._with_country_regexp.match(name) or
GuessitConverter._with_country_regexp2.match(name))

Expand Down Expand Up @@ -130,6 +130,8 @@ def length_comparator(value):
lang_suffixes = sorted(lang_both + ['audio'], key=length_comparator)
lang_prefixes = sorted(lang_both + ['true'], key=length_comparator)

weak_prefixes = ('audio', 'true')

_LanguageMatch = namedtuple('_LanguageMatch', ['property_name', 'word', 'lang'])


Expand Down Expand Up @@ -293,7 +295,7 @@ def find_match_for_word(self, word, fallback_word, affixes, is_affix, strip_affi
if fallback_word:
match = self.find_language_match_for_word(fallback_word, key=key, force=True)

if not match:
if not match and part not in weak_prefixes:
match = self.create_language_match(key, LanguageWord(current_word.start, current_word.end,
'und', current_word.input_string))
elif value not in self.common_words:
Expand Down
11 changes: 11 additions & 0 deletions guessit/test/episodes.yml
Expand Up @@ -3835,3 +3835,14 @@
video_codec: h264
release_group: NTb
type: episode

? True Detective S02E04 720p HDTV x264-0SEC [GloDLS].mkv
: title: True Detective
season: 2
episode: 4
screen_size: 720p
format: HDTV
video_codec: h264
release_group: 0SEC [GloDLS]
container: mkv
type: episode
8 changes: 4 additions & 4 deletions guessit/test/test_yml.py
Expand Up @@ -71,10 +71,10 @@ def __repr__(self):
return '%s%s: ERROR! (valid=%i, missing=%i, different=%i, extra=%i, others=%i)' % \
('-' if self.negates else '', self.string, len(self.valid), len(self.missing), len(self.different),
len(self.extra), len(self.others))
else:
return '%s%s: UNKOWN! (valid=%i, missing=%i, different=%i, extra=%i, others=%i)' % \
('-' if self.negates else '', self.string, len(self.valid), len(self.missing), len(self.different),
len(self.extra), len(self.others))

return '%s%s: UNKOWN! (valid=%i, missing=%i, different=%i, extra=%i, others=%i)' % \
('-' if self.negates else '', self.string, len(self.valid), len(self.missing), len(self.different),
len(self.extra), len(self.others))

@property
def details(self):
Expand Down

0 comments on commit ad775aa

Please sign in to comment.