Skip to content

Commit

Permalink
Add subtitle start > end warning to .to_srt()
Browse files Browse the repository at this point in the history
  • Loading branch information
cdown committed May 2, 2016
1 parent f61496f commit 2c643e2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions srt.py
Expand Up @@ -54,6 +54,9 @@
('No content', lambda sub: not sub.content.strip()),
('Start time < 0 seconds', lambda sub: sub.start < ZERO_TIMEDELTA),
)
SUBTITLE_WARN_CONDITIONS = (
('Subtitle starts time > end time', lambda sub: sub.start > sub.end),
)

SECONDS_IN_HOUR = 3600
SECONDS_IN_MINUTE = 60
Expand Down Expand Up @@ -110,6 +113,12 @@ def to_srt(self, strict=True):
SRT formatted subtitle block
:rtype: str
'''
for warning_msg, check_func in SUBTITLE_WARN_CONDITIONS:
if check_func(self):
log.warning(
'Subtitle at index %d: %s', self.index, warning_msg,
)

output_content = self.content
output_proprietary = self.proprietary

Expand Down

0 comments on commit 2c643e2

Please sign in to comment.