The-Drobe 3 years ago
commit 7db73a54c1

@ -7,8 +7,6 @@ from video_creation.final_video import make_final_video
from dotenv import load_dotenv from dotenv import load_dotenv
import os, time, shutil 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"] REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD", "OPACITY"]
print_markdown( print_markdown(
@ -30,6 +28,12 @@ for val in REQUIRED_VALUES:
print(f"Please set the variable \"{val}\" in your .env file.") print(f"Please set the variable \"{val}\" in your .env file.")
configured = False 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: if configured:
reddit_object = get_subreddit_threads() reddit_object = get_subreddit_threads()
length, number_of_comments = save_text_to_mp3(reddit_object) length, number_of_comments = save_text_to_mp3(reddit_object)

@ -2,9 +2,8 @@ from utils.console import print_markdown, print_step, print_substep
from dotenv import load_dotenv from dotenv import load_dotenv
import os, random, praw, re import os, random, praw, re
def get_subreddit_threads(): def get_subreddit_threads():
global submission
""" """
Returns a list of threads from the AskReddit subreddit. Returns a list of threads from the AskReddit subreddit.
""" """
@ -56,6 +55,7 @@ def get_subreddit_threads():
content["comments"] = [] content["comments"] = []
for top_level_comment in submission.comments: for top_level_comment in submission.comments:
if not top_level_comment.stickied:
content["comments"].append( content["comments"].append(
{ {
"comment_body": top_level_comment.body, "comment_body": top_level_comment.body,

@ -7,6 +7,8 @@ from moviepy.editor import (
CompositeAudioClip, CompositeAudioClip,
CompositeVideoClip, CompositeVideoClip,
) )
import reddit.subreddit
import re
from utils.console import print_step from utils.console import print_step
from dotenv import load_dotenv from dotenv import load_dotenv
import os import os
@ -16,11 +18,13 @@ W, H = 1080, 1920
def make_final_video(number_of_clips): def make_final_video(number_of_clips):
# Calls opacity from the .env
# Calls opacity from the .env
load_dotenv() load_dotenv()
opacity = os.getenv('OPACITY') opacity = os.getenv('OPACITY')
print_step("Creating the final video...") print_step("Creating the final video...")
VideoFileClip.reW = lambda clip: clip.resize(width=W) VideoFileClip.reW = lambda clip: clip.resize(width=W)
VideoFileClip.reH = lambda clip: clip.resize(width=H) VideoFileClip.reH = lambda clip: clip.resize(width=H)
@ -30,11 +34,7 @@ def make_final_video(number_of_clips):
.resize(height=H) .resize(height=H)
.crop(x1=1166.6, y1=0, x2=2246.6, y2=1920) .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 # Gather all audio clips
audio_clips = [] audio_clips = []
for i in range(0, number_of_clips): for i in range(0, number_of_clips):
@ -66,9 +66,7 @@ def make_final_video(number_of_clips):
) )
image_concat.audio = audio_composite image_concat.audio = audio_composite
final = CompositeVideoClip([background_clip, image_concat]) final = CompositeVideoClip([background_clip, image_concat])
final.write_videofile( filename = (re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.subreddit.submission.title + ".mp4")))
"assets/final_video.mp4", fps=30, audio_codec="aac", audio_bitrate="192k" final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k")
)
for i in range(0, number_of_clips): for i in range(0, number_of_clips):
pass pass

Loading…
Cancel
Save