From a695e74821a85cb883b6b98b0bb2921723916b0d Mon Sep 17 00:00:00 2001 From: iaacornus Date: Mon, 6 Jun 2022 22:39:42 +0800 Subject: [PATCH] codiga suggestions --- main.py | 2 +- reddit/subreddit.py | 4 ++-- setup_program.py | 2 +- video_creation/final_video.py | 10 +++++----- video_creation/voices.py | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index f3ba98f..893d0e2 100644 --- a/main.py +++ b/main.py @@ -62,7 +62,7 @@ def main(subreddit_=None, background=None, filename=None, thread_link_=None): TypeError, ): console.print( - f"[bold red]Please ensure that OPACITY is between 0 and 1 in .env file.[/bold red]" + "[bold red]Please ensure that OPACITY is between 0 and 1 in .env file.[/bold red]" ) raise SystemExit() diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 13293df..09e19fa 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -67,7 +67,7 @@ def get_subreddit_threads(subreddit_, thread_link_): # he doesn't insert the "RANDOM_THREAD" variable at all, ask the thread link if thread_link_ is not None: thread_link = thread_link_ - print_step(f"Getting the inserted thread...") + print_step("Getting the inserted thread...") submission = reddit.submission(url=thread_link) else: try: @@ -104,7 +104,7 @@ def get_subreddit_threads(subreddit_, thread_link_): "comment_id": top_level_comment.id, } ) - except AttributeError as e: + except AttributeError: pass print_substep("AskReddit threads retrieved successfully.", style="bold green") diff --git a/setup_program.py b/setup_program.py index 6800c14..d44c317 100644 --- a/setup_program.py +++ b/setup_program.py @@ -42,7 +42,7 @@ def setup(): + " grab those quickly and come back.[/bold]" ) - """Begin the setup process.""" + # Begin the setup process. cliID = input("Client ID > ") cliSec = input("Client Secret > ") diff --git a/video_creation/final_video.py b/video_creation/final_video.py index eba61b8..c00936e 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -40,7 +40,7 @@ def make_final_video(number_of_clips, file_name): TypeError ): print_substep( - f"Please ensure that OPACITY is between 0 and 1 in .env file", style="bold red" + "Please ensure that OPACITY is between 0 and 1 in .env file", style="bold red" ) # Gather all audio clips @@ -50,7 +50,7 @@ def make_final_video(number_of_clips, file_name): audio_clips.insert(0, AudioFileClip("assets/mp3/title.mp3")) try: - audio_clips.insert(1, AudioFileClip(f"assets/mp3/posttext.mp3")) + audio_clips.insert(1, AudioFileClip("assets/mp3/posttext.mp3")) except ( OSError, FileNotFoundError, @@ -63,10 +63,10 @@ def make_final_video(number_of_clips, file_name): # Gather all images image_clips = [] - if os.path.exists(f"assets/mp3/posttext.mp3"): + if os.path.exists("assets/mp3/posttext.mp3"): image_clips.insert( 0, - ImageClip(f"assets/png/title.png") + ImageClip("assets/png/title.png") .set_duration(audio_clips[0].duration + audio_clips[1].duration) .set_position("center") .resize(width=1080 - 100) @@ -75,7 +75,7 @@ def make_final_video(number_of_clips, file_name): else: image_clips.insert( 0, - ImageClip(f"assets/png/title.png") + ImageClip("assets/png/title.png") .set_duration(audio_clips[0].duration) .set_position("center") .resize(width=1080 - 100) diff --git a/video_creation/voices.py b/video_creation/voices.py index 80372f1..0889ac6 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -25,14 +25,14 @@ def save_text_to_mp3(reddit_obj): length += MP3("assets/mp3/title.mp3").info.length try: - Path(f"assets/mp3/posttext.mp3").unlink() + Path("assets/mp3/posttext.mp3").unlink() except OSError: pass if reddit_obj["thread_post"] != "": tts = gTTS(text=reddit_obj["thread_post"], lang="en", slow=False) - tts.save(f"assets/mp3/posttext.mp3") - length += MP3(f"assets/mp3/posttext.mp3").info.length + tts.save("assets/mp3/posttext.mp3") + length += MP3("assets/mp3/posttext.mp3").info.length for idx, comment in track(enumerate(reddit_obj["comments"]), "Saving..."): # ! Stop creating mp3 files if the length is greater than 50 seconds.