diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3e858d..ca1c7cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -111,7 +111,16 @@ When making your PR, follow these guidelines: - Your branch has a base of _develop_, **not** _master_ - You are merging your branch into the _develop_ branch -- You link any issues that are resolved or fixed by your changes. (this is done by typing "Fixes #\") in your pull request. +- You link any issues that are resolved or fixed by your changes. (this is done by typing "Fixes #\") in your pull request +- Where possible, you have used `git pull --rebase`, to avoid creating unnecessary merge commits +- You have meaningful commits, and if possible, follow the commit style guide of `type: explanation` +- Here are the commit types: + - **feat** - a new feature + - **fix** - a bug fix + - **docs** - a change to documentation / commenting + - **style** - formatting changes - does not impact code + - **refactor** - refactored code + - **chore** - updating configs, workflows etc - does not impact code ### Improving The Documentation diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 428dd67..cae8cc1 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -27,6 +27,19 @@ 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, background_config: Tuple[str, str, str, Any]): """Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp @@ -90,7 +103,7 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict, backgr 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)