Skip to content

Commit

Permalink
Merge pull request #71 from faveris/feature/support-multiline-subtitles
Browse files Browse the repository at this point in the history
Added multiline subtitles support for auto-subs-light
  • Loading branch information
tmoroney authored Sep 27, 2024
2 parents e3d583a + 66904ec commit a635cd7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions auto-subs-light.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ def OnAddSubs(ev):

timelineStartFrame = timeline.GetStartFrame() # get timeline start frame
#print("-> Start of timeline: ", timelineStartFrame)
for i in range(0, len(lines), 4):
i = 0
while i < len(lines):
frame_rate = timeline.GetSetting("timelineFrameRate") # get timeline framerate
start_time, end_time = lines[i+1].strip().split(" --> ")
text = lines[i+2].strip() # get subtitle text

# Accumulate subtitle text until an empty line is found
text = lines[i+2].strip()
for j in range(i+3, len(lines)):
if lines[j].strip() == "":
break
text += "\n" + lines[j].strip()

# Convert timestamps to frames for position of subtitle
hours, minutes, seconds_milliseconds = start_time.split(':')
Expand Down Expand Up @@ -180,6 +187,9 @@ def OnAddSubs(ev):
text = re.sub(pattern, censored_word, text, flags=re.IGNORECASE)

subs.append((timelinePos, duration, text)) # add subtitle to list

# Move to the next subtitle block
i = j + 1

print("Found", len(subs), "subtitles in SRT file")

Expand Down

0 comments on commit a635cd7

Please sign in to comment.