parent
8d54e373df
commit
b2b4a08741
@ -1,31 +1,52 @@
|
|||||||
REDDIT_CLIENT_ID=""
|
REDDIT_CLIENT_ID=""
|
||||||
|
#EXPLANATION the ID of your Reddit app of SCRIPT type
|
||||||
|
|
||||||
REDDIT_CLIENT_SECRET=""
|
REDDIT_CLIENT_SECRET=""
|
||||||
|
#EXPLANATION the SECRET of your Reddit app of SCRIPT type
|
||||||
|
|
||||||
REDDIT_USERNAME=""
|
REDDIT_USERNAME=""
|
||||||
|
#EXPLANATION the username of your reddit account
|
||||||
|
|
||||||
REDDIT_PASSWORD=""
|
REDDIT_PASSWORD=""
|
||||||
|
#EXPLANATION the password of your reddit account
|
||||||
|
|
||||||
# If no, it will ask you a thread link to extract the thread, if yes it will randomize it. Default: "no"
|
#OPTIONAL
|
||||||
RANDOM_THREAD="no"
|
RANDOM_THREAD="no"
|
||||||
|
#EXPLANATION If set to no, it will ask you a thread link to extract the thread, if yes it will randomize it. Default: "no"
|
||||||
|
|
||||||
# Valid options are "yes" and "no" for the variable below
|
|
||||||
REDDIT_2FA=""
|
REDDIT_2FA=""
|
||||||
|
#MATCH_REGEX ^(yes|no)
|
||||||
|
#EXPLANATION Whether you have Reddit 2FA enabled, Valid options are "yes" and "no"
|
||||||
|
|
||||||
SUBREDDIT="AskReddit"
|
SUBREDDIT="AskReddit"
|
||||||
# True or False
|
|
||||||
ALLOW_NSFW="False"
|
ALLOW_NSFW="False"
|
||||||
# Used if you want to use a specific post. example of one is urdtfx
|
#EXPLANATION Whether to allow NSFW content, True or False
|
||||||
|
#MATCH_REGEX ^(True|False)$
|
||||||
|
|
||||||
POST_ID=""
|
POST_ID=""
|
||||||
#set to either LIGHT or DARK
|
#MATCH_REGEX ^((?!://|://).)*$
|
||||||
|
#EXPLANATION Used if you want to use a specific post. example of one is urdtfx
|
||||||
|
|
||||||
THEME="LIGHT"
|
THEME="LIGHT"
|
||||||
# used if you want to run multiple times. set to an int e.g. 4 or 29 and leave blank for 1
|
#EXPLANATION sets the Reddit theme, either LIGHT or DARK
|
||||||
|
|
||||||
TIMES_TO_RUN=""
|
TIMES_TO_RUN=""
|
||||||
# max number of characters a comment can have.
|
#EXPLANATION used if you want to run multiple times. set to an int e.g. 4 or 29 and leave blank for 1
|
||||||
MAX_COMMENT_LENGTH="500" # default is 500
|
|
||||||
# Range is 0 -> 1 recommended around 0.8-0.9
|
MAX_COMMENT_LENGTH="500"
|
||||||
|
#EXPLANATION max number of characters a comment can have. default is 500
|
||||||
|
|
||||||
|
#OPTIONAL
|
||||||
OPACITY="1"
|
OPACITY="1"
|
||||||
|
#EXPLANATION sets the opacity of the comments, Range is 0 -> 1 recommended around 0.8-0.9
|
||||||
|
|
||||||
# see different voice options: todo: add docs
|
# see different voice options: todo: add docs
|
||||||
VOICE="Matthew" # e.g. en_us_002
|
VOICE="Matthew"
|
||||||
|
#EXPLANATION sets the voice the TTS uses, e.g. en_us_002
|
||||||
|
|
||||||
TTsChoice="polly"
|
TTsChoice="polly"
|
||||||
|
#EXPLANATION the backend used for TTS, default is polly
|
||||||
|
|
||||||
# IN-PROGRESS - not yet implemented
|
#OPTIONAL
|
||||||
STORYMODE="False"
|
STORYMODE="False"
|
||||||
|
#EXPLANATION IN-PROGRESS - not yet implemented
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
from rich.console import Console
|
||||||
|
import re
|
||||||
|
import dotenv
|
||||||
|
from utils.console import handle_input
|
||||||
|
|
||||||
|
console = Console()
|
||||||
|
|
||||||
|
success = True
|
||||||
|
|
||||||
|
|
||||||
|
def check_env() -> bool:
|
||||||
|
if not os.path.exists(".env.template"):
|
||||||
|
console.print("[red]Couldn't find .env.template. Unable to check variables.")
|
||||||
|
return False
|
||||||
|
with open(".env.template", "r") as template:
|
||||||
|
# req_envs = [env.split("=")[0] for env in template.readlines() if "=" in env]
|
||||||
|
matching = {}
|
||||||
|
explanations = {}
|
||||||
|
req_envs = []
|
||||||
|
var_optional = False
|
||||||
|
for line in template.readlines():
|
||||||
|
if "=" in line and var_optional is not True:
|
||||||
|
req_envs.append(line.split("=")[0])
|
||||||
|
elif "#OPTIONAL" in line:
|
||||||
|
var_optional = True
|
||||||
|
elif line.startswith("#MATCH_REGEX "):
|
||||||
|
matching[req_envs[-1]] = line.removeprefix("#MATCH_REGEX ")[:-1]
|
||||||
|
var_optional = False
|
||||||
|
elif line.startswith("#EXPLANATION "):
|
||||||
|
explanations[req_envs[-1]] = line.removeprefix("#EXPLANATION ")[:-1]
|
||||||
|
var_optional = False
|
||||||
|
else:
|
||||||
|
var_optional = False
|
||||||
|
missing = []
|
||||||
|
incorrect = []
|
||||||
|
dotenv.load_dotenv()
|
||||||
|
for env in req_envs:
|
||||||
|
value = os.getenv(env)
|
||||||
|
if value is None:
|
||||||
|
missing.append(env)
|
||||||
|
continue
|
||||||
|
if env in matching.keys():
|
||||||
|
env, re.match(matching[env], value) is None and incorrect.append(env)
|
||||||
|
if len(missing):
|
||||||
|
for i in range(len(missing)):
|
||||||
|
try:
|
||||||
|
missing[i] = missing[i] + ": " + explanations[missing[i]]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
console.print(
|
||||||
|
f"[red]{'These variables are'*(len(missing) > 1) or 'This variable is'} non-optional and missing: \n\n"
|
||||||
|
+ "\n\n".join(missing)
|
||||||
|
)
|
||||||
|
success = False
|
||||||
|
if len(incorrect):
|
||||||
|
console.print(
|
||||||
|
f"[red]{'These variables are'*(len(incorrect) > 1) or 'This variable is'} set incorrectly: "
|
||||||
|
+ "\n".join(incorrect)
|
||||||
|
)
|
||||||
|
success = False
|
||||||
|
# if success is True:
|
||||||
|
# return True
|
||||||
|
# console.print("[green]Do you want to enter the missing variables by hand(y/n)")
|
||||||
|
# if not input().casefold().startswith("y"):
|
||||||
|
# console.print("[red]Aborting: Unresolved missing variables")
|
||||||
|
# return success
|
||||||
|
# with open(".env", "a") as env_file:
|
||||||
|
# for env in missing:
|
||||||
|
# pass
|
||||||
|
return success
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
check_env()
|
@ -1,9 +0,0 @@
|
|||||||
$envFile = Get-Content ".\.env.template"
|
|
||||||
|
|
||||||
$envFile -split "=" | Where-Object {$_ -notmatch '\"'} | Set-Content ".\envVarsbefSpl.txt"
|
|
||||||
Get-Content ".\envVarsbefSpl.txt" | Where-Object {$_ -notmatch '\#'} | Set-Content ".\envVarsN.txt"
|
|
||||||
Get-Content ".\envVarsN.txt" | Where-Object {$_ -ne ''} | Set-Content ".\video_creation\data\envvars.txt"
|
|
||||||
Remove-Item ".\envVarsbefSpl.txt"
|
|
||||||
Remove-Item ".\envVarsN.txt"
|
|
||||||
|
|
||||||
Write-Host $nowSplit
|
|
@ -1,9 +0,0 @@
|
|||||||
$envFile = Get-Content ".\.env"
|
|
||||||
|
|
||||||
$envFile -split "=" | Where-Object {$_ -notmatch '\"'} | Set-Content ".\envVarsbefSpl.txt"
|
|
||||||
Get-Content ".\envVarsbefSpl.txt" | Where-Object {$_ -notmatch '\#'} | Set-Content ".\envVarsN.txt"
|
|
||||||
Get-Content ".\envVarsN.txt" | Where-Object {$_ -ne ''} | Set-Content ".\video_creation\data\envvars.txt"
|
|
||||||
Remove-Item ".\envVarsbefSpl.txt"
|
|
||||||
Remove-Item ".\envVarsN.txt"
|
|
||||||
|
|
||||||
Write-Host $nowSplit
|
|
Loading…
Reference in new issue