commit
39160f49bf
@ -0,0 +1,83 @@
|
||||
import argparse
|
||||
|
||||
from main import main
|
||||
from setup_program import setup
|
||||
from utils.console import print_substep
|
||||
|
||||
|
||||
def program_options():
|
||||
|
||||
description = """\
|
||||
Create Reddit Videos with one command.
|
||||
"""
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="RedditVideoMakerBot", # can be renamed, just a base
|
||||
usage="RedditVideoMakerBot [OPTIONS]",
|
||||
description=description
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", "--create",
|
||||
help="Create a video (uses the defaults).",
|
||||
action="store_true"
|
||||
)
|
||||
parser.add_argument( # only accepts the name of subreddit, not links.
|
||||
"-s", "--subreddit",
|
||||
help="Specify a subreddit.",
|
||||
action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-b", "--background",
|
||||
help="Specify a video background for video (accepts link and file).",
|
||||
action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-f", "--filename",
|
||||
help="Specify a filename for the video.",
|
||||
action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-t", "--thread",
|
||||
help="Use the given thread link instead of random.",
|
||||
action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-n", "--number",
|
||||
help="Specify number of comments to include in the video.",
|
||||
action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--setup", "--setup",
|
||||
help="(Re)setup the program.",
|
||||
action="store_true"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
if args.create:
|
||||
while True:
|
||||
create = main(
|
||||
args.subreddit,
|
||||
args.background,
|
||||
args.filename,
|
||||
args.thread,
|
||||
args.number,
|
||||
)
|
||||
if not create:
|
||||
try_again = input("Something went wrong! Try again? [y/N] > ").strip()
|
||||
if try_again in ["y", "Y"]:
|
||||
continue
|
||||
|
||||
break
|
||||
elif args.setup:
|
||||
setup()
|
||||
else:
|
||||
print_substep("Error occured!", style_="bold red")
|
||||
raise SystemExit()
|
||||
except KeyboardInterrupt:
|
||||
print_substep("\nOperation Aborted!", style_="bold red")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
program_options()
|
@ -1,2 +1 @@
|
||||
#!/bin/sh
|
||||
docker run -v $(pwd)/out/:/app/assets -v $(pwd)/.env:/app/.env -it rvmt
|
||||
|
@ -0,0 +1,69 @@
|
||||
import os
|
||||
from os.path import exists
|
||||
|
||||
from utils.console import print_markdown, print_substep
|
||||
|
||||
|
||||
def setup():
|
||||
if exists(".setup-done-before"):
|
||||
print_substep(
|
||||
"Setup was already done before! Please make sure you have "
|
||||
+ "to run this script again.", style_="bold red"
|
||||
)
|
||||
# to run the setup script again, but in better and more convenient manner.
|
||||
if str(input("\033[1mRun the script again? [y/N] > \033[0m")).strip() not in ["y", "Y"]:
|
||||
print_substep("Permission denied!", style_="bold red")
|
||||
raise SystemExit()
|
||||
|
||||
print_markdown(
|
||||
"### You're in the setup wizard. Ensure you're supposed to be here, "
|
||||
+ "then type yes to continue. If you're not sure, type no to quit."
|
||||
)
|
||||
|
||||
# This Input is used to ensure the user is sure they want to continue.
|
||||
# Again, let them know they are about to erase all other setup data.
|
||||
print_substep(
|
||||
"Ensure you have the following ready to enter:\n"
|
||||
+ "[bold green]Reddit Client ID\n"
|
||||
+ "Reddit Client Secret\n"
|
||||
+ "Reddit Username\n"
|
||||
+ "Reddit Password\n"
|
||||
+ "Reddit 2FA (yes or no)\n"
|
||||
+ "Opacity (range of 0-1, decimals are accepted.)\n"
|
||||
+ "Subreddit (without r/ or /r/)\n"
|
||||
+ "Theme (light or dark)[/bold green]"
|
||||
+ "[bold]If you don't have these, please follow the instructions in the README.md "
|
||||
+ "set them up.\nIf you do have these, type y or Y to continue. If you don't, "
|
||||
+ "go ahead and grab those quickly and come back.[/bold]"
|
||||
)
|
||||
|
||||
# Begin the setup process.
|
||||
|
||||
cliID = input("Client ID > ")
|
||||
cliSec = input("Client Secret > ")
|
||||
user = input("Username > ")
|
||||
passw = input("Password > ")
|
||||
twofactor = input("2FA Enabled? (yes/no) > ")
|
||||
opacity = input("Opacity? (range of 0-1) > ")
|
||||
subreddit = input("Subreddit (without r/) > ")
|
||||
theme = input("Theme? (light or dark) > ")
|
||||
|
||||
if exists(".env"):
|
||||
os.remove(".env")
|
||||
|
||||
with open(".env", "a", encoding="utf-8") as f:
|
||||
f.write(
|
||||
f'REDDIT_CLIENT_ID="{cliID}"\n'
|
||||
+ f'REDDIT_CLIENT_SECRET="{cliSec}"\n'
|
||||
+ f'REDDIT_USERNAME="{user}"\n'
|
||||
+ f'REDDIT_PASSWORD="{passw}"\n'
|
||||
+ f'REDDIT_2FA="{twofactor}"\n'
|
||||
+ f'THEME="{theme}"\n'
|
||||
+ f'SUBREDDIT="{subreddit}"\n'
|
||||
+ f'OPACITY="{opacity}"\n'
|
||||
)
|
||||
|
||||
with open(".setup-done-before", "a", encoding="utf-8") as f:
|
||||
f.write("This file will stop the setup assistant from running again.")
|
||||
|
||||
print_substep("[bold green]Setup Complete![/bold green]")
|
Loading…
Reference in new issue