From b5c6e8f60b0fef48d950ac84c0edb2b3d36e3472 Mon Sep 17 00:00:00 2001 From: Domiziano Scarcelli Date: Mon, 6 Jun 2022 11:11:44 +0200 Subject: [PATCH 1/3] Added a .env variable to change the save location of the final video --- .env.template | 3 +++ video_creation/final_video.py | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.env.template b/.env.template index e95c209..56f60d0 100644 --- a/.env.template +++ b/.env.template @@ -18,3 +18,6 @@ SUBREDDIT="" # Range is 0 -> 1 OPACITY="0.9" + +#The absolute path of the folder you want to save the final video +FINAL_VIDEO_PATH="" \ No newline at end of file diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 93bac6f..d9463bb 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -1,3 +1,4 @@ +from click import style from moviepy.editor import ( VideoFileClip, AudioFileClip, @@ -9,7 +10,7 @@ from moviepy.editor import ( ) import reddit.subreddit import re -from utils.console import print_step +from utils.console import print_step, print_substep from dotenv import load_dotenv import os @@ -80,7 +81,16 @@ def make_final_video(number_of_clips): ) image_concat.audio = audio_composite final = CompositeVideoClip([background_clip, image_concat]) - filename = (re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.subreddit.submission.title + ".mp4"))) - final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k") + + final_video_path = "assets/" + if os.getenv("FINAL_VIDEO_PATH"): + final_video_path = os.getenv("FINAL_VIDEO_PATH") + filename = (re.sub('[?\"%*:|<>]', '', (final_video_path + reddit.subreddit.submission.title + ".mp4"))) + try: + final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k") + except: + print_substep("Something's wrong with the path you inserted, the video will be saved in the default path (assets/)", style="bold red") + filename = (re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.subreddit.submission.title + ".mp4"))) + final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k") for i in range(0, number_of_clips): pass From 46b77cb7311b5b9ef7af652863b7e86668824503 Mon Sep 17 00:00:00 2001 From: Domiziano Scarcelli Date: Mon, 6 Jun 2022 11:16:52 +0200 Subject: [PATCH 2/3] Edit .env.template --- .env.template | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.template b/.env.template index 56f60d0..7469035 100644 --- a/.env.template +++ b/.env.template @@ -19,5 +19,6 @@ SUBREDDIT="" # Range is 0 -> 1 OPACITY="0.9" -#The absolute path of the folder you want to save the final video +# The absolute path of the folder where you want to save the final video +# If empty or wrong, the path will be 'assets/' FINAL_VIDEO_PATH="" \ No newline at end of file From 5bf088846028fa479863311ab576057d0c1336a1 Mon Sep 17 00:00:00 2001 From: Domiziano Scarcelli Date: Wed, 8 Jun 2022 00:23:29 +0200 Subject: [PATCH 3/3] Removed unused imports --- video_creation/final_video.py | 1 - 1 file changed, 1 deletion(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index d9463bb..96be579 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -1,4 +1,3 @@ -from click import style from moviepy.editor import ( VideoFileClip, AudioFileClip,