From 905c506ff08b57c924b1511c7bc24eb1479b1e05 Mon Sep 17 00:00:00 2001 From: electro199 Date: Fri, 3 Feb 2023 22:53:52 +0500 Subject: [PATCH 1/4] reformated the propmt --- utils/console.py | 10 +++++----- video_creation/screenshot_downloader.py | 16 +++++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/utils/console.py b/utils/console.py index 3419f05..7ac8a70 100644 --- a/utils/console.py +++ b/utils/console.py @@ -10,28 +10,28 @@ from rich.text import Text console = Console() -def print_markdown(text): +def print_markdown(text) -> None: """Prints a rich info message. Support Markdown syntax.""" md = Padding(Markdown(text), 2) console.print(md) -def print_step(text): +def print_step(text) -> None: """Prints a rich info message.""" panel = Panel(Text(text, justify="left")) console.print(panel) -def print_table(items): +def print_table(items) -> None: """Prints items in a table.""" console.print(Columns([Panel(f"[yellow]{item}", expand=True) for item in items])) -def print_substep(text, style=""): - """Prints a rich info message without the panelling.""" +def print_substep(text, style="") -> None: + """Prints a rich colored info message without the panelling.""" console.print(text, style=style) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index d3fbf17..9239245 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -123,20 +123,18 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): try: page.locator('[data-test-id="post-content"]').screenshot(path=postcontentpath) except Exception as e: - OKGREEN = '\033[92m' - WARNING = '\033[93m' - ENDC = '\033[0m' - print_step(f"{WARNING}Something went wrong!{ENDC}") + print_substep("Something went wrong!",style="red") resp = input("Something went wrong with making the screenshots! Do you want to skip the post? (y/n) ") + if resp.casefold().startswith("y"): save_data("", "", "skipped", reddit_id, "") - print(f"{OKGREEN}The post is successfully skipped! You can now restart the program and this post will skipped.{ENDC}") + print_substep("The post is successfully skipped! You can now restart the program and this post will skipped.","green") + resp = input("Do you want the error traceback for debugging purposes? (y/n)") - if resp.casefold().startswith("y"): - print(e) - exit() - else: + if not resp.casefold().startswith("y"): exit() + + raise e if storymode: page.locator('[data-click-id="text"]').first.screenshot( From 64c8118379f7d52b60f21c2aeb9e71efa3373419 Mon Sep 17 00:00:00 2001 From: electro199 Date: Fri, 3 Feb 2023 23:05:50 +0500 Subject: [PATCH 2/4] imporved error message --- main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index dcb1861..50ca371 100755 --- a/main.py +++ b/main.py @@ -110,9 +110,8 @@ if __name__ == "__main__": except Exception as err: print_step(f''' Sorry, something went wrong with this version! Try again, and feel free to report this issue at GitHub or the Discord community.\n - Version: {__VERSION__} \n - Story mode: {str(config["settings"]["storymode"])} \n - Story mode method: {str(config["settings"]["storymodemethod"])} + Version: {__VERSION__},Story mode: {str(config["settings"]["storymode"])}, Story mode method: {str(config["settings"]["storymodemethod"])}, + Postid : {str(config["settings"])},allownsfw :{config["settings"]["allow_nsfw"]},is_nsfw : {reddit_object["is_nsfw"]} ''') raise err # todo error From 6af57bfd1dc1c78538220776bfc09b3b6b519451 Mon Sep 17 00:00:00 2001 From: electro199 Date: Fri, 3 Feb 2023 23:14:26 +0500 Subject: [PATCH 3/4] better error message --- main.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 50ca371..e1ebd84 100755 --- a/main.py +++ b/main.py @@ -42,7 +42,7 @@ print_markdown( checkversion(__VERSION__) -def main(POST_ID=None): +def main(POST_ID=None) -> None: global redditid ,reddit_object reddit_object = get_subreddit_threads(POST_ID) redditid = id(reddit_object) @@ -55,7 +55,7 @@ def main(POST_ID=None): make_final_video(number_of_comments, length, reddit_object, bg_config) -def run_many(times): +def run_many(times) -> None: for x in range(1, times + 1): print_step( f'on the {x}{("th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th")[x % 10]} iteration of {times}' @@ -108,10 +108,9 @@ if __name__ == "__main__": shutdown() except Exception as err: - print_step(f''' - Sorry, something went wrong with this version! Try again, and feel free to report this issue at GitHub or the Discord community.\n - Version: {__VERSION__},Story mode: {str(config["settings"]["storymode"])}, Story mode method: {str(config["settings"]["storymodemethod"])}, - Postid : {str(config["settings"])},allownsfw :{config["settings"]["allow_nsfw"]},is_nsfw : {reddit_object["is_nsfw"]} - ''') + print_step(f'Sorry, something went wrong with this version! Try again, and feel free to report this issue at GitHub or the Discord community.\n' + f'Version: {__VERSION__},Story mode: {str(config["settings"]["storymode"])}, Story mode method: {str(config["settings"]["storymodemethod"])},\n' + f'Postid : {str(config["settings"])},allownsfw :{config["settings"]["allow_nsfw"]},is_nsfw : {str(reddit_object["is_nsfw"])}' + ) raise err # todo error From fb70901db36c98ebdf7e2c52660e983ea40ddaf8 Mon Sep 17 00:00:00 2001 From: Syed Aman Raza <109358640+electro199@users.noreply.github.com> Date: Sat, 4 Feb 2023 00:45:55 +0500 Subject: [PATCH 4/4] Update main.py Co-authored-by: Simon <65854503+OpenSourceSimon@users.noreply.github.com> --- main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/main.py b/main.py index e1ebd84..6bbf615 100755 --- a/main.py +++ b/main.py @@ -113,4 +113,3 @@ if __name__ == "__main__": f'Postid : {str(config["settings"])},allownsfw :{config["settings"]["allow_nsfw"]},is_nsfw : {str(reddit_object["is_nsfw"])}' ) raise err - # todo error