Merge pull request #354 from null3000/ux-changes

UX changes / Gives User More Info
pull/456/head
Callum Leslie 3 years ago committed by GitHub
commit 862d7f25e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,6 +22,29 @@ REQUIRED_VALUES = [
"OPACITY", "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( 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." "### 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() load_dotenv()
console.log("[bold green]Checking environment variables...") console.log("[bold green]Checking environment variables...")
time.sleep(1) time.sleep(.5)
if not os.path.exists(".env"): if not os.path.exists(".env"):

@ -64,9 +64,17 @@ def get_subreddit_threads():
threads = subreddit.hot(limit=25) threads = subreddit.hot(limit=25)
submission = list(threads)[random.randrange(0, 25)] submission = list(threads)[random.randrange(0, 25)]
print_substep(f"Video will be: {submission.title}") upvotes=submission.score
print("Getting video comments...") 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: try:
content["thread_url"] = submission.url content["thread_url"] = submission.url

@ -46,6 +46,14 @@ def make_final_video(number_of_clips):
OSError() OSError()
audio_concat = concatenate_audioclips(audio_clips) audio_concat = concatenate_audioclips(audio_clips)
audio_composite = CompositeAudioClip([audio_concat]) 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 # Gather all images
image_clips = [] image_clips = []

@ -4,6 +4,8 @@ from pathlib import Path
from rich.progress import track from rich.progress import track
from utils.console import print_step, print_substep from utils.console import print_step, print_substep
import json import json
from rich.console import Console
console = Console()
def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme): 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( 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 # Stop if we have reached the screenshot_num
if idx >= screenshot_num: if idx >= screenshot_num:
break break
@ -62,5 +67,7 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme):
page.locator(f"#t1_{comment['comment_id']}").screenshot( page.locator(f"#t1_{comment['comment_id']}").screenshot(
path=f"assets/png/comment_{idx}.png" 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.")

@ -4,9 +4,10 @@ from pathlib import Path
from mutagen.mp3 import MP3 from mutagen.mp3 import MP3
from utils.console import print_step, print_substep from utils.console import print_step, print_substep
from rich.progress import track from rich.progress import track
from rich.console import Console
console = Console()
import re import re
def save_text_to_mp3(reddit_obj): def save_text_to_mp3(reddit_obj):
"""Saves Text to MP3 files. """Saves Text to MP3 files.
@ -33,7 +34,11 @@ def save_text_to_mp3(reddit_obj):
tts.save("assets/mp3/posttext.mp3") tts.save("assets/mp3/posttext.mp3")
length += MP3("assets/mp3/posttext.mp3").info.length 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 # ! 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: if length > 50:
break break
@ -43,6 +48,7 @@ def save_text_to_mp3(reddit_obj):
tts.save(f"assets/mp3/{idx}.mp3") tts.save(f"assets/mp3/{idx}.mp3")
length += MP3(f"assets/mp3/{idx}.mp3").info.length 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 the index so we know how many screenshots of comments we need to make.
return length, idx return length, idx

Loading…
Cancel
Save