Merge branch 'master' into master

pull/125/head
BlockArchitech 3 years ago committed by GitHub
commit 7ab4ced43b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -43,7 +43,7 @@ These videos on TikTok, YouTube and Instagram get MILLIONS of views across all p
7. Enjoy 😎
If you want to see more detailed guide, please refer to the official [documentation](https://immaharry.gitbook.io/reddit-automated-video-bot/).
If you want to see more detailed guide, please refer to the official [documentation](https://luka-hietala.gitbook.io/documentation-for-the-reddit-bot/).
*The Documentation is still being developed and worked on, please be patient as we change / add new knowledge!
## Contributing & Ways to improve 📈

@ -4,7 +4,6 @@ from utils.console import print_step
from utils.console import print_substep
from rich.console import Console
import time
import os
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
@ -14,7 +13,10 @@ from utils.loader import Loader
from dotenv import load_dotenv
console = Console()
from dotenv import load_dotenv
import os
import os, time, shutil
configured = True
REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD"]
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."
)
@ -36,25 +38,33 @@ reddit2fa=os.getenv("REDDIT_2FA")
console.log("[bold green]Checking environment variables...")
time.sleep(1)
if not all(client_id, client_secret, username, password):
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:
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.")
setup_ask = input("Launch setup wizard? > ")
if setup_ask=="yes":
console.log("[bold green]Here goes nothing! Launching setup wizard...")
time.sleep(0.5)
os.system("python3 setup.py")
else:
if setup_ask=="no":
console.print("[red]Exiting...")
time.sleep(0.5)
exit()
else:
console.print("[red]I don't understand that. Exiting...")
time.sleep(0.5)
exit()
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.")
setup_ask = input("Launch setup wizard? > ")
if setup_ask=="yes":
console.log("[bold green]Here goes nothing! Launching setup wizard...")
time.sleep(0.5)
os.system("python3 setup.py")
else:
if setup_ask=="no":
console.print("[red]Exiting...")
time.sleep(0.5)
exit()
else:
console.print("[red]I don't understand that. Exiting...")
time.sleep(0.5)
exit()
exit()
@ -62,12 +72,17 @@ if not all(client_id, client_secret, username, password):
console.log("[bold green]Enviroment Variables are set! Continuing...")
time.sleep(3)
reddit_object = get_subreddit_threads()
load_dotenv()
length, number_of_comments = save_text_to_mp3(reddit_object)
download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME"))
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)
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)

@ -1,11 +1,8 @@
from rich import Console
from utils.console import print_markdown, print_step, print_substep
import praw
import random
from dotenv import load_dotenv
import os
console = Console()
import os, random, praw, re
def get_subreddit_threads():
"""
@ -16,7 +13,7 @@ def get_subreddit_threads():
print_step("Getting AskReddit threads...")
if os.getenv("REDDIT_2FA").lower() == "yes":
if os.getenv("REDDIT_2FA", default="no").casefold() == "yes":
print(
"\nEnter your two-factor authentication code from your authenticator app.\n"
)
@ -37,12 +34,12 @@ def get_subreddit_threads():
)
if os.getenv("SUBREDDIT"):
subreddit = reddit.subreddit(os.getenv("SUBREDDIT"))
subreddit = reddit.subreddit(re.sub(r"r\/", "", os.getenv("SUBREDDIT")))
else:
# ! Prompt the user to enter a subreddit
try:
subreddit = reddit.subreddit(
input("What subreddit would you like to pull from? ")
re.sub(r"r\/", "", input("What subreddit would you like to pull from? "))
)
except ValueError:
subreddit = reddit.subreddit("askreddit")

Loading…
Cancel
Save