2 files changed
+42
-11
No files matched your search
@@ -0,0 +1,30 @@
|
||||
# write a class that takes .env file and parses it into a dictionary
|
||||
|
||||
from dotenv import dotenv_values
|
||||
|
||||
DEFAULTS = {'SUBREDDIT': "AskReddit", 'ALLOW_NSFW': "False", 'POST_ID': "", 'THEME': "DARK", 'REDDIT_2FA': "no",
|
||||
'TIMES_TO_RUN': "", 'MAX_COMMENT_LENGTH': "500", 'OPACITY': "1", 'VOICE': "en_us_001", 'STORYMODE': "False"}
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
self.raw = dotenv_values("../.env")
|
||||
self.load_attrs()
|
||||
|
||||
def __getattr__(self, attr): # code completion for attributes fix.
|
||||
return getattr(self, attr)
|
||||
|
||||
def load_attrs(self):
|
||||
for key, value in self.raw.items():
|
||||
self.add_attr(key, value)
|
||||
|
||||
def add_attr(self, key, value):
|
||||
if value is None or value == "":
|
||||
setattr(self, key, DEFAULTS[key])
|
||||
else:
|
||||
setattr(self, key, str(value))
|
||||
|
||||
|
||||
config = Config()
|
||||
|
||||
print(config.SUBREDDIT)
|
||||
@@ -88,20 +88,21 @@ def make_final_video(number_of_clips, length):
|
||||
.resize(width=W - 100)
|
||||
.set_opacity(float(opacity)),
|
||||
)
|
||||
if os.path.exists("assets/mp3/posttext.mp3"):
|
||||
image_clips.insert(
|
||||
0,
|
||||
ImageClip("assets/png/title.png")
|
||||
.set_duration(audio_clips[0].duration + audio_clips[1].duration)
|
||||
.set_position("center")
|
||||
.resize(width=W - 100)
|
||||
.set_opacity(float(opacity)),
|
||||
)
|
||||
else:
|
||||
image_clips.insert(
|
||||
#if os.path.exists("assets/mp3/posttext.mp3"):
|
||||
# image_clips.insert(
|
||||
# 0,
|
||||
# ImageClip("assets/png/title.png")
|
||||
# .set_duration(audio_clips[0].duration + audio_clips[1].duration)
|
||||
# .set_position("center")
|
||||
# .resize(width=W - 100)
|
||||
# .set_opacity(float(opacity)),
|
||||
# )
|
||||
#else:
|
||||
image_clips.insert(
|
||||
0,
|
||||
ImageClip("assets/temp/png/title.png")
|
||||
.set_duration(audio_clips[0].duration)
|
||||
#.set_duration(audixc vcco_clips[0].duration)
|
||||
.set_position("center")
|
||||
.resize(width=W - 100)
|
||||
.set_opacity(float(opacity)),
|
||||
|
||||
Reference in new issue
Block a user