features for custom filename as listed in #225

pull/280/head
iaacornus 3 years ago
parent 0d034d01dd
commit 2ad99f41ef
No known key found for this signature in database
GPG Key ID: 281739AE7252598C

@ -34,12 +34,22 @@ def program_options():
help="Use another video background for video (accepts link).", help="Use another video background for video (accepts link).",
action="store" action="store"
) )
parser.add_argument(
"-f",
"--filename",
help="Set a filename for the video.",
action="store"
)
args = parser.parse_args() args = parser.parse_args()
try: try:
if args.create: if args.create:
main(args.subreddit, args.background) main(
args.subreddit,
args.background,
args.filename
)
else: else:
print_substep("Error occured!", style="bold red") print_substep("Error occured!", style="bold red")
raise SystemExit() raise SystemExit()

@ -12,7 +12,7 @@ from video_creation.final_video import make_final_video
from utils.console import print_markdown, print_substep from utils.console import print_markdown, print_substep
def main(subreddit_=None, background=None): def main(subreddit_=None, background=None, filename=None):
REQUIRED_VALUES = [ REQUIRED_VALUES = [
"REDDIT_CLIENT_ID", "REDDIT_CLIENT_ID",
"REDDIT_CLIENT_SECRET", "REDDIT_CLIENT_SECRET",
@ -42,7 +42,10 @@ def main(subreddit_=None, background=None):
if configured: if configured:
reddit_object = get_subreddit_threads(subreddit_) reddit_object = get_subreddit_threads(subreddit_)
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(background) download_background(background)
chop_background_video(length) chop_background_video(length)
final_video = make_final_video(number_of_comments) final_video = make_final_video(snumber_of_comments, filename)

@ -19,7 +19,7 @@ from utils.console import print_step
W, H = 1080, 1920 W, H = 1080, 1920
def make_final_video(number_of_clips): def make_final_video(number_of_clips, file_name):
# Calls opacity from the .env # Calls opacity from the .env
load_dotenv() load_dotenv()
opacity = os.getenv('OPACITY') opacity = os.getenv('OPACITY')
@ -80,9 +80,11 @@ def make_final_video(number_of_clips):
image_concat.audio = audio_composite image_concat.audio = audio_composite
final = CompositeVideoClip([background_clip, image_concat]) final = CompositeVideoClip([background_clip, image_concat])
filename = ( if file_name is None:
re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.subreddit.submission.title + ".mp4")) filename = (
) re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.subreddit.submission.title + ".mp4"))
)
final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k") final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k")
for i in range(0, number_of_clips): for i in range(0, number_of_clips):
pass pass

Loading…
Cancel
Save