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 😎 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! *The Documentation is still being developed and worked on, please be patient as we change / add new knowledge!
## Contributing & Ways to improve 📈 ## Contributing & Ways to improve 📈

@ -4,7 +4,6 @@ from utils.console import print_step
from utils.console import print_substep from utils.console import print_substep
from rich.console import Console from rich.console import Console
import time import time
import os
from reddit.subreddit import get_subreddit_threads from reddit.subreddit import get_subreddit_threads
from video_creation.background import download_background, chop_background_video from video_creation.background import download_background, chop_background_video
from video_creation.voices import save_text_to_mp3 from video_creation.voices import save_text_to_mp3
@ -14,7 +13,10 @@ from utils.loader import Loader
from dotenv import load_dotenv from dotenv import load_dotenv
console = Console() console = Console()
from dotenv import load_dotenv 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( 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." "### 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,7 +38,15 @@ reddit2fa=os.getenv("REDDIT_2FA")
console.log("[bold green]Checking environment variables...") console.log("[bold green]Checking environment variables...")
time.sleep(1) 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.") 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) time.sleep(0.5)
@ -62,12 +72,17 @@ if not all(client_id, client_secret, username, password):
console.log("[bold green]Enviroment Variables are set! Continuing...") console.log("[bold green]Enviroment Variables are set! Continuing...")
time.sleep(3) time.sleep(3)
reddit_object = get_subreddit_threads()
load_dotenv() load_dotenv()
length, number_of_comments = save_text_to_mp3(reddit_object) length, number_of_comments = save_text_to_mp3(reddit_object)
download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME")) download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME"))
download_background() download_background()
chop_background_video(length) chop_background_video(length)
final_video = make_final_video(number_of_comments) 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 rich import Console
from utils.console import print_markdown, print_step, print_substep from utils.console import print_markdown, print_step, print_substep
import praw
import random
from dotenv import load_dotenv from dotenv import load_dotenv
import os
console = Console() console = Console()
import os, random, praw, re
def get_subreddit_threads(): def get_subreddit_threads():
""" """
@ -16,7 +13,7 @@ def get_subreddit_threads():
print_step("Getting AskReddit threads...") print_step("Getting AskReddit threads...")
if os.getenv("REDDIT_2FA").lower() == "yes": if os.getenv("REDDIT_2FA", default="no").casefold() == "yes":
print( print(
"\nEnter your two-factor authentication code from your authenticator app.\n" "\nEnter your two-factor authentication code from your authenticator app.\n"
) )
@ -37,12 +34,12 @@ def get_subreddit_threads():
) )
if os.getenv("SUBREDDIT"): if os.getenv("SUBREDDIT"):
subreddit = reddit.subreddit(os.getenv("SUBREDDIT")) subreddit = reddit.subreddit(re.sub(r"r\/", "", os.getenv("SUBREDDIT")))
else: else:
# ! Prompt the user to enter a subreddit # ! Prompt the user to enter a subreddit
try: try:
subreddit = reddit.subreddit( 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: except ValueError:
subreddit = reddit.subreddit("askreddit") subreddit = reddit.subreddit("askreddit")

Loading…
Cancel
Save