fixed the pull request

pull/280/head
iaacornus 3 years ago
parent c3aff9d1d0
commit 422eb38b0b
No known key found for this signature in database
GPG Key ID: 281739AE7252598C

@ -9,6 +9,7 @@ from utils.console import print_step, print_substep
def get_subreddit_threads(subreddit_): def get_subreddit_threads(subreddit_):
global submission
""" """
Takes subreddit_ as parameter which defaults to None, but in this Takes subreddit_ as parameter which defaults to None, but in this
case since it is None, it would raise ValueError, thus defaulting case since it is None, it would raise ValueError, thus defaulting
@ -62,6 +63,7 @@ def get_subreddit_threads(subreddit_):
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,

@ -1,4 +1,5 @@
import os import os
import re
from dotenv import load_dotenv from dotenv import load_dotenv
from moviepy.editor import ( from moviepy.editor import (
@ -11,6 +12,7 @@ from moviepy.editor import (
CompositeVideoClip, CompositeVideoClip,
) )
import reddit.subreddit
from utils.console import print_step from utils.console import print_step
@ -18,11 +20,11 @@ W, H = 1080, 1920
def make_final_video(number_of_clips): def make_final_video(number_of_clips):
# Calls opacity from the .env
load_dotenv()
opacity = os.getenv("OPACITY")
# Calls opacity from the .env
load_dotenv()
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)
@ -34,7 +36,7 @@ def make_final_video(number_of_clips):
) )
try: try:
float(os.getenv("OPACITY")) opacity = float(os.getenv("OPACITY"))
except: except:
print(f"Please ensure that OPACITY is set between 0 and 1 in your .env file") print(f"Please ensure that OPACITY is set between 0 and 1 in your .env file")
configured = False configured = False
@ -56,7 +58,7 @@ def make_final_video(number_of_clips):
.set_duration(audio_clips[i + 1].duration) .set_duration(audio_clips[i + 1].duration)
.set_position("center") .set_position("center")
.resize(width=W - 100) .resize(width=W - 100)
.set_opacity(float(opacity)), .set_opacity(opacity),
) )
image_clips.insert( image_clips.insert(
@ -65,16 +67,16 @@ def make_final_video(number_of_clips):
.set_duration(audio_clips[0].duration) .set_duration(audio_clips[0].duration)
.set_position("center") .set_position("center")
.resize(width=W - 100) .resize(width=W - 100)
.set_opacity(float(opacity)), .set_opacity(opacity),
) )
image_concat = concatenate_videoclips(image_clips).set_position( image_concat = concatenate_videoclips(image_clips).set_position(
("center", "center") ("center", "center")
) )
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 = (
"assets/final_video.mp4", fps=30, audio_codec="aac", audio_bitrate="192k" 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): for i in range(0, number_of_clips):
pass pass

Loading…
Cancel
Save