From 5cfda324cb8a6766fd9bfc6ba45ecc49e32600b2 Mon Sep 17 00:00:00 2001 From: Domiziano Scarcelli Date: Sat, 4 Jun 2022 12:22:40 +0200 Subject: [PATCH 01/11] Comments can be filtered by lenght --- .env.template | 5 +++++ reddit/subreddit.py | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.env.template b/.env.template index 5ab4ae4..bd2cbe4 100644 --- a/.env.template +++ b/.env.template @@ -9,3 +9,8 @@ REDDIT_2FA="" THEME="" SUBREDDIT="" + +# Filters the comments by range of lenght (min and max characters) +# Min has to be less or equal to max +# DO NOT INSERT ANY SPACES BETWEEN THE COMMA AND THE VALUES +COMMENT_LENGHT_RANGE = "min,max" \ No newline at end of file diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 5d020fe..5212375 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -1,3 +1,4 @@ +from numpy import Infinity from utils.console import print_markdown, print_step, print_substep import praw import random @@ -58,13 +59,17 @@ def get_subreddit_threads(): content["comments"] = [] for top_level_comment in submission.comments: - content["comments"].append( - { - "comment_body": top_level_comment.body, - "comment_url": top_level_comment.permalink, - "comment_id": top_level_comment.id, - } - ) + COMMENT_LENGHT_RANGE = [0, Infinity] + if os.getenv("COMMENT_LENGHT_RANGE"): + COMMENT_LENGHT_RANGE = [int(i) for i in os.getenv("COMMENT_LENGHT_RANGE").split(",")] + if COMMENT_LENGHT_RANGE[0] <= len(top_level_comment.body) <= COMMENT_LENGHT_RANGE[1]: + content["comments"].append( + { + "comment_body": top_level_comment.body, + "comment_url": top_level_comment.permalink, + "comment_id": top_level_comment.id, + } + ) except AttributeError as e: pass From 8c8b344881cf6847d6c1c9410e06d30e610f44c2 Mon Sep 17 00:00:00 2001 From: Domiziano Scarcelli Date: Sat, 4 Jun 2022 12:31:35 +0200 Subject: [PATCH 02/11] Typo correction --- reddit/subreddit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 5212375..30f6b2f 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -59,10 +59,10 @@ def get_subreddit_threads(): content["comments"] = [] for top_level_comment in submission.comments: - COMMENT_LENGHT_RANGE = [0, Infinity] - if os.getenv("COMMENT_LENGHT_RANGE"): - COMMENT_LENGHT_RANGE = [int(i) for i in os.getenv("COMMENT_LENGHT_RANGE").split(",")] - if COMMENT_LENGHT_RANGE[0] <= len(top_level_comment.body) <= COMMENT_LENGHT_RANGE[1]: + COMMENT_LENGTH_RANGE = [0, Infinity] + if os.getenv("COMMENT_LENGTH_RANGE"): + COMMENT_LENGTH_RANGE = [int(i) for i in os.getenv("COMMENT_LENGTH_RANGE").split(",")] + if COMMENT_LENGTH_RANGE[0] <= len(top_level_comment.body) <= COMMENT_LENGTH_RANGE[1]: content["comments"].append( { "comment_body": top_level_comment.body, From 0b161932ea0c5219ac8c7bc0957e78653abb1153 Mon Sep 17 00:00:00 2001 From: Domiziano Scarcelli Date: Sat, 4 Jun 2022 12:56:18 +0200 Subject: [PATCH 03/11] Typo correction --- .env.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.template b/.env.template index bd2cbe4..c3f32dc 100644 --- a/.env.template +++ b/.env.template @@ -13,4 +13,4 @@ SUBREDDIT="" # Filters the comments by range of lenght (min and max characters) # Min has to be less or equal to max # DO NOT INSERT ANY SPACES BETWEEN THE COMMA AND THE VALUES -COMMENT_LENGHT_RANGE = "min,max" \ No newline at end of file +COMMENT_LENGTH_RANGE = "min,max" \ No newline at end of file From 20f087ea930e3e0a00811a487592b048d5950dec Mon Sep 17 00:00:00 2001 From: Domiziano Scarcelli Date: Sun, 5 Jun 2022 20:20:35 +0200 Subject: [PATCH 04/11] Merge conficts --- .env.template | 8 -------- reddit/subreddit.py | 19 ++++++++----------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/.env.template b/.env.template index 3c38548..7ae0ac6 100644 --- a/.env.template +++ b/.env.template @@ -16,10 +16,6 @@ THEME="" # Enter a subreddit, e.g. "AskReddit" SUBREDDIT="" -<<<<<<< HEAD -======= - ->>>>>>> b5393694ca852b5b29d6acb7779af1efd2f345db # Filters the comments by range of lenght (min and max characters) # Min has to be less or equal to max # DO NOT INSERT ANY SPACES BETWEEN THE COMMA AND THE VALUES @@ -27,7 +23,3 @@ COMMENT_LENGTH_RANGE = "min,max" # Range is 0 -> 1 OPACITY="0.9" -<<<<<<< HEAD -======= - ->>>>>>> b5393694ca852b5b29d6acb7779af1efd2f345db diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 190dc8a..a84dffc 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -66,21 +66,18 @@ def get_subreddit_threads(): content["comments"] = [] for top_level_comment in submission.comments: -<<<<<<< HEAD COMMENT_LENGTH_RANGE = [0, Infinity] if os.getenv("COMMENT_LENGTH_RANGE"): COMMENT_LENGTH_RANGE = [int(i) for i in os.getenv("COMMENT_LENGTH_RANGE").split(",")] if COMMENT_LENGTH_RANGE[0] <= len(top_level_comment.body) <= COMMENT_LENGTH_RANGE[1]: -======= - if not top_level_comment.stickied: ->>>>>>> upstream/master - content["comments"].append( - { - "comment_body": top_level_comment.body, - "comment_url": top_level_comment.permalink, - "comment_id": top_level_comment.id, - } - ) + if not top_level_comment.stickied: + content["comments"].append( + { + "comment_body": top_level_comment.body, + "comment_url": top_level_comment.permalink, + "comment_id": top_level_comment.id, + } + ) except AttributeError as e: pass From b5c6e8f60b0fef48d950ac84c0edb2b3d36e3472 Mon Sep 17 00:00:00 2001 From: Domiziano Scarcelli Date: Mon, 6 Jun 2022 11:11:44 +0200 Subject: [PATCH 05/11] 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 06/11] 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 2234a5c973677c51e177f99648e5e781a4754034 Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Tue, 7 Jun 2022 13:03:29 +0300 Subject: [PATCH 07/11] fixed image hyperlink --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 56f4581..8b06174 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,11 @@ All done WITHOUT video editing or asset compiling. Just pure ✨programming magi Created by Lewis Menelaws & [TMRRW](https://tmrrwinc.ca) -[ - +[ -](https://tmrrwinc.ca) +](https://tmrrwinc.ca) ## Motivation 🤔 @@ -35,7 +34,7 @@ These videos on TikTok, YouTube and Instagram get MILLIONS of views across all p 2. Run `pip3 install -r requirements.txt` 3. Run `playwright install` and `playwright install-deps`. -4. +4. 4a **Automatic Install**: Run `python3 main.py` and type 'yes' to activate the setup assistant. 4b **Manual Install**: Rename `.env.template` to `.env` and replace all values with the appropriate fields. To get Reddit keys (**required**), visit [the Reddit Apps page.](https://www.reddit.com/prefs/apps) TL;DR set up an app that is a "script". Copy your keys into the `.env` file, along with whether your account uses two-factor authentication. From afd89a7ef82490f6e56d4fc64fbe623c231c730a Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Tue, 7 Jun 2022 13:06:01 +0300 Subject: [PATCH 08/11] merge conflict --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b06174..30723ca 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ These videos on TikTok, YouTube and Instagram get MILLIONS of views across all p 1. Clone this repository 2. Run `pip3 install -r requirements.txt` -3. Run `playwright install` and `playwright install-deps`. +3. Run `python3 -m playwright install` and `python3 -m playwright install-deps`. 4. 4a **Automatic Install**: Run `python3 main.py` and type 'yes' to activate the setup assistant. From 914f8679ae9a4a9ccf745b1f1e575b27a526ce6f Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Tue, 7 Jun 2022 13:06:54 +0300 Subject: [PATCH 09/11] merge conflict --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30723ca..8596ee7 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ These videos on TikTok, YouTube and Instagram get MILLIONS of views across all p 2. Run `pip3 install -r requirements.txt` 3. Run `python3 -m playwright install` and `python3 -m playwright install-deps`. -4. +4. 4a **Automatic Install**: Run `python3 main.py` and type 'yes' to activate the setup assistant. 4b **Manual Install**: Rename `.env.template` to `.env` and replace all values with the appropriate fields. To get Reddit keys (**required**), visit [the Reddit Apps page.](https://www.reddit.com/prefs/apps) TL;DR set up an app that is a "script". Copy your keys into the `.env` file, along with whether your account uses two-factor authentication. From 50cca3183d252d44230360161dbe913c93c39174 Mon Sep 17 00:00:00 2001 From: Phlipde <65417693+Phlipde@users.noreply.github.com> Date: Tue, 7 Jun 2022 18:45:18 +0200 Subject: [PATCH 10/11] Removed "Click to see nsfw" Button in Screenshot --- video_creation/screenshot_downloader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index 2925daa..d1f5719 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -38,6 +38,7 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme): print_substep("Post is NSFW. You are spicy...") page.locator('[data-testid="content-gate"] button').click() + page.locator('[data-click-id="text"] button').click() # Remove "Click to see nsfw" Button in Screenshot page.locator('[data-test-id="post-content"]').screenshot( path="assets/png/title.png" From 5bf088846028fa479863311ab576057d0c1336a1 Mon Sep 17 00:00:00 2001 From: Domiziano Scarcelli Date: Wed, 8 Jun 2022 00:23:29 +0200 Subject: [PATCH 11/11] 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,