From 21c8da3648cb1024448f35cd6b6f51b6370d82f2 Mon Sep 17 00:00:00 2001 From: Kamushy <92086533+Kamushy@users.noreply.github.com> Date: Thu, 2 Jun 2022 21:57:32 +1000 Subject: [PATCH 01/25] Made submission global --- reddit/askreddit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reddit/askreddit.py b/reddit/askreddit.py index 7c7110a..21b2277 100644 --- a/reddit/askreddit.py +++ b/reddit/askreddit.py @@ -4,8 +4,8 @@ import random from dotenv import load_dotenv import os - def get_askreddit_threads(): + global submission """ Returns a list of threads from the AskReddit subreddit. """ From 9bb1aa351e222d10308ab16baacaea43575278b7 Mon Sep 17 00:00:00 2001 From: Kamushy <92086533+Kamushy@users.noreply.github.com> Date: Thu, 2 Jun 2022 22:00:24 +1000 Subject: [PATCH 02/25] made name change correctly line 59 is if any of characters cant be turned into a file remove them --- video_creation/final_video.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 947ab04..25f80f0 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -7,6 +7,8 @@ from moviepy.editor import ( CompositeAudioClip, CompositeVideoClip, ) +import reddit.askreddit +import re from utils.console import print_step @@ -14,6 +16,7 @@ W, H = 1080, 1920 def make_final_video(number_of_clips): + global submission print_step("Creating the final video 🎥") VideoFileClip.reW = lambda clip: clip.resize(width=W) VideoFileClip.reH = lambda clip: clip.resize(width=H) @@ -53,9 +56,7 @@ def make_final_video(number_of_clips): ) image_concat.audio = audio_composite final = CompositeVideoClip([background_clip, image_concat]) - final.write_videofile( - "assets/final_video.mp4", fps=30, audio_codec="aac", audio_bitrate="192k" - ) - + filename = (re.sub('[?\"/%*:|<>]', '', ("assets/" + reddit.askreddit.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 93bcd7be772d565be7e893f336fe5a4e3cce107d Mon Sep 17 00:00:00 2001 From: Kamushy <92086533+Kamushy@users.noreply.github.com> Date: Thu, 2 Jun 2022 22:57:02 +1000 Subject: [PATCH 03/25] file will now go to correct folder --- 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 25f80f0..f711568 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -56,7 +56,7 @@ def make_final_video(number_of_clips): ) image_concat.audio = audio_composite final = CompositeVideoClip([background_clip, image_concat]) - filename = (re.sub('[?\"/%*:|<>]', '', ("assets/" + reddit.askreddit.submission.title + ".mp4"))) + filename = (re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.askreddit.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 bed5dd2ab2737735ff24fb9b9523382c2429e40b Mon Sep 17 00:00:00 2001 From: Kamushy <92086533+Kamushy@users.noreply.github.com> Date: Fri, 3 Jun 2022 09:18:05 +1000 Subject: [PATCH 04/25] Made ENV make more sense A couple were submitting links into the subreddit field --- .env.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.template b/.env.template index f00c2ac..033c9d9 100644 --- a/.env.template +++ b/.env.template @@ -6,5 +6,5 @@ REDDIT_PASSWORD="" # Valid options are "yes" and "no" for the variable below REDDIT_2FA="" - +# Enter a subreddit, e.g. "AskReddit" or "r/AskReddit" SUBREDDIT="" From 757768be151e250390e4ff78dcfa82897f5fe6be Mon Sep 17 00:00:00 2001 From: Kamushy <92086533+Kamushy@users.noreply.github.com> Date: Fri, 3 Jun 2022 11:50:54 +1000 Subject: [PATCH 05/25] Making it work with newer code version --- reddit/askreddit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/reddit/askreddit.py b/reddit/askreddit.py index 21b2277..78ec481 100644 --- a/reddit/askreddit.py +++ b/reddit/askreddit.py @@ -5,7 +5,6 @@ from dotenv import load_dotenv import os def get_askreddit_threads(): - global submission """ Returns a list of threads from the AskReddit subreddit. """ From 8546deac7d93cdda847e5941523320161533d645 Mon Sep 17 00:00:00 2001 From: Kamushy Date: Fri, 3 Jun 2022 11:59:36 +1000 Subject: [PATCH 06/25] Added it back Have no idea how do this --- reddit/askreddit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/reddit/askreddit.py b/reddit/askreddit.py index 78ec481..21b2277 100644 --- a/reddit/askreddit.py +++ b/reddit/askreddit.py @@ -5,6 +5,7 @@ from dotenv import load_dotenv import os def get_askreddit_threads(): + global submission """ Returns a list of threads from the AskReddit subreddit. """ From ccd0c60d874a97c0f0d0a092c8412c38e33967b7 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 00:31:56 +0100 Subject: [PATCH 07/25] Add default values for environment variables This should reduce errors by some values not being set in the .env file - namely 2FA and Theme --- main.py | 2 +- reddit/subreddit.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 8cc3c9a..57256df 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,7 @@ reddit_object = get_subreddit_threads() load_dotenv() length, number_of_comments = save_text_to_mp3(reddit_object) -download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME")) +download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME", "light")) download_background() chop_background_video(length) final_video = make_final_video(number_of_comments) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 5d020fe..c7714ce 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -15,7 +15,7 @@ def get_subreddit_threads(): print_step("Getting AskReddit threads...") - if os.getenv("REDDIT_2FA").lower() == "yes": + if os.getenv("REDDIT_2FA", default="no").lower() == "yes": print( "\nEnter your two-factor authentication code from your authenticator app.\n" ) From f05eff4f88402b53c1dc919c6e793dea628c3da3 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 01:30:10 +0100 Subject: [PATCH 08/25] Alert user if their .env is not configured properly --- main.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 57256df..dff9645 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,13 @@ from utils.console import print_markdown -import time - from reddit.subreddit import get_subreddit_threads from video_creation.background import download_background, chop_background_video from video_creation.voices import save_text_to_mp3 from video_creation.screenshot_downloader import download_screenshots_of_reddit_posts from video_creation.final_video import make_final_video from dotenv import load_dotenv -import os +import os, time + +REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD"] 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." @@ -15,10 +15,17 @@ print_markdown( time.sleep(3) +load_dotenv() -reddit_object = get_subreddit_threads() +configured = True -load_dotenv() +for val in REQUIRED_VALUES: + if val not in os.environ or not os.getenv(val): + print(f"Please set the variable \"{val}\" in your .env file.") + configured = False + +if configured: +reddit_object = get_subreddit_threads() length, number_of_comments = save_text_to_mp3(reddit_object) download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME", "light")) download_background() From 87d211281220ea529e6b48008e884a2adb7cd5f9 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 01:40:55 +0100 Subject: [PATCH 09/25] Move to casefold --- reddit/subreddit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index c7714ce..c64db2b 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -15,7 +15,7 @@ def get_subreddit_threads(): print_step("Getting AskReddit threads...") - if os.getenv("REDDIT_2FA", default="no").lower() == "yes": + if os.getenv("REDDIT_2FA", default="no").casefold() == "yes": print( "\nEnter your two-factor authentication code from your authenticator app.\n" ) From 3a7d91f474de5bbfdab0113b8479b0378949c943 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 01:41:48 +0100 Subject: [PATCH 10/25] Create a .env file if none exists on run Should fix issues users have with creating their own .env file, by simply copying our template to a file for them. --- main.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index dff9645..b813c01 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ from video_creation.voices import save_text_to_mp3 from video_creation.screenshot_downloader import download_screenshots_of_reddit_posts from video_creation.final_video import make_final_video from dotenv import load_dotenv -import os, time +import os, time, shutil REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD"] @@ -19,15 +19,19 @@ load_dotenv() configured = True +if not os.path.exists(".env"): + shutil.copy(".env.template", ".env") + configured = False + for val in REQUIRED_VALUES: if val not in os.environ or not os.getenv(val): print(f"Please set the variable \"{val}\" in your .env file.") configured = False if configured: -reddit_object = get_subreddit_threads() -length, number_of_comments = save_text_to_mp3(reddit_object) -download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME", "light")) -download_background() -chop_background_video(length) -final_video = make_final_video(number_of_comments) + reddit_object = get_subreddit_threads() + length, number_of_comments = save_text_to_mp3(reddit_object) + download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME", "light")) + download_background() + chop_background_video(length) + final_video = make_final_video(number_of_comments) From d39386178b254f7bb86837c728fec20cb1dd52de Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 01:53:34 +0100 Subject: [PATCH 11/25] Clean up imports --- reddit/subreddit.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 5d020fe..95d26e7 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -1,8 +1,6 @@ from utils.console import print_markdown, print_step, print_substep -import praw -import random from dotenv import load_dotenv -import os +import os, random, praw, re def get_subreddit_threads(): From cd5924562f021fcd95c8313cf9b8ee5cfc01185c Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 01:57:09 +0100 Subject: [PATCH 12/25] Ignore r/ in subreddit names --- reddit/subreddit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 95d26e7..e1be0c3 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -40,7 +40,7 @@ def get_subreddit_threads(): # ! Prompt the user to enter a subreddit try: subreddit = reddit.subreddit( - input("What subreddit would you like to pull from? ") + re.sub(r"r\/", "", input("What subreddit would you like to pull from? ")) ) except ValueError: subreddit = reddit.subreddit("askreddit") From 37f22b8b018dd85d3b8db1b4fa9df282a55133cc Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 02:00:19 +0100 Subject: [PATCH 13/25] Ignore r/ in environment subreddit names --- reddit/subreddit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index e1be0c3..32bcba3 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -35,7 +35,7 @@ def get_subreddit_threads(): ) if os.getenv("SUBREDDIT"): - subreddit = reddit.subreddit(os.getenv("SUBREDDIT")) + subreddit = reddit.subreddit(re.sub(r"r\/", "", os.getenv("SUBREDDIT"))) else: # ! Prompt the user to enter a subreddit try: From d3b288008fbe1f67f9fcddcbf17783493f339ddf Mon Sep 17 00:00:00 2001 From: Kamushy <92086533+Kamushy@users.noreply.github.com> Date: Sat, 4 Jun 2022 11:03:13 +1000 Subject: [PATCH 14/25] Changed function name to match new version --- reddit/subreddit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 09f4477..1f49152 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -4,7 +4,7 @@ import random from dotenv import load_dotenv import os -def get_askreddit_threads(): +def get_subreddit_threads(): global submission """ Returns a list of threads from the AskReddit subreddit. From 367105fb2dd33cdbf1ae6730036509d82e00531e Mon Sep 17 00:00:00 2001 From: Kamushy <92086533+Kamushy@users.noreply.github.com> Date: Sat, 4 Jun 2022 11:04:30 +1000 Subject: [PATCH 15/25] Changed file import name and resolved conflicts --- 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 ba169f0..366f61d 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -7,7 +7,7 @@ from moviepy.editor import ( CompositeAudioClip, CompositeVideoClip, ) -import reddit.askreddit +import reddit.subreddit import re from utils.console import print_step @@ -58,7 +58,7 @@ def make_final_video(number_of_clips): ) image_concat.audio = audio_composite final = CompositeVideoClip([background_clip, image_concat]) - filename = (re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.askreddit.submission.title + ".mp4"))) + 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 03f96e7a89780fb3ec8d8df16ff9653fa6cfed79 Mon Sep 17 00:00:00 2001 From: Luka Hietala <95122845+LukaHietala@users.noreply.github.com> Date: Sat, 4 Jun 2022 14:48:13 +0300 Subject: [PATCH 16/25] Fixed link to documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 10e84e9..dbb0250 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ These videos on TikTok, YouTube and Instagram get MILLIONS of views across all p 5. Run `python3 main.py` 6. Enjoy 😎 -If you want to see more detailed guide, please refer to the official [documentation](https://immaharry.gitbook.io/reddit-automated-video-bot/). +If you want to see more detailed guide, please refer to the official [documentation](https://luka-hietala.gitbook.io/documentation-for-the-reddit-bot/). *The Documentation is still being developed and worked on, please be patient as we change / add new knowledge! ## Contributing & Ways to improve 📈 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 17/25] 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 18/25] 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 19/25] 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 20/25] 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 21/25] 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 22/25] 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" From 0dc32154f2ccce46daf1d5751a9d4f5426e6c5bc Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 16:16:02 +0100 Subject: [PATCH 23/25] Code was placed in the wrong place --- main.py | 6 ++++++ video_creation/final_video.py | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index fc12206..3bc6c83 100644 --- a/main.py +++ b/main.py @@ -30,6 +30,12 @@ for val in REQUIRED_VALUES: print(f"Please set the variable \"{val}\" in your .env file.") configured = False +try: + float(os.getenv("OPACITY")) +except: + print(f"Please ensure that OPACITY is set between 0 and 1 in your .env file") + configured = False + if configured: reddit_object = get_subreddit_threads() length, number_of_comments = save_text_to_mp3(reddit_object) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 0a2afb0..1933db3 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -30,11 +30,7 @@ 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 48688f18c642177cda0a9eb421ce0c3c126c0f42 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sat, 4 Jun 2022 16:19:58 +0100 Subject: [PATCH 24/25] Remove code duplication --- main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/main.py b/main.py index 3bc6c83..1b66e8c 100644 --- a/main.py +++ b/main.py @@ -7,8 +7,6 @@ from video_creation.final_video import make_final_video from dotenv import load_dotenv import os, time, shutil -REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD"] - REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD", "OPACITY"] print_markdown( From 211b03e7f5cc4e8c92778f50d80cf9e82f83790c Mon Sep 17 00:00:00 2001 From: null3000 <76852813+null3000@users.noreply.github.com> Date: Sun, 5 Jun 2022 00:31:59 +0200 Subject: [PATCH 25/25] stickied comments will no longer be used I made a video but it was taken up entirely by a post looking like this: https://imgur.com/a/1fwT94c This isn't a big deal because these serious tags are uncommon, but still a small annoyance. So I fixed it! In threads that are marked 'serious', there is an automatic stickied mod post. ex. (shorturl.at/I1346). My changes will skip any automatically stickied comments, so they won't make it into the final Video. --- reddit/subreddit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 1d47974..063b862 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -56,6 +56,7 @@ def get_subreddit_threads(): content["comments"] = [] for top_level_comment in submission.comments: + if not top_level_comment.stickied: content["comments"].append( { "comment_body": top_level_comment.body,