optimize subtitle segmentation
optimize code
This commit is contained in:
@@ -63,3 +63,5 @@ if imagemagick_path and os.path.isfile(imagemagick_path):
|
|||||||
ffmpeg_path = app.get("ffmpeg_path", "")
|
ffmpeg_path = app.get("ffmpeg_path", "")
|
||||||
if ffmpeg_path and os.path.isfile(ffmpeg_path):
|
if ffmpeg_path and os.path.isfile(ffmpeg_path):
|
||||||
os.environ["IMAGEIO_FFMPEG_EXE"] = ffmpeg_path
|
os.environ["IMAGEIO_FFMPEG_EXE"] = ffmpeg_path
|
||||||
|
|
||||||
|
logger.info(f"{project_name} v{project_version}")
|
||||||
|
|||||||
@@ -168,6 +168,11 @@ def split_string_by_punctuations(s):
|
|||||||
next_char = ""
|
next_char = ""
|
||||||
for i in range(len(s)):
|
for i in range(len(s)):
|
||||||
char = s[i]
|
char = s[i]
|
||||||
|
if char == "\n":
|
||||||
|
result.append(txt.strip())
|
||||||
|
txt = ""
|
||||||
|
continue
|
||||||
|
|
||||||
if i > 0:
|
if i > 0:
|
||||||
previous_char = s[i - 1]
|
previous_char = s[i - 1]
|
||||||
if i < len(s) - 1:
|
if i < len(s) - 1:
|
||||||
@@ -184,6 +189,8 @@ def split_string_by_punctuations(s):
|
|||||||
result.append(txt.strip())
|
result.append(txt.strip())
|
||||||
txt = ""
|
txt = ""
|
||||||
|
|
||||||
|
# filter empty string
|
||||||
|
result = list(filter(None, result))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ def get_all_fonts():
|
|||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith(".ttf") or file.endswith(".ttc"):
|
if file.endswith(".ttf") or file.endswith(".ttc"):
|
||||||
fonts.append(file)
|
fonts.append(file)
|
||||||
|
fonts.sort()
|
||||||
return fonts
|
return fonts
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user