glut23 / webvtt-py

Read, write, convert and segment WebVTT caption files in Python.
MIT License
188 stars 56 forks source link

identified is None when a srt file is parsed. #27

Closed phigrey closed 4 years ago

phigrey commented 4 years ago

I have run the following code

srt_obj = webvtt.from_srt('dracula.srt')
# srt_obj.save('test.vtt')
print(srt_obj.captions[10].identifier)

At first, I found the identifier in srt file is not saved in vtt file, then I did a little inspection. The identifier is None according to the output.

BTW, I have checked the issue#14. I am using 0.4.3.

phigrey commented 4 years ago

I have solved this by adding identifier.

srt_obj = webvtt.from_srt('dracula.srt')

for index, caption in enumerate(srt_obj.captions):
    caption.identifier = str(index + 1)

srt_obj.save('test.vtt')
glut23 commented 4 years ago

Hi @dorrywhale apologies for the late reply. The identifiers in vtt captions are not a requirement of the WebVTT format as they are optional and for certain purposes. Converting from srt along with those numbers as identifiers would not provide any added benefit. Thanks and Best Regards!