feat: added TFA auth

chore: overhauled the video download system.
feat: added progress bar and speed for video download
fix: fixed the evil file not found error!
feat: added a variable that allows you to make MULTIPLE videos not just one
feat: added a standardized viewport size for the screenshot downloader
notes: removed askreddit.py as it was not needed after subreddit.py redesign.
closes #26
fixes #38
fixes #32
fixes #31
fixes #30
fixes #22
fixes #21
fixes #17
fixes #14
pull/418/head
Jason 3 years ago
parent 25c198dff3
commit 293b34666a

@ -13,3 +13,4 @@ POST_ID=""
THEME="LIGHT"
# set to an int e.g. 1 or 29 and leave blank for once
TIMES_TO_RUN=""
MAX_COMMENT_LENGTH="500"

@ -1,24 +1,23 @@
import re
from utils.console import print_step, print_substep
import praw
import random
from dotenv import load_dotenv
from os import getenv, environ
import praw
from utils.console import print_step, print_substep
from utils.videos import check_done
TEXT_WHITELIST = set('abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890')
def textify(text):
return ''.join(filter(TEXT_WHITELIST.__contains__, text))
def get_subreddit_threads():
"""
Returns a list of threads from the AskReddit subreddit.
"""
global submission
print_step("Getting subreddit threads...")
content = {}
@ -50,8 +49,8 @@ def get_subreddit_threads():
threads = subreddit.hot(limit=25)
submission = list(threads)[random.randrange(0, 25)]
submission = check_done(submission)
if submission == None:
return get_subreddit_threads() # todo check
if submission is None:
return get_subreddit_threads() # submission already done. rerun
print_substep(f"Video will be: {submission.title} :thumbsup:")
print_substep(

@ -5,7 +5,6 @@ from random import randrange
from pytube import YouTube
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
from moviepy.editor import VideoFileClip
from rich.progress import Progress
from utils.console import print_step, print_substep
@ -30,15 +29,10 @@ def download_background():
background_options): # if there are any background videos not installed
print_step("We need to download the backgnrounds videos. they are fairly large but it's only done once. 😎")
print_substep("Downloading the backgrounds videos... please be patient 🙏 ")
with Progress() as progress:
download_task = progress.add_task("[green]Downloading...", total=2)
for uri, filename, credit in background_options:
print_substep(f"Downloading {filename} from {uri}")
YouTube(uri).streams.filter(res="1080p").first().download("assets/backgrounds",
filename=f"{credit}-{filename}")
progress.update(download_task, advance=1) # todo remove
for uri, filename, credit in background_options:
print_substep(f"Downloading {filename} from {uri}")
YouTube(uri).streams.filter(res="1080p").first().download("assets/backgrounds",
filename=f"{credit}-{filename}")
print_substep("Background videos downloaded successfully! 🎉", style="bold green")

@ -1,9 +1 @@
[
{
"id": "v2kd2q",
"time": "1654128204",
"background_credit": "bbswitzer",
"reddit_title": "What movie do you absolutely love yet acknowledge is not a super wellmade movie",
"filename": "What movie do you absolutely l....mp4"
}
]
[]

@ -4,8 +4,9 @@ import time
from os.path import exists
from moviepy.editor import VideoFileClip, AudioFileClip, ImageClip, concatenate_videoclips, concatenate_audioclips, CompositeAudioClip, CompositeVideoClip
from moviepy.video import io
from moviepy.video.io import ffmpeg_tools
from reddit import subreddit
from utils.cleanup import cleanup
from utils.console import print_step, print_substep
@ -18,7 +19,7 @@ def make_final_video(number_of_clips, length):
VideoFileClip.reH = lambda clip: clip.resize(width=H)
background_clip = (
VideoFileClip("assets/temp/backgrounds.mp4").without_audio().resize(height=H).crop(x1=1166.6, y1=0, x2=2246.6,
VideoFileClip("assets/temp/background.mp4").without_audio().resize(height=H).crop(x1=1166.6, y1=0, x2=2246.6,
y2=1920))
# Gather all audio clips
audio_clips = []
@ -52,7 +53,7 @@ def make_final_video(number_of_clips, length):
def save_data():
with open('./video_creation/data/videos.json', 'r+') as raw_vids:
done_vids = json.load(raw_vids)
if str(os.getenv("VIDEO_ID")) in [video['id'] for video in done_vids]:
if str(subreddit.submission.id) in [video['id'] for video in done_vids]:
return # video already done but was specified to continue anyway in the .env file
payload = {"id": str(os.getenv("VIDEO_ID")), 'time': str(int(time.time())),
"background_credit": str(os.getenv('background_credit')),
@ -66,9 +67,9 @@ def make_final_video(number_of_clips, length):
print_substep('the results folder didn\'t exist so I made it')
os.mkdir("./results")
final.write_videofile("temp.mp4", fps=30, audio_codec="aac", audio_bitrate="192k")
io.ffmpeg_tools.ffmpeg_extract_subclip("temp.mp4", 0, length, targetname=f"results/{filename}")
os.remove("temp.mp4")
final.write_videofile("assets/temp/temp.mp4", fps=30, audio_codec="aac", audio_bitrate="192k")
ffmpeg_tools.ffmpeg_extract_subclip("assets/temp/temp.mp4", 0, length, targetname=f"results/{filename}")
#os.remove("assets/temp/temp.mp4")
print_step("Removing temporary files 🗑")
cleanups = cleanup()

Loading…
Cancel
Save