From 45a296db802840be708b8679bc5ceb309b117249 Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Mon, 6 Jun 2022 20:42:46 +0300 Subject: [PATCH 1/8] setup.py heavily refactored, all files formatted with python-BLACK and added shebang lines --- build.sh | 3 +- main.py | 3 +- reddit/subreddit.py | 7 +- run.sh | 3 +- setup.py | 247 ++++++++++++++++-------- utils/console.py | 1 + utils/loader.py | 9 +- video_creation/background.py | 2 + video_creation/final_video.py | 18 +- video_creation/screenshot_downloader.py | 6 +- video_creation/voices.py | 1 + 11 files changed, 200 insertions(+), 100 deletions(-) mode change 100644 => 100755 setup.py diff --git a/build.sh b/build.sh index 7d4dfc6..45ebd33 100755 --- a/build.sh +++ b/build.sh @@ -1 +1,2 @@ -docker build -t rvmt . \ No newline at end of file +#!/bin/sh +docker build -t rvmt . diff --git a/main.py b/main.py index 9aabe78..92cc886 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Main from utils.console import print_markdown from utils.console import print_step @@ -54,7 +55,7 @@ if not os.path.exists(".env"): console.log("[red] Your .env file is invalid, or was never created. Standby.") for val in REQUIRED_VALUES: - #print(os.getenv(val)) + # print(os.getenv(val)) if val not in os.environ or not os.getenv(val): console.log(f'[bold red]Missing Variable: "{val}"') configured = False diff --git a/reddit/subreddit.py b/reddit/subreddit.py index c560293..a52a214 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 from rich.console import Console from utils.console import print_markdown, print_step, print_substep from dotenv import load_dotenv @@ -48,7 +49,11 @@ def get_subreddit_threads(): # ! Prompt the user to enter a subreddit try: subreddit = reddit.subreddit( - re.sub(r"r\/", "",input("What subreddit would you like to pull from? ")) + re.sub( + r"r\/", + "", + input("What subreddit would you like to pull from? "), + ) ) except ValueError: subreddit = reddit.subreddit("askreddit") diff --git a/run.sh b/run.sh index 4dcb69a..3ee26db 100755 --- a/run.sh +++ b/run.sh @@ -1 +1,2 @@ -docker run -v $(pwd)/out/:/app/assets -v $(pwd)/.env:/app/.env -it rvmt \ No newline at end of file +#!/bin/sh +docker run -v "$(pwd)/out/:/app/assets" -v "$(pwd)/.env:/app/.env -it rvmt" diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index feaa344..0154ce9 --- a/setup.py +++ b/setup.py @@ -1,55 +1,98 @@ -""" - -Setup Script for RedditVideoMakerBot +#!/usr/bin/env python3 +# Setup Script for RedditVideoMakerBot -""" # Imports import os -import time +import subprocess +import re from utils.console import print_markdown from utils.console import print_step -from utils.console import print_substep from rich.console import Console from utils.loader import Loader -from os.path import exists + console = Console() -setup_done = exists(".setup-done-before") -if setup_done == True: - console.log("[red]Setup was already completed! Please make sure you have to run this script again. If you have to, please delete the file .setup-done-before") - exit() +def handle_input( + message: str = "", + check_type=False, + match: str = "", + err_message: str = "", + nmin=None, + nmax=None, + oob_error="", +): + match = re.compile(match) + while True: + user_input = input(message + "\n> ").strip() + if re.match(match, user_input) is not None: + if check_type is not False: + try: + user_input = check_type(user_input) + if nmin is not None and user_input < nmin: + console.log("[red]" + oob_error) # Input too low failstate + continue + if nmax is not None and user_input > nmax: + console.log("[red]" + oob_error) # Input too high + continue + break # Successful type conversion and number in bounds + except ValueError: + console.log("[red]" + err_message) # Type conversion failed + continue + if ( + nmin is not None and len(user_input) < nmin + ): # Check if string is long enough + console.log("[red]" + oob_error) + continue + if ( + nmax is not None and len(user_input) > nmax + ): # Check if string is not too long + console.log("[red]" + oob_error) + continue + break + console.log("[red]" + err_message) + + return user_input + + +if os.path.isfile(".setup-done-before"): + console.log( + "[red]Setup was already completed! Please make sure you have to run this script again. If that is such, delete the file .setup-done-before" + ) + exit() # These lines ensure the user: # - knows they are in setup mode # - knows that they are about to erase any other setup files/data. print_step("Setup Assistant") - print_markdown( - "### You're in the setup wizard. Ensure you're supposed to be here, then type yes to continue. If you're not sure, type no to quit." + "### You're in the setup wizard. Ensure you're supposed to be here, then type yes to continue. If you're not sure, type no to quit." ) + # This Input is used to ensure the user is sure they want to continue. -ensureSetupIsRequired = input("Are you sure you want to continue? > ").casefold() -if ensureSetupIsRequired != "yes": - console.print("[red]Exiting...") - time.sleep(0.5) - exit() -else: - # Again, let them know they are about to erase all other setup data. - console.print("[bold red] This will overwrite your current settings. Are you sure you want to continue? [bold green]yes/no") - overwriteSettings = input("Are you sure you want to continue? > ").casefold() - if overwriteSettings != "yes": - console.print("[red]Abort mission! Exiting...") - time.sleep(0.5) - exit() - else: - # Once they confirm, move on with the script. - console.print("[bold green]Alright! Let's get started!") - time.sleep(1) +if input("Are you sure you want to continue? > ").strip().casefold() != "yes": + console.print("[red]Exiting...") + exit() +# This code is inaccessible if the prior check fails, and thus an else statement is unnecessary + +# Again, let them know they are about to erase all other setup data. +console.print( + "[bold red] This will overwrite your current settings. Are you sure you want to continue? [bold green]yes/no" +) + + +if input("Are you sure you want to continue? > ").strip().casefold() != "yes": + console.print("[red]Abort mission! Exiting...") + exit() +# This is once again inaccessible if the prior checks fail +# Once they confirm, move on with the script. +console.print("[bold green]Alright! Let's get started!") + +print("\n") console.log("Ensure you have the following ready to enter:") console.log("[bold green]Reddit Client ID") console.log("[bold green]Reddit Client Secret") @@ -59,64 +102,108 @@ console.log("[bold green]Reddit 2FA (yes or no)") console.log("[bold green]Opacity (range of 0-1, decimals are OK)") console.log("[bold green]Subreddit (without r/ or /r/)") console.log("[bold green]Theme (light or dark)") -time.sleep(0.5) -console.print("[green]If you don't have these, please follow the instructions in the README.md file to set them up.") -console.print("[green]If you do have these, type yes to continue. If you dont, go ahead and grab those quickly and come back.") -confirmUserHasCredentials = input("Are you sure you have the credentials? > ").casefold() -if confirmUserHasCredentials != "yes": - console.print("[red]I don't understand that.") - console.print("[red]Exiting...") - exit() -else: - console.print("[bold green]Alright! Let's get started!") - time.sleep(1) +console.print( + "[green]If you don't have these, please follow the instructions in the README.md file to set them up." +) +console.print( + "[green]If you do have these, type yes to continue. If you dont, go ahead and grab those quickly and come back." +) +print() -""" -Begin the setup process. +if input("Are you sure you have the credentials? > ").strip().casefold() != "yes": + console.print("[red]I don't understand that.") + console.print("[red]Exiting...") + exit() -""" + +console.print("[bold green]Alright! Let's get started!") + +# Begin the setup process. console.log("Enter your credentials now.") -cliID = input("Client ID > ") -cliSec = input("Client Secret > ") -user = input("Username > ") -passw = input("Password > ") -twofactor = input("2fa Enabled? (yes/no) > ") -opacity = input("Opacity? (range of 0-1) > ") -subreddit = input("Subreddit (without r/) > ") -theme = input("Theme? (light or dark) > ") -console.log("Attempting to save your credentials...") -loader = Loader("Saving Credentials...", "Done!").start() - # you can also put a while loop here, e.g. while VideoIsBeingMade == True: ... -time.sleep(0.5) -console.log("Removing old .env file...") -os.remove(".env") -time.sleep(0.5) -console.log("Creating new .env file...") -with open('.env', 'a') as f: - f.write(f'REDDIT_CLIENT_ID="{cliID}"\n') - time.sleep(0.5) - f.write(f'REDDIT_CLIENT_SECRET="{cliSec}"\n') - time.sleep(0.5) - f.write(f'REDDIT_USERNAME="{user}"\n') - time.sleep(0.5) - f.write(f'REDDIT_PASSWORD="{passw}"\n') - time.sleep(0.5) - f.write(f'REDDIT_2FA="{twofactor}"\n') - time.sleep(0.5) - f.write(f'THEME="{theme}"\n') - time.sleep(0.5) - f.write(f'SUBREDDIT="{subreddit}"\n') - time.sleep(0.5) - f.write(f'OPACITY="{opacity}"\n') - -with open('.setup-done-before', 'a') as f: - f.write("This file blocks the setup assistant from running again. Delete this file to run setup again.") +client_id = handle_input( + "Client ID > ", + False, + "[-a-zA-Z0-9._~+/]+=*", + "That is somehow not a correct ID, try again.", + 20, + 40, + "The ID should be over 20 and under 40 characters, double check your input.", +) +client_sec = handle_input( + "Client Secret > ", + False, + "[-a-zA-Z0-9._~+/]+=*", + "That is somehow not a correct secret, try again.", + 20, + 40, + "The secret should be over 20 and under 40 characters, double check your input.", +) +user = handle_input( + "Username > ", + False, + r"[_0-9a-zA-Z]+", + "That is not a valid user", + 3, + 20, + "A username HAS to be between 3 and 20 characters", +) +passw = handle_input("Password > ", False, "", "", 8, None, "Password too short") +twofactor = handle_input( + "2fa Enabled? (yes/no) > ", + False, + r"(yes)|(no)", + "You need to input either yes or no", +) +opacity = handle_input( + "Opacity? (range of 0-1) > ", + float, + "", + "You need to input a number between 0 and 1", + 0, + 1, + "Your number is not between 0 and 1", +) +subreddit = handle_input( + "Subreddit (without r/) > ", + False, + r"[_0-9a-zA-Z]+", + "This subreddit cannot exist, make sure you typed it in correctly and removed the r/ (or /r/).", + 3, + 20, + "A subreddit name HAS to be between 3 and 20 characters", +) +theme = handle_input( + "Theme? (light or dark) > ", + False, + r"(light)|(dark)", + "You need to input 'light' or 'dark'", +) +loader = Loader("Attempting to save your credentials...", "Done!").start() +# you can also put a while loop here, e.g. while VideoIsBeingMade == True: ... +console.log("Writing to the .env file...") +with open(".env", "w") as f: + f.write( + f"""REDDIT_CLIENT_ID="{client_id}" +REDDIT_CLIENT_SECRET="{client_sec}" +REDDIT_USERNAME="{user}" +REDDIT_PASSWORD="{passw}" +REDDIT_2FA="{twofactor}" +THEME="{theme}" +SUBREDDIT="{subreddit}" +OPACITY={opacity} +""" + ) + +with open(".setup-done-before", "w") as f: + f.write( + "This file blocks the setup assistant from running again. Delete this file to run setup again." + ) loader.stop() console.log("[bold green]Setup Complete! Returning...") # Post-Setup: send message and try to run main.py again. -os.system("python3 main.py") +subprocess.call("python3 main.py", shell=True) diff --git a/utils/console.py b/utils/console.py index d024dc0..11ee429 100644 --- a/utils/console.py +++ b/utils/console.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 from rich.console import Console from rich.markdown import Markdown from rich.padding import Padding diff --git a/utils/loader.py b/utils/loader.py index 58fd662..46c40fe 100644 --- a/utils/loader.py +++ b/utils/loader.py @@ -1,9 +1,8 @@ -""" -Okay, have to admit. This code is from StackOverflow. It's so efficient, that it's probably the best way to do it. -Although, it is edited to use less threads. +# Okay, have to admit. This code is from StackOverflow. It's so efficient, that it's probably the best way to do it. +# Although, it is edited to use less threads. + -""" from itertools import cycle from shutil import get_terminal_size from threading import Thread @@ -50,4 +49,4 @@ class Loader: def __exit__(self, exc_type, exc_value, tb): # handle exceptions with those variables ^ - self.stop() \ No newline at end of file + self.stop() diff --git a/video_creation/background.py b/video_creation/background.py index dce46bd..fe7b5ec 100644 --- a/video_creation/background.py +++ b/video_creation/background.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 from random import randrange from yt_dlp import YoutubeDL @@ -13,6 +14,7 @@ def get_start_and_end_times(video_length, length_of_clip): random_time = randrange(180, int(length_of_clip) - int(video_length)) return random_time, random_time + video_length + def download_background(): """Downloads the background video from youtube. diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 93bac6f..8a635d6 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 from moviepy.editor import ( VideoFileClip, AudioFileClip, @@ -7,7 +8,7 @@ from moviepy.editor import ( CompositeAudioClip, CompositeVideoClip, ) -import reddit.subreddit +import reddit.subreddit import re from utils.console import print_step from dotenv import load_dotenv @@ -16,13 +17,12 @@ import os W, H = 1080, 1920 - def make_final_video(number_of_clips): - + # Calls opacity from the .env load_dotenv() - opacity = os.getenv('OPACITY') - + opacity = os.getenv("OPACITY") + print_step("Creating the final video...") VideoFileClip.reW = lambda clip: clip.resize(width=W) @@ -65,7 +65,7 @@ def make_final_video(number_of_clips): .set_position("center") .resize(width=W - 100) .set_opacity(float(opacity)), - ) + ) else: image_clips.insert( 0, @@ -74,13 +74,15 @@ def make_final_video(number_of_clips): .set_position("center") .resize(width=W - 100) .set_opacity(float(opacity)), - ) + ) image_concat = concatenate_videoclips(image_clips).set_position( ("center", "center") ) image_concat.audio = audio_composite final = CompositeVideoClip([background_clip, image_concat]) - filename = (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") for i in range(0, number_of_clips): pass diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index d3d32ef..2925daa 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 from playwright.sync_api import sync_playwright, ViewportSize from pathlib import Path from rich.progress import track @@ -24,7 +25,7 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme): context = browser.new_context() if theme.casefold() == "dark": - cookie_file = open('video_creation/cookies.json') + cookie_file = open("video_creation/cookies.json") cookies = json.load(cookie_file) context.add_cookies(cookies) @@ -58,5 +59,4 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme): path=f"assets/png/comment_{idx}.png" ) - print_substep("Screenshots downloaded Successfully.", - style="bold green") + print_substep("Screenshots downloaded Successfully.", style="bold green") diff --git a/video_creation/voices.py b/video_creation/voices.py index c0df8b7..5a64f7b 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 from gtts import gTTS from pathlib import Path from mutagen.mp3 import MP3 From c028d66b0cdec11c37b4a29fa9ca51f2e0fec807 Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Mon, 6 Jun 2022 20:52:41 +0300 Subject: [PATCH 2/8] fixed run.sh --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 3ee26db..1769e21 100755 --- a/run.sh +++ b/run.sh @@ -1,2 +1,2 @@ #!/bin/sh -docker run -v "$(pwd)/out/:/app/assets" -v "$(pwd)/.env:/app/.env -it rvmt" +docker run -v $(pwd)/out/:/app/assets -v $(pwd)/.env:/app/.env -it rvmt From 86c7b26f00024c50d715f85e6a189eb8e05ddf72 Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Mon, 6 Jun 2022 21:07:33 +0300 Subject: [PATCH 3/8] small regex fix --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 0154ce9..f33daff 100755 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def handle_input( nmax=None, oob_error="", ): - match = re.compile(match) + match = re.compile(match + "$") while True: user_input = input(message + "\n> ").strip() if re.match(match, user_input) is not None: @@ -149,7 +149,7 @@ user = handle_input( 20, "A username HAS to be between 3 and 20 characters", ) -passw = handle_input("Password > ", False, "", "", 8, None, "Password too short") +passw = handle_input("Password > ", False, ".*", "", 8, None, "Password too short") twofactor = handle_input( "2fa Enabled? (yes/no) > ", False, @@ -159,7 +159,7 @@ twofactor = handle_input( opacity = handle_input( "Opacity? (range of 0-1) > ", float, - "", + ".*", "You need to input a number between 0 and 1", 0, 1, @@ -206,4 +206,4 @@ loader.stop() console.log("[bold green]Setup Complete! Returning...") # Post-Setup: send message and try to run main.py again. -subprocess.call("python3 main.py", shell=True) +subprocess.call("python3 main.py", shell=False) From 42861287ef8a2977ea66e4461320f927265d00ec Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Mon, 6 Jun 2022 21:10:21 +0300 Subject: [PATCH 4/8] forgor to change shell back to true :skull: --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f33daff..1ed0e93 100755 --- a/setup.py +++ b/setup.py @@ -206,4 +206,4 @@ loader.stop() console.log("[bold green]Setup Complete! Returning...") # Post-Setup: send message and try to run main.py again. -subprocess.call("python3 main.py", shell=False) +subprocess.call("python3 main.py", shell=True) From d9bf0e509b9d3d746be1a000cc3480f095bd79f2 Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Mon, 6 Jun 2022 21:19:01 +0300 Subject: [PATCH 5/8] main.py surface level refactor --- main.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 92cc886..ea944f0 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,6 @@ #!/usr/bin/env python3 # Main from utils.console import print_markdown -from utils.console import print_step -from utils.console import print_substep from rich.console import Console import time from reddit.subreddit import get_subreddit_threads @@ -10,12 +8,10 @@ from video_creation.background import download_background, chop_background_video from video_creation.voices import save_text_to_mp3 from video_creation.screenshot_downloader import download_screenshots_of_reddit_posts from video_creation.final_video import make_final_video -from utils.loader import Loader from dotenv import load_dotenv +import os console = Console() -from dotenv import load_dotenv -import os, time, shutil configured = True REQUIRED_VALUES = [ @@ -82,9 +78,9 @@ for val in REQUIRED_VALUES: exit() try: float(os.getenv("OPACITY")) -except: +except ValueError: console.log( - f"[red]Please ensure that OPACITY is set between 0 and 1 in your .env file" + "[red]Please ensure that OPACITY is set between 0 and 1 in your .env file" ) configured = False exit() From 24863a9940814c577280fdedfff8a8a80e73eeef Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Mon, 6 Jun 2022 21:20:08 +0300 Subject: [PATCH 6/8] video_creation surface level refactor --- video_creation/final_video.py | 10 +++++----- video_creation/voices.py | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 8a635d6..3cbed3a 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -39,9 +39,9 @@ def make_final_video(number_of_clips): audio_clips = [] for i in range(0, number_of_clips): audio_clips.append(AudioFileClip(f"assets/mp3/{i}.mp3")) - audio_clips.insert(0, AudioFileClip(f"assets/mp3/title.mp3")) + audio_clips.insert(0, AudioFileClip("assets/mp3/title.mp3")) try: - audio_clips.insert(1, AudioFileClip(f"assets/mp3/posttext.mp3")) + audio_clips.insert(1, AudioFileClip("assets/mp3/posttext.mp3")) except: OSError() audio_concat = concatenate_audioclips(audio_clips) @@ -57,10 +57,10 @@ def make_final_video(number_of_clips): .resize(width=W - 100) .set_opacity(float(opacity)), ) - if os.path.exists(f"assets/mp3/posttext.mp3"): + if os.path.exists("assets/mp3/posttext.mp3"): image_clips.insert( 0, - ImageClip(f"assets/png/title.png") + ImageClip("assets/png/title.png") .set_duration(audio_clips[0].duration + audio_clips[1].duration) .set_position("center") .resize(width=W - 100) @@ -69,7 +69,7 @@ def make_final_video(number_of_clips): else: image_clips.insert( 0, - ImageClip(f"assets/png/title.png") + ImageClip("assets/png/title.png") .set_duration(audio_clips[0].duration) .set_position("center") .resize(width=W - 100) diff --git a/video_creation/voices.py b/video_creation/voices.py index 5a64f7b..3d54c40 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -19,18 +19,18 @@ def save_text_to_mp3(reddit_obj): Path("assets/mp3").mkdir(parents=True, exist_ok=True) tts = gTTS(text=reddit_obj["thread_title"], lang="en", slow=False) - tts.save(f"assets/mp3/title.mp3") - length += MP3(f"assets/mp3/title.mp3").info.length + tts.save("assets/mp3/title.mp3") + length += MP3("assets/mp3/title.mp3").info.length try: - Path(f"assets/mp3/posttext.mp3").unlink() - except OSError as e: + Path("assets/mp3/posttext.mp3").unlink() + except OSError: pass if reddit_obj["thread_post"] != "": tts = gTTS(text=reddit_obj["thread_post"], lang="en", slow=False) - tts.save(f"assets/mp3/posttext.mp3") - length += MP3(f"assets/mp3/posttext.mp3").info.length + tts.save("assets/mp3/posttext.mp3") + length += MP3("assets/mp3/posttext.mp3").info.length for idx, comment in track(enumerate(reddit_obj["comments"]), "Saving..."): # ! Stop creating mp3 files if the length is greater than 50 seconds. This can be longer, but this is just a good starting point From 69c8b4a1890363c4157281f4545ed4867483f464 Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Mon, 6 Jun 2022 21:21:17 +0300 Subject: [PATCH 7/8] subreddit.py surface level refactor --- reddit/subreddit.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index a52a214..ff01684 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -1,10 +1,13 @@ #!/usr/bin/env python3 from rich.console import Console -from utils.console import print_markdown, print_step, print_substep +from utils.console import print_step, print_substep from dotenv import load_dotenv +import os +import random +import praw +import re console = Console() -import os, random, praw, re def get_subreddit_threads(): @@ -39,7 +42,7 @@ def get_subreddit_threads(): if not os.getenv("RANDOM_THREAD") or os.getenv("RANDOM_THREAD") == "no": print_substep("Insert the full thread link:", style="bold green") thread_link = input() - print_step(f"Getting the inserted thread...") + print_step("Getting the inserted thread...") submission = reddit.submission(url=thread_link) else: # Otherwise, picks a random thread from the inserted subreddit @@ -80,7 +83,7 @@ def get_subreddit_threads(): } ) - except AttributeError as e: + except AttributeError: pass print_substep("Received AskReddit threads successfully.", style="bold green") From 01c9977549e71db691ce285d92c1e4578892801b Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Mon, 6 Jun 2022 21:35:10 +0300 Subject: [PATCH 8/8] fixed the character bounds for client_ID --- CONTRIBUTING.md | 16 +++++++++------- setup.py | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ad3adb0..71a9aa8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,8 +6,8 @@ All types of contributions are encouraged and valued. See the [Table of Contents > And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: > -> - ⭐ Star the project -> - 📣 Tweet about it +> - ⭐ Star the project +> - 📣 Tweet about it > - 🌲 Refer this project in your project's readme ## Table of Contents @@ -38,8 +38,7 @@ Additionally, there is a [Discord Server](https://discord.gg/swqtb7AsNQ) for any ## I Want To Contribute ### Reporting Bugs - -#### Before Submitting a Bug Report +

Before Submitting a Bug Report

A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible. @@ -53,8 +52,8 @@ A good bug report shouldn't leave others needing to chase you up for more inform - Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant. - Your input and the output - Is the issue reproducable? Does it exist in previous versions? - -#### How Do I Submit a Good Bug Report? +
+

How Do I Submit a Good Bug Report?

We use GitHub issues to track bugs and errors. If you run into an issue with the project: @@ -68,12 +67,13 @@ Once it's filed: - The project team will label the issue accordingly. - A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will try to support you as best as they can, but you may not recieve an instant. - If the team discovers that this is an issue it will be marked `bug` or `error`, as well as possibly other tags relating to the nature of the error), and the issue will be left to be [implemented by someone](#your-first-code-contribution). +
### Suggesting Enhancements This section guides you through submitting an enhancement suggestion for Reddit Video Maker Bot, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions. -#### Before Submitting an Enhancement +

Before Submitting an Enhancement

- Make sure that you are using the latest version. - Read the [documentation](https://luka-hietala.gitbook.io/documentation-for-the-reddit-bot/) carefully and find out if the functionality is already covered, maybe by an individual configuration. @@ -90,6 +90,8 @@ Enhancement suggestions are tracked as [GitHub issues](https://github.com/elebum - You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. - **Explain why this enhancement would be useful** to most users. You may also want to point out the other projects that solved it better and which could serve as inspiration. +
+ ### Your First Code Contribution #### Your environment diff --git a/setup.py b/setup.py index 1ed0e93..b09c30d 100755 --- a/setup.py +++ b/setup.py @@ -127,9 +127,9 @@ client_id = handle_input( False, "[-a-zA-Z0-9._~+/]+=*", "That is somehow not a correct ID, try again.", - 20, - 40, - "The ID should be over 20 and under 40 characters, double check your input.", + 12, + 30, + "The ID should be over 12 and under 30 characters, double check your input.", ) client_sec = handle_input( "Client Secret > ",