From 5f2070d34497d6e2bfa5716f4dffdf53a96c3fe8 Mon Sep 17 00:00:00 2001 From: jacesleeman <46321222+jacesleeman@users.noreply.github.com> Date: Sat, 4 Jun 2022 09:04:43 -0400 Subject: [PATCH 1/6] Added opacity setting to the screen shots --- .env.template | 3 +++ video_creation/final_video.py | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.env.template b/.env.template index 5ab4ae4..43cb7d9 100644 --- a/.env.template +++ b/.env.template @@ -9,3 +9,6 @@ REDDIT_2FA="" THEME="" SUBREDDIT="" + +# Range is 0 -> 1 +OPACITY="" diff --git a/video_creation/final_video.py b/video_creation/final_video.py index e1f71ff..9db757e 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -8,12 +8,18 @@ from moviepy.editor import ( CompositeVideoClip, ) from utils.console import print_step - +from dotenv import load_dotenv +import os W, H = 1080, 1920 + def make_final_video(number_of_clips): + # Calls opacity from the .env + load_dotenv() + opacity = os.getenv('OPACITY') + print_step("Creating the final video...") VideoFileClip.reW = lambda clip: clip.resize(width=W) VideoFileClip.reH = lambda clip: clip.resize(width=H) @@ -39,14 +45,16 @@ def make_final_video(number_of_clips): ImageClip(f"assets/png/comment_{i}.png") .set_duration(audio_clips[i + 1].duration) .set_position("center") - .resize(width=W - 100), + .resize(width=W - 100) + .set_opacity(float(opacity)), ) image_clips.insert( 0, ImageClip(f"assets/png/title.png") .set_duration(audio_clips[0].duration) .set_position("center") - .resize(width=W - 100), + .resize(width=W - 100) + .set_opacity(float(opacity)), ) image_concat = concatenate_videoclips(image_clips).set_position( ("center", "center") From 84c8eb25ce3a8735dfb9486330647006e4891a5f Mon Sep 17 00:00:00 2001 From: jacesleeman <46321222+jacesleeman@users.noreply.github.com> Date: Sat, 4 Jun 2022 10:02:01 -0400 Subject: [PATCH 2/6] updated .env to explain better --- .env.template | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.env.template b/.env.template index 43cb7d9..5115d89 100644 --- a/.env.template +++ b/.env.template @@ -3,12 +3,13 @@ REDDIT_CLIENT_SECRET="" REDDIT_USERNAME="" REDDIT_PASSWORD="" -# Valid options are "yes" and "no" for the variable below +SUBREDDIT="" + +# Valid options are "yes" and "no" REDDIT_2FA="" +# Valid options are "light "dark" THEME="" -SUBREDDIT="" - # Range is 0 -> 1 OPACITY="" From 102f791684caddfdd3bb7de1b63c3391790e565b Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 15:43:21 +0100 Subject: [PATCH 3/6] Update .env.template --- .env.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.template b/.env.template index 5115d89..58f3fd3 100644 --- a/.env.template +++ b/.env.template @@ -8,8 +8,8 @@ SUBREDDIT="" # Valid options are "yes" and "no" REDDIT_2FA="" -# Valid options are "light "dark" +# Valid options are "light" and "dark" THEME="" # Range is 0 -> 1 -OPACITY="" +OPACITY="0.9" From fe92918823c0dbfc1dd03d7b675b0bfcb94b15b5 Mon Sep 17 00:00:00 2001 From: jacesleeman <46321222+jacesleeman@users.noreply.github.com> Date: Sat, 4 Jun 2022 10:59:07 -0400 Subject: [PATCH 4/6] updated --- .env.template | 2 +- main.py | 2 ++ video_creation/final_video.py | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.env.template b/.env.template index 43cb7d9..d90bac7 100644 --- a/.env.template +++ b/.env.template @@ -11,4 +11,4 @@ THEME="" SUBREDDIT="" # Range is 0 -> 1 -OPACITY="" +OPACITY=".9" diff --git a/main.py b/main.py index 8cc3c9a..b0a4c28 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,8 @@ from video_creation.final_video import make_final_video from dotenv import load_dotenv import os +REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD", "OPACITY"] + print_markdown( "### Thanks for using this tool! [Feel free to contribute to this project on GitHub!](https://lewismenelaws.com) If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue." ) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 9db757e..0a2afb0 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -30,6 +30,11 @@ def make_final_video(number_of_clips): .resize(height=H) .crop(x1=1166.6, y1=0, x2=2246.6, y2=1920) ) + try: + float(os.getenv("OPACITY")) + except: + print(f"Please ensure that OPACITY is set between 0 and 1 in your .env file") + configured = False # Gather all audio clips audio_clips = [] for i in range(0, number_of_clips): From c318e4e0425f288a7189ea9ec6e2f2361367a973 Mon Sep 17 00:00:00 2001 From: jacesleeman <46321222+jacesleeman@users.noreply.github.com> Date: Sat, 4 Jun 2022 11:06:52 -0400 Subject: [PATCH 5/6] default OPACITY --- .env.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.template b/.env.template index a7f6dd3..3fc5e13 100644 --- a/.env.template +++ b/.env.template @@ -12,4 +12,4 @@ THEME="" SUBREDDIT="" # Range is 0 -> 1 -OPACITY="" \ No newline at end of file +OPACITY=".9" From b9ffdd186d1638da22d9d725a320afd5e795047c Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 16:09:26 +0100 Subject: [PATCH 6/6] Added a zero to make it clearer to users --- .env.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.template b/.env.template index 3fc5e13..cab265e 100644 --- a/.env.template +++ b/.env.template @@ -12,4 +12,4 @@ THEME="" SUBREDDIT="" # Range is 0 -> 1 -OPACITY=".9" +OPACITY="0.9"