Merge branch 'master' into master
This commit is contained in:
4 files changed
+39
-14
No files matched your search
+6
-2
@@ -2,10 +2,14 @@ REDDIT_CLIENT_ID=""
|
||||
REDDIT_CLIENT_SECRET=""
|
||||
REDDIT_USERNAME=""
|
||||
REDDIT_PASSWORD=""
|
||||
|
||||
# Valid options are "yes" and "no" for the variable below
|
||||
# Valid options are "yes" and "no"
|
||||
REDDIT_2FA=""
|
||||
|
||||
# Valid options are "light" and "dark"
|
||||
THEME=""
|
||||
|
||||
# Enter a subreddit, e.g. "AskReddit"
|
||||
SUBREDDIT=""
|
||||
|
||||
# Range is 0 -> 1
|
||||
OPACITY="0.9"
|
||||
@@ -14,8 +14,10 @@ from dotenv import load_dotenv
|
||||
console = Console()
|
||||
from dotenv import load_dotenv
|
||||
import os, time, shutil
|
||||
|
||||
configured = True
|
||||
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(
|
||||
"### 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."
|
||||
@@ -47,7 +49,6 @@ for val in REQUIRED_VALUES:
|
||||
if val not in os.environ or not os.getenv(val):
|
||||
console.log(f"[bold red]Missing Variable: \"{val}\"")
|
||||
configured = False
|
||||
|
||||
console.log("[red]Looks like you need to set your Reddit credentials in the .env file. Please follow the instructions in the README.md file to set them up.")
|
||||
time.sleep(0.5)
|
||||
console.log("[red]We can also launch the easy setup wizard. type yes to launch it, or no to quit the program.")
|
||||
@@ -68,9 +69,14 @@ for val in REQUIRED_VALUES:
|
||||
|
||||
|
||||
exit()
|
||||
|
||||
try:
|
||||
float(os.getenv("OPACITY"))
|
||||
except:
|
||||
console.log(f"[red]Please ensure that OPACITY is set between 0 and 1 in your .env file")
|
||||
configured = False
|
||||
exit()
|
||||
console.log("[bold green]Enviroment Variables are set! Continuing...")
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
load_dotenv()
|
||||
length, number_of_comments = save_text_to_mp3(reddit_object)
|
||||
@@ -79,6 +85,9 @@ download_background()
|
||||
chop_background_video(length)
|
||||
final_video = make_final_video(number_of_comments)
|
||||
|
||||
|
||||
|
||||
|
||||
if configured:
|
||||
reddit_object = get_subreddit_threads()
|
||||
length, number_of_comments = save_text_to_mp3(reddit_object)
|
||||
|
||||
+2
-1
@@ -4,7 +4,7 @@ from dotenv import load_dotenv
|
||||
console = Console()
|
||||
import os, random, praw, re
|
||||
def get_subreddit_threads():
|
||||
|
||||
global submission
|
||||
"""
|
||||
Returns a list of threads from the AskReddit subreddit.
|
||||
"""
|
||||
@@ -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,
|
||||
|
||||
@@ -7,14 +7,24 @@ from moviepy.editor import (
|
||||
CompositeAudioClip,
|
||||
CompositeVideoClip,
|
||||
)
|
||||
import reddit.subreddit
|
||||
import re
|
||||
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)
|
||||
|
||||
@@ -24,6 +34,7 @@ def make_final_video(number_of_clips):
|
||||
.resize(height=H)
|
||||
.crop(x1=1166.6, y1=0, x2=2246.6, y2=1920)
|
||||
)
|
||||
|
||||
# Gather all audio clips
|
||||
audio_clips = []
|
||||
for i in range(0, number_of_clips):
|
||||
@@ -39,23 +50,23 @@ 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")
|
||||
)
|
||||
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.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
|
||||
Reference in new issue
Block a user