diff --git a/main.py b/main.py index cade990..5a2fa6c 100644 --- a/main.py +++ b/main.py @@ -22,6 +22,29 @@ REQUIRED_VALUES = [ "OPACITY", ] +#Banner may look bad or wrong in IDE/Text Editor, but looks perfect in CMD, BASH or ZSH +banner = ''' + +██████╗░███████╗██████╗░██████╗░██╗████████╗  ██╗░░░██╗██╗██████╗░███████╗░█████╗░ +██╔══██╗██╔════╝██╔══██╗██╔══██╗██║╚══██╔══╝  ██║░░░██║██║██╔══██╗██╔════╝██╔══██╗ +██████╔╝█████╗░░██║░░██║██║░░██║██║░░░██║░░░  ╚██╗░██╔╝██║██║░░██║█████╗░░██║░░██║ +██╔══██╗██╔══╝░░██║░░██║██║░░██║██║░░░██║░░░  ░╚████╔╝░██║██║░░██║██╔══╝░░██║░░██║ +██║░░██║███████╗██████╔╝██████╔╝██║░░░██║░░░  ░░╚██╔╝░░██║██████╔╝███████╗╚█████╔╝ +╚═╝░░╚═╝╚══════╝╚═════╝░╚═════╝░╚═╝░░░╚═╝░░░  ░░░╚═╝░░░╚═╝╚═════╝░╚══════╝░╚════╝░ + +███╗░░░███╗░█████╗░██╗░░██╗███████╗██████╗░ +████╗░████║██╔══██╗██║░██╔╝██╔════╝██╔══██╗ +██╔████╔██║███████║█████═╝░█████╗░░██████╔╝ +██║╚██╔╝██║██╔══██║██╔═██╗░██╔══╝░░██╔══██╗ +██║░╚═╝░██║██║░░██║██║░╚██╗███████╗██║░░██║ +╚═╝░░░░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝ + +''' +print(banner) + +#Banner may look bad or wrong in IDE/Text Editor, but looks perfect in CMD, BASH or ZSH + +time.sleep(.5) print_markdown( "### Thanks for using this tool! [Feel free to contribute to this project on GitHub!](https://lewismenelaws.com) If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue." @@ -43,7 +66,7 @@ reddit2fa = os.getenv("REDDIT_2FA") load_dotenv() console.log("[bold green]Checking environment variables...") -time.sleep(1) +time.sleep(.5) if not os.path.exists(".env"): diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 40c95b6..249f902 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -64,9 +64,17 @@ def get_subreddit_threads(): threads = subreddit.hot(limit=25) submission = list(threads)[random.randrange(0, 25)] - - print_substep(f"Video will be: {submission.title}") - print("Getting video comments...") + + upvotes=submission.score + ratio=submission.upvote_ratio * 100 + num_comments=submission.num_comments + + console.log(f"[bold green] Video will be: {submission.title} :thumbsup:") + console.log(f"[bold blue] Thread has " + str(upvotes) + " upvotes") + console.log(f"[bold blue] Thread has a upvote ratio of " + str(ratio) + "%") + console.log(f"[bold blue] Thread has " + str(num_comments) + " comments") + console.log("Getting video comments...") + try: content["thread_url"] = submission.url diff --git a/video_creation/final_video.py b/video_creation/final_video.py index a12f2d6..a1ad0e1 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -46,6 +46,14 @@ def make_final_video(number_of_clips): OSError() audio_concat = concatenate_audioclips(audio_clips) audio_composite = CompositeAudioClip([audio_concat]) + + #Get sum of all clip lengths + total_length = sum([clip.duration for clip in audio_clips]) + #round total_length to an integer + int_total_length=round(total_length) + #Output Length + console.log(f"[bold green] Video Will Be: {int_total_length} Seconds Long") + # Gather all images image_clips = [] diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index 5f884f0..88fcaa1 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -4,6 +4,8 @@ from pathlib import Path from rich.progress import track from utils.console import print_step, print_substep import json +from rich.console import Console +console = Console() def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme): @@ -48,9 +50,12 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme): ) for idx, comment in track( - enumerate(reddit_object["comments"]), "Downloading screenshots..." + enumerate(reddit_object["comments"]) ): + #allow user to see what comment is being saved + print_substep(f"Downloading screenshot {idx + 1}") + # Stop if we have reached the screenshot_num if idx >= screenshot_num: break @@ -62,5 +67,7 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme): page.locator(f"#t1_{comment['comment_id']}").screenshot( path=f"assets/png/comment_{idx}.png" ) - - print_substep("Screenshots downloaded Successfully.", style="bold green") + + #let user know that the screenshots are done + console.log(f"[bold green]Saved {idx + 1} screenshots.") + \ No newline at end of file diff --git a/video_creation/voices.py b/video_creation/voices.py index 1a83735..6ae88ab 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -4,9 +4,10 @@ from pathlib import Path from mutagen.mp3 import MP3 from utils.console import print_step, print_substep from rich.progress import track +from rich.console import Console +console = Console() import re - def save_text_to_mp3(reddit_obj): """Saves Text to MP3 files. @@ -33,7 +34,11 @@ def save_text_to_mp3(reddit_obj): tts.save("assets/mp3/posttext.mp3") length += MP3("assets/mp3/posttext.mp3").info.length - for idx, comment in track(enumerate(reddit_obj["comments"]), "Saving..."): + for idx, comment in track(enumerate(reddit_obj["comments"])): + + #allow user to see what comment is being saved + print_substep(f"Saving MP3 {idx + 1} ") + # ! Stop creating mp3 files if the length is greater than 50 seconds. This can be longer, but this is just a good starting point if length > 50: break @@ -43,6 +48,7 @@ def save_text_to_mp3(reddit_obj): tts.save(f"assets/mp3/{idx}.mp3") length += MP3(f"assets/mp3/{idx}.mp3").info.length - print_substep("Saved Text to MP3 files successfully.", style="bold green") + #let user know that the MP3 files are saved + console.log(f"[bold green]Saved {idx + 1} MP3 Files.") # ! Return the index so we know how many screenshots of comments we need to make. return length, idx