Skip to content

Commit

Permalink
Merge d0c845b into 1a9cf06
Browse files Browse the repository at this point in the history
  • Loading branch information
ratoaq2 committed Jan 29, 2017
2 parents 1a9cf06 + d0c845b commit a54ca29
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/properties.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,5 @@ Other properties
- ``Fansub``, ``HR``, ``HQ``, ``Screener``, ``Unrated``, ``HD``, ``3D``, ``SyncFix``, ``Bonus``,
``WideScreen``, ``Fastsub``, ``R5``, ``AudioFix``, ``DDC``, ``Trailer``, ``Complete``, ``Limited``, ``Classic``,
``Proper``, ``DualAudio``, ``LiNE``, ``LD``, ``MD``, ``XXX``, ``Remastered``, ``Extended``, ``Extended Cut``,
``Uncut``, ``Retail``, ``ReEncoded``, ``Mux``
``Uncut``, ``Retail``, ``ReEncoded``, ``Mux``, ``Hardcoded Subtitles``

28 changes: 27 additions & 1 deletion guessit/rules/properties/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ def validate_complete(match):
tags=['other.validate.screener', 'format-prefix', 'format-suffix'])
rebulk.string('Mux', value='Mux', validator=seps_after,
tags=['other.validate.mux', 'video-codec-prefix', 'format-suffix'])
rebulk.string('HC', value='Hardcoded Subtitles')

rebulk.rules(ValidateHasNeighbor, ValidateHasNeighborAfter, ValidateHasNeighborBefore, ValidateScreenerRule,
ValidateMuxRule, ProperCountRule)
ValidateMuxRule, ValidateHardcodedSubs, ProperCountRule)

return rebulk

Expand Down Expand Up @@ -200,3 +201,28 @@ def when(self, matches, context):
if not format_match:
ret.append(mux)
return ret


class ValidateHardcodedSubs(Rule):
"""Validate HC matches."""

priority = 32
consequence = RemoveMatch

def when(self, matches, context):
to_remove = []
for hc_match in matches.named('other', predicate=lambda match: match.value == 'Hardcoded Subtitles'):
next_match = matches.next(hc_match, predicate=lambda match: match.name == 'subtitle_language', index=0)
if next_match and not matches.holes(hc_match.end, next_match.start,
predicate=lambda match: match.value.strip(seps)):
continue

previous_match = matches.previous(hc_match,
predicate=lambda match: match.name == 'subtitle_language', index=0)
if previous_match and not matches.holes(previous_match.end, hc_match.start,
predicate=lambda match: match.value.strip(seps)):
continue

to_remove.append(hc_match)

return to_remove
12 changes: 12 additions & 0 deletions guessit/test/episodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2901,3 +2901,15 @@
video_codec: h264
release_group: CasStudio
type: episode

# Hardcoded subtitles
? Show.Name.S06E16.HC.SWESUB.HDTV.x264
: title: Show Name
season: 6
episode: 16
other: Hardcoded Subtitles
format: HDTV
video_codec: h264
subtitle_language: sv
type: episode

0 comments on commit a54ca29

Please sign in to comment.