Skip to content

Commit

Permalink
Allow "." as a separator for msecs when parsing SRT timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
cdown committed Dec 29, 2015
1 parent 3f2fe5b commit 0ad7b55
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion srt.py
Expand Up @@ -142,7 +142,9 @@ def srt_timestamp_to_timedelta(srt_timestamp):
>>> srt.srt_timestamp_to_timedelta('01:23:04,000')
datetime.timedelta(0, 4984)
'''
hrs, mins, secs, msecs = (int(x) for x in re.split('[,:]', srt_timestamp))
# "." is not technically a legal separator, but some subtitle editors use
# it to delimit msecs, and some players accept it.
hrs, mins, secs, msecs = (int(x) for x in re.split('[,:.]', srt_timestamp))
return timedelta(hours=hrs, minutes=mins, seconds=secs, milliseconds=msecs)


Expand Down

0 comments on commit 0ad7b55

Please sign in to comment.