Merge pull request #403 from Drugsosos/fix--video-file-name

added name_normalize to fix bugs with forbidden chars in videoname
pull/863/head
Jason 2 years ago committed by GitHub
commit 0db13912b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,6 +26,18 @@ console = Console()
W, H = 1080, 1920
def name_normalize(
name: str
) -> str:
name = re.sub(r'[?\\"%*:|<>]', '', name)
name = re.sub(r'( [w,W]\s?\/\s?[o,O,0])', r' without', name)
name = re.sub(r'( [w,W]\s?\/)', r' with', name)
name = re.sub(r'([0-9]+)\s?\/\s?([0-9]+)', r'\1 of \2', name)
name = re.sub(r'(\w+)\s?\/\s?(\w+)', r'\1 or \2', name)
name = re.sub(r'\/', r'', name)
return name
def make_final_video(number_of_clips: int, length: int, reddit_obj: dict):
"""Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp
@ -90,7 +102,7 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict):
final = CompositeVideoClip([background_clip, image_concat])
title = re.sub(r"[^\w\s-]", "", reddit_obj["thread_title"])
idx = re.sub(r"[^\w\s-]", "", reddit_obj["thread_id"])
filename = f"{title}.mp4"
filename = f"{name_normalize(title)}.mp4"
subreddit = os.getenv("SUBREDDIT")
save_data(filename, title, idx)

Loading…
Cancel
Save