Update main.py

pull/311/head
null3000 3 years ago committed by GitHub
parent 12e967a7ce
commit e41ad649ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,64 +1,58 @@
# Main
from utils.console import print_markdown
from utils.console import print_step
from utils.console import print_substep
from rich.console import Console
import time
from reddit.subreddit import get_subreddit_threads
from video_creation.background import download_background, chop_background_video
from video_creation.voices import save_text_to_mp3
from video_creation.screenshot_downloader import download_screenshots_of_reddit_posts
from video_creation.final_video import make_final_video
from utils.loader import Loader
from dotenv import load_dotenv
import os, time, shutil
REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD", "OPACITY"]
banner = '''
console = Console()
from dotenv import load_dotenv
import os, time, shutil
'''
print(banner)
configured = True
REQUIRED_VALUES = [
"REDDIT_CLIENT_ID",
"REDDIT_CLIENT_SECRET",
"REDDIT_USERNAME",
"REDDIT_PASSWORD",
"OPACITY",
]
time.sleep(1.5)
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."
)
time.sleep(1)
"""
Load .env file if exists. If it doesnt exist, print a warning and launch the setup wizard.
If there is a .env file, check if the required variables are set. If not, print a warning and launch the setup wizard.
"""
client_id = os.getenv("REDDIT_CLIENT_ID")
client_secret = os.getenv("REDDIT_CLIENT_SECRET")
username = os.getenv("REDDIT_USERNAME")
password = os.getenv("REDDIT_PASSWORD")
reddit2fa = os.getenv("REDDIT_2FA")
load_dotenv()
configured = True
console.log("[bold green]Checking environment variables...")
time.sleep(1)
if not os.path.exists(".env"):
shutil.copy(".env.template", ".env")
configured = False
console.log("[red] Your .env file is invalid, or was never created. Standby.")
for val in REQUIRED_VALUES:
#print(os.getenv(val))
if val not in os.environ or not os.getenv(val):
print(f"Please set the variable \"{val}\" in your .env file.")
console.log(f'[bold red]Missing Variable: "{val}"')
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:
reddit_object = get_subreddit_threads()
length, number_of_comments = save_text_to_mp3(reddit_object)
download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME", "light"))
download_background()
chop_background_video(length)
final_video = make_final_video(number_of_comments)

Loading…
Cancel
Save