fixes after self review

pull/1070/head
Drugsosos 3 years ago
parent 7ca565eb8d
commit 1d86a8762c
No known key found for this signature in database
GPG Key ID: 8E35176FE617E28D

@ -1,203 +1,198 @@
[reddit] [reddit]
[reddit.creds]
[reddit.creds] [reddit.creds.client_id]
[reddit.creds.client_id] optional = false
optional = false nmin = 12
nmin = 12 nmax = 30
nmax = 30 explanation = "the ID of your Reddit app of SCRIPT type"
explanation = "the ID of your Reddit app of SCRIPT type" example = "fFAGRNJru1FTz70BzhT3Zg"
example = "fFAGRNJru1FTz70BzhT3Zg" regex = "^[-a-zA-Z0-9._~+/]+=*$"
regex = "^[-a-zA-Z0-9._~+/]+=*$" input_error = "The client ID can only contain printable characters."
input_error = "The client ID can only contain printable characters." oob_error = "The ID should be over 12 and under 30 characters, double check your input."
oob_error = "The ID should be over 12 and under 30 characters, double check your input."
[reddit.creds.client_secret]
[reddit.creds.client_secret] optional = false
optional = false nmin = 20
nmin = 20 nmax = 40
nmax = 40 explanation = "the SECRET of your Reddit app of SCRIPT var_type"
explanation = "the SECRET of your Reddit app of SCRIPT var_type" example = "fFAGRNJru1FTz70BzhT3Zg"
example = "fFAGRNJru1FTz70BzhT3Zg" regex = "^[-a-zA-Z0-9._~+/]+=*$"
regex = "^[-a-zA-Z0-9._~+/]+=*$" input_error = "The client ID can only contain printable characters."
input_error = "The client ID can only contain printable characters." oob_error = "The secret should be over 20 and under 40 characters, double check your input."
oob_error = "The secret should be over 20 and under 40 characters, double check your input."
[reddit.creds.username]
[reddit.creds.username] optional = false
optional = false nmin = 3
nmin = 3 nmax = 20
nmax = 20 explanation = "the username of your reddit account"
explanation = "the username of your reddit account" example = "JasonLovesDoggo"
example = "JasonLovesDoggo" regex = "^[-_0-9a-zA-Z]+$"
regex = "^[-_0-9a-zA-Z]+$" oob_error = "A username HAS to be between 3 and 20 characters"
oob_error = "A username HAS to be between 3 and 20 characters"
[reddit.creds.password]
[reddit.creds.password] optional = false
optional = false nmin = 8
nmin = 8 explanation = "the password of your reddit account"
explanation = "the password of your reddit account" example = "fFAGRNJru1FTz70BzhT3Zg"
example = "fFAGRNJru1FTz70BzhT3Zg" oob_error = "Password too short"
oob_error = "Password too short"
[reddit.creds.2fa]
[reddit.creds.2fa] optional = true
optional = true var_type = "bool"
var_type = "bool" options = [true, false]
options = [true, false] default = false
default = false explanation = "Whether you have Reddit 2FA enabled, Valid options are True and False"
explanation = "Whether you have Reddit 2FA enabled, Valid options are True and False" example = true
example = true
[reddit.thread]
[reddit.thread.random]
[reddit.thread] optional = true
[reddit.thread.random] options = [true, false]
optional = true default = false
options = [true, false] var_type = "bool"
default = false explanation = "If set to no, it will ask you a thread link to extract the thread, if yes it will randomize it. Default: 'False'"
var_type = "bool" example = "True"
explanation = "If set to no, it will ask you a thread link to extract the thread, if yes it will randomize it. Default: 'False'"
example = "True" [reddit.thread.subreddit]
optional = false
[reddit.thread.subreddit] regex = "[_0-9a-zA-Z]+$"
optional = false nmin = 3
regex = "[_0-9a-zA-Z]+$" explanation = "what subreddit to pull posts from, the name of the sub, not the URL"
nmin = 3 example = "AskReddit"
explanation = "what subreddit to pull posts from, the name of the sub, not the URL" oob_error = "A subreddit name HAS to be between 3 and 20 characters"
example = "AskReddit"
oob_error = "A subreddit name HAS to be between 3 and 20 characters" [reddit.thread.post_id]
optional = true
[reddit.thread.post_id] default = ""
optional = true regex = "^((?!://|://)[+a-zA-Z0-9])*$"
default = "" explanation = "Used if you want to use a specific post."
regex = "^((?!://|://)[+a-zA-Z0-9])*$" example = "urdtfx"
explanation = "Used if you want to use a specific post."
example = "urdtfx" [reddit.thread.max_comment_length]
default = 500
[reddit.thread.max_comment_length] optional = false
default = 500 nmin = 10
optional = false nmax = 10000
nmin = 10 var_type = "int"
nmax = 10000 explanation = "max number of characters a comment can have. default is 500"
var_type = "int" example = 500
explanation = "max number of characters a comment can have. default is 500" oob_error = "the max comment length should be between 10 and 10000"
example = 500
oob_error = "the max comment length should be between 10 and 10000" [reddit.thread.post_lang]
default = ""
[reddit.thread.post_lang] optional = true
default = "" explanation = "The language you would like to translate to."
optional = true example = "es-cr"
explanation = "The language you would like to translate to."
example = "es-cr" [reddit.thread.min_comments]
default = 20
[reddit.thread.min_comments] optional = false
default = 20 nmin = 15
optional = false var_type = "int"
nmin = 15 explanation = "The minimum number of comments a post should have to be included. default is 20"
var_type = "int" example = 29
explanation = "The minimum number of comments a post should have to be included. default is 20" oob_error = "the minimum number of comments should be between 15 and 999999"
example = 29
oob_error = "the minimum number of comments should be between 15 and 999999"
[settings] [settings]
[settings.allow_nsfw] [settings.allow_nsfw]
optional = false optional = false
var_type = "bool" var_type = "bool"
default = false default = false
example = false example = false
options = [true, false] options = [true, false]
explanation = "Whether to allow NSFW content, True or False" explanation = "Whether to allow NSFW content, True or False"
[settings.theme] [settings.theme]
optional = false optional = false
default = "dark" default = "dark"
example = "light" example = "light"
options = ["dark", "light"] options = ["dark", "light"]
explanation = "sets the Reddit theme, either LIGHT or DARK" explanation = "sets the Reddit theme, either LIGHT or DARK"
[settings.times_to_run] [settings.times_to_run]
optional = false optional = false
default = 1 default = 1
example = 2 example = 2
explanation = "used if you want to run multiple times. set to an int e.g. 4 or 29 or 1" explanation = "used if you want to run multiple times. set to an int e.g. 4 or 29 or 1"
var_type = "int" var_type = "int"
nmin = 1 nmin = 1
oob_error = "It's very hard to run something less than once." oob_error = "It's very hard to run something less than once."
[settings.opacity] [settings.opacity]
optional = false optional = false
default = 0.9 default = 0.9
example = 0.8 example = 0.8
explanation = "Sets the opacity of the comments when overlayed over the background" explanation = "Sets the opacity of the comments when overlayed over the background"
var_type = "float" var_type = "float"
nmin = 0 nmin = 0
nmax = 1 nmax = 1
oob_error = "The opacity HAS to be between 0 and 1" oob_error = "The opacity HAS to be between 0 and 1"
input_error = "The opacity HAS to be a decimal number between 0 and 1" input_error = "The opacity HAS to be a decimal number between 0 and 1"
[settings.transition] [settings.transition]
optional = true optional = true
default = 0.2 default = 0.2
example = 0.2 example = 0.2
explanation = "Sets the transition time (in seconds) between the comments. Set to 0 if you want to disable it." explanation = "Sets the transition time (in seconds) between the comments. Set to 0 if you want to disable it."
var_type = "float" var_type = "float"
nmin = 0 nmin = 0
nmax = 2 nmax = 2
oob_error = "The transition HAS to be between 0 and 2" oob_error = "The transition HAS to be between 0 and 2"
input_error = "The opacity HAS to be a decimal number between 0 and 2" input_error = "The opacity HAS to be a decimal number between 0 and 2"
[settings.storymode] [settings.storymode]
optional = true optional = true
var_type = "bool" var_type = "bool"
default = false default = false
example = false example = false
options = [true, false] options = [true, false]
explanation = "not yet implemented" explanation = "not yet implemented"
[settings.background]
[settings.background] [settings.background.background_choice]
[settings.background.background_choice] optional = true
optional = true default = "minecraft"
default = "minecraft" example = "minecraft"
example = "minecraft" options = ["minecraft", "gta", "rocket-league", "motor-gta", "csgo-surf", "cluster-truck", ""]
options = ["minecraft", "gta", "rocket-league", "motor-gta", "csgo-surf", "cluster-truck", ""] explanation = "Sets the background for the video"
explanation = "Sets the background for the video"
#[settings.background.background_audio]
#[settings.background.background_audio] #optional = true
#optional = true #var_type = "bool"
#var_type = "bool" #default = false
#default = false #example = false
#example = false #options = [true, false]
#options = [true, false] #explaination="Sets a audio to play in the background (put a background.mp3 file in the assets/backgrounds directory for it to be used.)"
#explaination="Sets a audio to play in the background (put a background.mp3 file in the assets/backgrounds directory for it to be used.)" #
# #[settings.background.background_audio_volume]
#[settings.background.background_audio_volume] #optional = true
#optional = true #var_type = "float"
#var_type = "float" #default = 0.3
#default = 0.3 #example = 0.1
#example = 0.1 #explanation="Sets the volume of the background audio. only used if the background_audio is also set to true"
#explanation="Sets the volume of the background audio. only used if the background_audio is also set to true"
[settings.tts]
[settings.tts.choice]
optional = false
[settings.tts] default = ""
[settings.tts.choice] options = ["streamlabspolly", "tiktok", "googletranslate", "awspolly", ""]
optional = false example = "streamlabspolly"
default = "" explanation = "The backend used for TTS generation. This can be left blank and you will be prompted to choose at runtime."
options = ["streamlabspolly", "tiktok", "googletranslate", "awspolly", ""]
example = "streamlabspolly" [settings.tts.aws_polly_voice]
explanation = "The backend used for TTS generation. This can be left blank and you will be prompted to choose at runtime." optional = false
default = "Matthew"
[settings.tts.aws_polly_voice] example = "Matthew"
optional = false explanation = "The voice used for AWS Polly"
default = "Matthew"
example = "Matthew" [settings.tts.streamlabs_polly_voice]
explanation = "The voice used for AWS Polly" optional = false
default = "Matthew"
[settings.tts.streamlabs_polly_voice] example = "Matthew"
optional = false explanation = "The voice used for Streamlabs Polly"
default = "Matthew"
example = "Matthew" [settings.tts.tiktok_voice]
explanation = "The voice used for Streamlabs Polly" optional = false
default = "en_us_006"
[settings.tts.tiktok_voice] example = "en_us_006"
optional = false explanation = "The voice used for TikTok TTS"
default = "en_us_006"
example = "en_us_006"
explanation = "The voice used for TikTok TTS"

@ -154,7 +154,7 @@ def check_vars(
checks: dict, checks: dict,
) -> None: ) -> None:
""" """
Checks if value is in nested dict and correct by path of keys Checks if there is the value in the dict and it's correct
Args: Args:
path: List with path path: List with path
@ -204,9 +204,9 @@ def check_config_wrapper(
return False return False
console.print("Unable to read config, and not allowed to overwrite it. Giving up.") console.print("Unable to read config, and not allowed to overwrite it. Giving up.")
return False return False
# except Exception as error: except Exception as error:
# console.print(f"[red bold]Encountered error when trying to to load {kwargs['template_name']}: {error}") console.print(f"[red bold]Encountered error when trying to to load {kwargs['template_name']}: {error}")
# return False return False
return wrapper return wrapper
@ -248,6 +248,16 @@ def check_config(
config = toml.load(config_name) config = toml.load(config_name)
template = toml.load(template_name) template = toml.load(template_name)
console.print(
"""\
[blue bold]###############################
# #
# Checking TOML configuration #
# #
###############################
If you see any prompts, that means that you have unset/incorrectly set variables, please input the correct values.\
"""
)
crawl(template, check_vars) crawl(template, check_vars)
with open(config_name, "w") as f: with open(config_name, "w") as f:
toml.dump(config, f) toml.dump(config, f)

Loading…
Cancel
Save