Skip to content

Commit

Permalink
Fix #203: Detect releaseGroup properties when prefixed by screenSize
Browse files Browse the repository at this point in the history
  • Loading branch information
Toilal committed Jun 6, 2015
1 parent 180d004 commit 5f84793
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
18 changes: 18 additions & 0 deletions guessit/test/autodetect.yaml
Expand Up @@ -507,3 +507,21 @@
episodeNumber: 34
title: At the End of Darkness
crc32: 781219F1

? Game.of.Thrones.S05E07.720p.HDTV-KILLERS.mkv
: type: episode
episodeNumber: 7
format: HDTV
releaseGroup: KILLERS
screenSize: 720p
season: 5
series: Game of Thrones

? Game.of.Thrones.S05E07.HDTV.720p-KILLERS.mkv
: type: episode
episodeNumber: 7
format: HDTV
releaseGroup: KILLERS
screenSize: 720p
season: 5
series: Game of Thrones
19 changes: 15 additions & 4 deletions guessit/transfo/guess_release_group.py
Expand Up @@ -40,10 +40,12 @@ def __init__(self):
lambda elt: self._is_number(elt)]
# If the previous property in this list, the match will be considered as safe
# and group name can contain a separator.
self.previous_safe_properties = ['videoCodec', 'format', 'videoApi', 'audioCodec', 'audioProfile', 'videoProfile', 'audioChannels', 'other']
self.previous_safe_properties = ['videoCodec', 'format', 'videoApi', 'audioCodec', 'audioProfile', 'videoProfile', 'audioChannels', 'screenSize', 'other']
self.previous_safe_values = {'other': ['Complete']}
self.next_safe_properties = ['extension', 'website']
self.next_safe_values = {'format': ['Telesync']}
self.next_unsafe_properties = list(self.previous_safe_properties)
self.next_unsafe_properties.extend(['episodeNumber', 'season'])
self.container.sep_replace_char = '-'
self.container.canonical_from_pattern = False
self.container.enhance = True
Expand Down Expand Up @@ -112,12 +114,21 @@ def is_leaf_previous(leaf, node):
return True
return False

@staticmethod
def validate_next_leaves(node):
def validate_next_leaves(self, node):
if 'series' in node.root.info or 'title' in node.root.info:
# --expected-series or --expected-title is used.
return True

next_leaf = node.root.next_leaf(node)
node_idx = node.node_last_idx
while next_leaf and next_leaf.node_last_idx >= node_idx:
node_idx = next_leaf.node_last_idx
# Check next properties in the same group are not in unsafe properties list
for next_unsafe_property in self.next_unsafe_properties:
if next_unsafe_property in next_leaf.info:
return False
next_leaf = next_leaf.root.next_leaf(next_leaf)

# Make sure to avoid collision with 'series' or 'title' guessed later. Should be more precise.
leaves = node.root.unidentified_leaves()
return len(list(leaves)) > 1
Expand All @@ -129,7 +140,7 @@ def validate_node(self, leaf, node, safe=False):
return False
if safe:
for k, v in leaf.guess.items():
if k in self.previous_safe_values and not v in self.previous_safe_values[k]:
if k in self.previous_safe_values and v not in self.previous_safe_values[k]:
return False
return True

Expand Down

0 comments on commit 5f84793

Please sign in to comment.