Skip to content

Commit

Permalink
Merge pull request #780 from pymedusa/additional-fix-multiple-formats
Browse files Browse the repository at this point in the history
Additional fix for guessit multiple formats
  • Loading branch information
ratoaq2 committed Jul 19, 2016
2 parents 0d210fc + d0b5098 commit dfb86af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 3 additions & 4 deletions sickbeard/name_parser/rules/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,6 @@ def when(self, matches, context):
:type context: dict
:return:
"""
to_remove = []
fileparts = matches.markers.named('path')
for filepart in marker_sorted(fileparts, matches):
formats = matches.range(filepart.start, filepart.end, predicate=lambda match: match.name == 'format')
Expand All @@ -1806,9 +1805,9 @@ def when(self, matches, context):
lambda match: match.name in ('video_codec', 'release_group'))
# If we have at least 3 matches near by, then discard the other formats
if len(previous) + len(next_range) > 2:
to_remove.extend(formats[0:-1])

return to_remove
invalid_formats = {f.value for f in formats[0:-1]}
to_remove = matches.named('format', predicate=lambda m: m.value in invalid_formats)
return to_remove


class EnhanceReleaseGroupDetection(Rule):
Expand Down
5 changes: 4 additions & 1 deletion tests/datasets/tvshows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2706,7 +2706,8 @@
type: episode

# FixMultipleFormats
? Show.Name.S02E01.eps2.0.unm4sk-pt1.tc.1080p.WEB-DL.DD5.1.H264-GROUP
? - Show.Name.S02E01.eps2.0.unm4sk-pt1.tc.1080p.WEB-DL.DD5.1.H264-GROUP.mkv
- /folder/Show.Name.S02E01.eps2.0.unm4sk-pt1.tc.1080p.WEB-DL.DD5.1.H264-GROUP[something]/Show.Name.S02E01.eps2.0.unm4sk-pt1.tc.1080p.WEB-DL.DD5.1.H264-GROUP.mkv
: title: Show Name
season: 2
episode: 1
Expand All @@ -2719,6 +2720,8 @@
audio_channels: '5.1'
video_codec: h264
release_group: GROUP
container: mkv
mimetype: video/x-matroska
type: episode

# Size detection separated with .
Expand Down

0 comments on commit dfb86af

Please sign in to comment.