isaacbernat / netflix-to-srt

Rip, extract and convert subtitles to .srt closed captions from .xml/dfxp/ttml and .vtt/WebVTT (e.g. Netflix, YouTube)
MIT License
741 stars 72 forks source link

Fixed issue where script throws error if first caption is at time 0 #9

Closed rakochi closed 7 years ago

rakochi commented 7 years ago

Error was the following:

Traceback (most recent call last): File "to_srt.py", line 97, in main() File "to_srt.py", line 94, in main f.write(to_srt(text)) File "to_srt.py", line 69, in to_srt append_subs(prev_time["start"], prev_time["end"], prev_content, fmt_t) File "to_srt.py", line 25, in append_subs "start_time": convert_time(start) if format_time else start, File "to_srt.py", line 13, in convert_time ms = leading_zeros(int(raw_time[:-4]) % 1000, 3) ValueError: invalid literal for int() with base 10: ''

isaacbernat commented 7 years ago

Hi @rakochi, thanks for the fix. Could you please add an example that crashed before? Something similar to an input sample and the corresponding output sample would suffice.