Merge branch 'develop' into fix/moviepy-length-checker

pull/830/head
Callum Leslie 3 years ago committed by GitHub
commit 3b51d084e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -32,21 +32,19 @@ 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 👩‍💻
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)

@ -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
@ -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

@ -2,6 +2,7 @@ import json
import os
import time
from os import getenv
from typing import Dict
from praw.models import Submission
@ -9,18 +10,17 @@ from utils.console import print_step
def check_done(
redditobj: dict[str],
redditobj: Submission,
) -> Submission:
# don't set this to be run anyplace that isn't subreddit.py bc of inspect stack
"""Checks if the chosen post has already been generated
Args:
redditobj (dict[str]): Reddit object gotten from reddit/subreddit.py
redditobj (Dict[str]): Reddit object gotten from reddit/subreddit.py
Returns:
dict[str]|None: Reddit object in args
Dict[str]|None: Reddit object in args
"""
with open("./video_creation/data/videos.json", "r", encoding="utf-8") as done_vids_raw:
done_videos = json.load(done_vids_raw)
for video in done_videos:

@ -3,6 +3,8 @@ import multiprocessing
import os
import re
from os.path import exists
from typing import Dict
from moviepy.editor import (
VideoFileClip,
AudioFileClip,
@ -24,12 +26,13 @@ console = Console()
W, H = 1080, 1920
def make_final_video(number_of_clips: int, length: int, reddit_obj: dict[str]):
def make_final_video(number_of_clips: int, length: int, reddit_obj: dict):
"""Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp
Args:
number_of_clips (int): Index to end at when going through the screenshots
length (int): Length of the video
reddit_obj (dict): The reddit object that contains the posts to read.
"""
print_step("Creating the final video 🎥")
VideoFileClip.reW = lambda clip: clip.resize(width=W)
@ -52,41 +55,26 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict[str]):
# 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,

@ -2,6 +2,7 @@ import json
import os
from os import getenv
from pathlib import Path
from typing import Dict
from playwright.async_api import async_playwright # pylint: disable=unused-import
@ -16,14 +17,13 @@ from utils.console import print_step, print_substep
storymode = False
def download_screenshots_of_reddit_posts(reddit_object: dict[str], screenshot_num: int):
def download_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
"""Downloads screenshots of reddit posts as seen on the web. Downloads to assets/temp/png
Args:
reddit_object (dict[str]): Reddit object received from reddit/subreddit.py
reddit_object (Dict[str]): Reddit object received from reddit/subreddit.py
screenshot_num (int): Number of screenshots to downlaod
"""
print_step("Downloading screenshots of reddit posts...")
# ! Make sure the reddit screenshots folder exists

@ -1,6 +1,7 @@
#!/usr/bin/env python
import os
from typing import Dict, Tuple
from rich.console import Console
@ -23,7 +24,7 @@ TTSProviders = {
}
def save_text_to_mp3(reddit_obj: dict[str]) -> tuple[int, int]:
def save_text_to_mp3(reddit_obj) -> Tuple[int, int]:
"""Saves text to MP3 files.
Args:

Loading…
Cancel
Save