From cebbbf72cb2a75170e5ea24bd12550cc189c1d5e Mon Sep 17 00:00:00 2001 From: Tomovic Date: Wed, 6 Jul 2022 16:19:36 +0200 Subject: [PATCH 1/3] Added translation for filename TOML compatible --- video_creation/final_video.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 5938235..b56d231 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -4,6 +4,7 @@ import os import re from os.path import exists from typing import Dict +import translators as ts from moviepy.editor import ( VideoFileClip, @@ -35,7 +36,15 @@ def name_normalize( 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 + + lang = settings.config["reddit"]["thread"]["post_lang"] + if lang != "": + print_substep("Translating filename...") + translated_name = ts.google(name, to_language = lang) + return translated_name + + else: + return name def make_final_video( From 71eca6991215e1e8538c03c789b4893bacc0eef3 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Wed, 6 Jul 2022 20:08:45 +0000 Subject: [PATCH 2/3] fix: handle non value for post lang --- video_creation/final_video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 1080f66..4f73cf8 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -37,7 +37,7 @@ def name_normalize(name: str) -> str: name = re.sub(r"\/", r"", name) lang = settings.config["reddit"]["thread"]["post_lang"] - if lang != "": + if lang: print_substep("Translating filename...") translated_name = ts.google(name, to_language = lang) return translated_name From 4d7db77fff3097451a937ced47bf88d3655ec2e5 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Wed, 6 Jul 2022 23:14:43 +0100 Subject: [PATCH 3/3] style: reformat with python-black --- video_creation/final_video.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 4f73cf8..42f13b4 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -35,11 +35,11 @@ def name_normalize(name: str) -> str: 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) - + lang = settings.config["reddit"]["thread"]["post_lang"] if lang: print_substep("Translating filename...") - translated_name = ts.google(name, to_language = lang) + translated_name = ts.google(name, to_language=lang) return translated_name else: