Closed sweetngx closed 2 years ago
Yeah so that is pretty doable with the module.
from subtitle_filter.libs.subtitle import Subtitles, Subtitle
# Read in your subtitle file
subs = Subtitles('/my/subtitle/file.srt')
# Optionally apply the subtitle filter
subs.filter()
# Create your custom subtitle line with the Subtitle class
new_sub = Subtitle()
# Set the contents of the subtitle
new_sub.contents = 'this is my \n awesome subtitle' # use "\n" for multiline subtitle entries.
# Set the timestamp to whatever time you want it to appear
new_sub.start = '00:01:40,723'
new_sub.end = '00:01:42,707'
# The Subtitles class keeps all the Subtitle instances in a list referenced by Subtitles.subtitles
# Prepend this list with your newly created subtitle
subs.subtitles.insert(0, new_sub)
# Reindex the subtitles
for idx, sub in enumerate(self.subtitles):
sub.index = idx + 1
# Save your new subtitle file
subs.save('/my/awesome/new/subtitle.srt')
Well, while doing all this with this great script, I want to make my own advertisement in the first line of the subtitle, can you help me?