From c46ee59d9049164aeab3f2baa7665d892618e120 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Jul 2022 23:45:46 +0000 Subject: [PATCH 1/9] Bump botocore from 1.27.12 to 1.27.22 Bumps [botocore](https://github.com/boto/botocore) from 1.27.12 to 1.27.22. - [Release notes](https://github.com/boto/botocore/releases) - [Changelog](https://github.com/boto/botocore/blob/develop/CHANGELOG.rst) - [Commits](https://github.com/boto/botocore/compare/1.27.12...1.27.22) --- updated-dependencies: - dependency-name: botocore dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4cc217c..e01abce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ boto3==1.24.12 -botocore==1.27.12 +botocore==1.27.22 gTTS==2.2.4 moviepy==1.0.3 mutagen==1.45.1 From 237eaa4789fda3641279b32d09a05107325d69b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Jul 2022 23:45:48 +0000 Subject: [PATCH 2/9] Bump translators from 5.2.2 to 5.3.1 Bumps [translators](https://github.com/uliontse/translators) from 5.2.2 to 5.3.1. - [Release notes](https://github.com/uliontse/translators/releases) - [Commits](https://github.com/uliontse/translators/commits) --- updated-dependencies: - dependency-name: translators dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4cc217c..c33fd05 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,4 @@ python-dotenv==0.20.0 pytube==12.1.0 requests==2.28.1 rich==12.4.4 -translators==5.2.2 +translators==5.3.1 From 2e30c2e735e0e53ef880c2f705bd28603b507e79 Mon Sep 17 00:00:00 2001 From: Jarno Reynaert Date: Sun, 3 Jul 2022 02:27:25 +0200 Subject: [PATCH 3/9] Script uses removeprefix() which was only added in python 3.9 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bffbc8c..d863e7f 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The only original thing being done is the editing and gathering of all materials ## Requirements -- Python 3.7+ +- Python 3.9+ - Playwright (this should install automatically in installation) ## Installation 👩‍💻 From 31b09dca38193af5f9217cabdec90e14c3b1ba74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhammed=20Mustafa=20Ak=C5=9Fam?= Date: Sun, 3 Jul 2022 12:20:14 +0300 Subject: [PATCH 4/9] Update .env.template updated .env.template to match the regex --- .env.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.template b/.env.template index 7cf7cc2..77f2acf 100644 --- a/.env.template +++ b/.env.template @@ -14,7 +14,7 @@ REDDIT_CLIENT_SECRET="" #fFAGRNJru1FTz70BzhT3Zg REDDIT_USERNAME="" #asdfghjkl #EXPLANATION the username of your reddit account #RANGE 3:20 -#MATCH_REGEX [_0-9a-zA-Z]+$ +#MATCH_REGEX [-_0-9a-zA-Z]+$ #OOB_ERROR A username HAS to be between 3 and 20 characters REDDIT_PASSWORD="" #fFAGRNJru1FTz70BzhT3Zg From 7ee2297983175782d509760c2bb1782607349153 Mon Sep 17 00:00:00 2001 From: CordlessCoder <42666308+CordlessCoder@users.noreply.github.com> Date: Sun, 3 Jul 2022 14:09:55 +0300 Subject: [PATCH 5/9] Fix installation guide --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bffbc8c..6e97228 100644 --- a/README.md +++ b/README.md @@ -38,15 +38,13 @@ The only original thing being done is the editing and gathering of all materials ## Installation 👩‍💻 1. Clone this repository -2. **Automatic Install**: Run `python main.py` and type 'yes' to activate the setup assistant. +2. Run `pip install -r requirements.txt` -3. Run `pip install -r requirements.txt` +3. Run `playwright install` and `playwright install-deps`. (if this fails try adding python -m to the front of the command) -4. Run `playwright install` and `playwright install-deps`. (if this fails try adding python -m to the front of the command) - -5. Run `python main.py` (unless you chose automatic install, then the installer will automatically run main.py) +4. Run `python main.py` required\*\*), visit [the Reddit Apps page.](https://www.reddit.com/prefs/apps) TL;DR set up an app that is a "script". -6. Enjoy 😎 +5. Enjoy 😎 (Note if you got an error installing or running the bot try first rerunning the command with a three after the name e.g. python3 or pip3) From 708016c5839250dc064d65708a57181c3ef0aec6 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sun, 3 Jul 2022 17:42:18 +0100 Subject: [PATCH 6/9] fix: mutagen error - moved to moviepy duration --- TTS/engine_wrapper.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index a06b4b9..692cfdc 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -94,11 +94,12 @@ class TTSEngine: def call_tts(self, filename: str, text: str): self.tts_module.run(text=process_text(text), filepath=f"{self.path}/{filename}.mp3") - try: - self.length += MP3(f"{self.path}/{filename}.mp3").info.length - except (MutagenError, HeaderNotFoundError): - self.length += sox.file_info.duration(f"{self.path}/{filename}.mp3") - + # try: + # self.length += MP3(f"{self.path}/{filename}.mp3").info.length + # except (MutagenError, HeaderNotFoundError): + # self.length += sox.file_info.duration(f"{self.path}/{filename}.mp3") + clip = AudioFileClip(f"{self.path}/{filename}.mp3") + self.length += clip.duration def process_text(text: str): lang = getenv("POSTLANG", "") new_text = sanitize_text(text) From edf981ac399763a5e1d34ca5642bc7af5c9bedd5 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sun, 3 Jul 2022 18:12:11 +0100 Subject: [PATCH 7/9] chore: reduce code duplication --- video_creation/final_video.py | 47 ++++++++++++----------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 81b9b98..23876ed 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -61,41 +61,26 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict): # add title to video image_clips = [] # Gather all images - if opacity is None or float(opacity) >= 1: # opacity not set or is set to one OR MORE - image_clips.insert( - 0, - ImageClip("assets/temp/png/title.png") - .set_duration(audio_clips[0].duration) - .set_position("center") - .resize(width=W - 100), - ) - else: - image_clips.insert( - 0, - ImageClip("assets/temp/png/title.png") - .set_duration(audio_clips[0].duration) + new_opacity = 1 if opacity is None or float(opacity) >= 1 else opacity + + image_clips.insert( + 0, + ImageClip("assets/temp/png/title.png") + .set_duration(audio_clips[0].duration) + .set_position("center") + .resize(width=W - 100) + .set_opacity(new_opacity) + ) + + for i in range(0, number_of_clips): + image_clips.append( + ImageClip(f"assets/temp/png/comment_{i}.png") + .set_duration(audio_clips[i + 1].duration) .set_position("center") .resize(width=W - 100) - .set_opacity(float(opacity)), + .set_opacity(new_opacity) ) - for i in range(0, number_of_clips): - if opacity is None or float(opacity) >= 1: # opacity not set or is set to one OR MORE - image_clips.append( - ImageClip(f"assets/temp/png/comment_{i}.png") - .set_duration(audio_clips[i + 1].duration) - .set_position("center") - .resize(width=W - 100), - ) - else: - image_clips.append( - ImageClip(f"assets/temp/png/comment_{i}.png") - .set_duration(audio_clips[i + 1].duration) - .set_position("center") - .resize(width=W - 100) - .set_opacity(float(opacity)), - ) - # if os.path.exists("assets/mp3/posttext.mp3"): # image_clips.insert( # 0, From 11de0fd3240aeff30d4e0ccd9a4ef735c20a98d8 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sun, 3 Jul 2022 18:47:35 +0100 Subject: [PATCH 8/9] fix: length checker works with new duration code --- TTS/engine_wrapper.py | 7 ++++--- main.py | 3 ++- video_creation/final_video.py | 11 ++--------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index 692cfdc..77f6eab 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -4,9 +4,9 @@ from typing import Tuple import re from os import getenv -import sox -from mutagen import MutagenError -from mutagen.mp3 import MP3, HeaderNotFoundError +# import sox +# from mutagen import MutagenError +# from mutagen.mp3 import MP3, HeaderNotFoundError import translators as ts from rich.progress import track from moviepy.editor import AudioFileClip, CompositeAudioClip, concatenate_audioclips @@ -100,6 +100,7 @@ class TTSEngine: # self.length += sox.file_info.duration(f"{self.path}/{filename}.mp3") clip = AudioFileClip(f"{self.path}/{filename}.mp3") self.length += clip.duration + def process_text(text: str): lang = getenv("POSTLANG", "") new_text = sanitize_text(text) diff --git a/main.py b/main.py index 81bec26..e362aad 100755 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ #!/usr/bin/env python - +import math from subprocess import Popen from os import getenv, name from dotenv import load_dotenv @@ -35,6 +35,7 @@ def main(POST_ID=None): cleanup() reddit_object = get_subreddit_threads(POST_ID) length, number_of_comments = save_text_to_mp3(reddit_object) + length = math.ceil(length) download_screenshots_of_reddit_posts(reddit_object, number_of_comments) download_background() chop_background_video(length) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 852c4b2..418254c 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -3,7 +3,6 @@ import multiprocessing import os import re from os.path import exists - from moviepy.editor import ( VideoFileClip, AudioFileClip, @@ -49,13 +48,7 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict[str]): audio_concat = concatenate_audioclips(audio_clips) audio_composite = CompositeAudioClip([audio_concat]) - # Get sum of all clip lengths - total_length = sum([clip.duration for clip in audio_clips]) - # round total_length to an integer - int_total_length = round(total_length) - # Output Length - - console.log(f"[bold green] Video Will Be: {int_total_length} Seconds Long") + console.log(f"[bold green] Video Will Be: {length} Seconds Long") # add title to video image_clips = [] # Gather all images @@ -127,7 +120,7 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict[str]): threads=multiprocessing.cpu_count(), ) ffmpeg_tools.ffmpeg_extract_subclip( - "assets/temp/temp.mp4", 0, length, targetname=f"results/{subreddit}/{filename}" + "assets/temp/temp.mp4", 0, final.duration, targetname=f"results/{subreddit}/{filename}" ) # os.remove("assets/temp/temp.mp4") From 6412aa546b7cb3f87da0408f95c60306d66be171 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Mon, 4 Jul 2022 00:07:17 +0100 Subject: [PATCH 9/9] fix: add float cast to opacity to fix bug --- 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 23876ed..3e1f52e 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -61,7 +61,7 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict): # add title to video image_clips = [] # Gather all images - new_opacity = 1 if opacity is None or float(opacity) >= 1 else opacity + new_opacity = 1 if opacity is None or float(opacity) >= 1 else float(opacity) image_clips.insert( 0,