From 671449caad1e5243c1e4081211b66219f4e04f18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 10:19:58 +0000 Subject: [PATCH 01/16] Bump rich from 12.5.1 to 13.3.1 Bumps [rich](https://github.com/Textualize/rich) from 12.5.1 to 13.3.1. - [Release notes](https://github.com/Textualize/rich/releases) - [Changelog](https://github.com/Textualize/rich/blob/master/CHANGELOG.md) - [Commits](https://github.com/Textualize/rich/compare/v12.5.1...v13.3.1) --- updated-dependencies: - dependency-name: rich dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a9564c0..6cf4689 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ praw==7.6.1 prawcore~=2.3.0 pytube==12.1.0 requests==2.28.1 -rich==12.5.1 +rich==13.3.1 toml==0.10.2 translators==5.3.1 pyttsx3==2.90 From 1f8ebf5eeb3e5bed07c6a0727bf67c5bca050e76 Mon Sep 17 00:00:00 2001 From: electro199 Date: Thu, 2 Feb 2023 15:56:59 +0500 Subject: [PATCH 02/16] Fixed Timeout error and improved return hinting --- TTS/TikTok.py | 7 ++++++- utils/imagenarator.py | 4 ++-- utils/voice.py | 4 ++-- video_creation/screenshot_downloader.py | 15 +++++++++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/TTS/TikTok.py b/TTS/TikTok.py index b370455..ed21a78 100644 --- a/TTS/TikTok.py +++ b/TTS/TikTok.py @@ -79,6 +79,8 @@ vocals: Final[tuple] = ( class TikTok: """TikTok Text-to-Speech Wrapper""" def __init__(self): + if not settings.config['settings']['tts']['tiktok_sessionid']: + raise TikTokTTSException(5) headers = { "User-Agent": "com.zhiliaoapp.musically/2022600030 (Linux; U; Android 7.1.2; es_ES; SM-G988N; " "Build/NRD90M;tt-ok/3.12.13.1)", @@ -140,7 +142,7 @@ class TikTok: return response.json() @staticmethod - def random_voice(): + def random_voice() -> str: return random.choice(eng_voices) @@ -158,5 +160,8 @@ class TikTokTTSException(Exception): if self._code == 4: return f"Code: {self._code}, reason: the speaker doesn't exist, message: {self._message}" + + if self._code == 5: + return f"Would you mind add session id in config ??" return f"Code: {self._message}, reason: unknown, message: {self._message}" diff --git a/utils/imagenarator.py b/utils/imagenarator.py index 8c6dc58..8e3789e 100644 --- a/utils/imagenarator.py +++ b/utils/imagenarator.py @@ -6,7 +6,7 @@ from PIL import Image, ImageDraw, ImageFont from rich.progress import track from TTS.engine_wrapper import process_text -def draw_multiple_line_text(image, text, font, text_color, padding, wrap=50): +def draw_multiple_line_text(image, text, font, text_color, padding, wrap=50) -> None: """ Draw multiline text over given image """ @@ -24,7 +24,7 @@ def draw_multiple_line_text(image, text, font, text_color, padding, wrap=50): # theme=bgcolor,reddit_obj=reddit_object,txtclr=txtcolor -def imagemaker(theme, reddit_obj: dict, txtclr, padding=5): +def imagemaker(theme, reddit_obj: dict, txtclr, padding=5) -> None: """ Render Images for video """ diff --git a/utils/voice.py b/utils/voice.py index a88c87d..76efc20 100644 --- a/utils/voice.py +++ b/utils/voice.py @@ -13,7 +13,7 @@ if sys.version_info[0] >= 3: from datetime import timezone -def check_ratelimit(response: Response): +def check_ratelimit(response: Response) -> bool: """ Checks if the response is a ratelimit response. If it is, it sleeps for the time specified in the response. @@ -30,7 +30,7 @@ def check_ratelimit(response: Response): return True -def sleep_until(time): +def sleep_until(time) -> None: """ Pause your program until a specific end time. 'time' is either a valid datetime object or unix timestamp in seconds (i.e. seconds since Unix epoch) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index 3a76b5b..8e537d1 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -11,6 +11,7 @@ from rich.progress import track from utils import settings from utils.console import print_step, print_substep from utils.imagenarator import imagemaker +from utils.videos import save_data __all__ = ["download_screenshots_of_reddit_posts"] @@ -105,8 +106,18 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): print_substep("Skipping translation...") postcontentpath = f"assets/temp/{reddit_id}/png/title.png" - page.locator('[data-test-id="post-content"]').screenshot(path=postcontentpath) - + try : + page.locator('[data-test-id="post-content"]').screenshot(path=postcontentpath) + + except TimeoutError as e: + print_step("unable to locate post It is possibly Due to a NSFW post or unstable internet") + resp = input("Do you want to skip the post?(y/n)") + if resp.startswith("y"): + save_data("","","skiped",reddit_id,"") + print("Now you can re run the program this post will skipped") + exit() + raise e + if storymode: page.locator('[data-click-id="text"]').first.screenshot( path=f"assets/temp/{reddit_id}/png/story_content.png" From e6e27f32407a8d8dcb3b05034a91f5b6dc5c4f6b Mon Sep 17 00:00:00 2001 From: electro199 Date: Thu, 2 Feb 2023 16:01:55 +0500 Subject: [PATCH 03/16] changed TikTokTTSException msg --- TTS/TikTok.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TTS/TikTok.py b/TTS/TikTok.py index ed21a78..2bcbd6d 100644 --- a/TTS/TikTok.py +++ b/TTS/TikTok.py @@ -162,6 +162,6 @@ class TikTokTTSException(Exception): return f"Code: {self._code}, reason: the speaker doesn't exist, message: {self._message}" if self._code == 5: - return f"Would you mind add session id in config ??" + return f"You have to add session id in config to use titok TTS" return f"Code: {self._message}, reason: unknown, message: {self._message}" From c0916c13bb93612d2752737ded9eebad55d9acb7 Mon Sep 17 00:00:00 2001 From: electro199 Date: Thu, 2 Feb 2023 17:03:51 +0500 Subject: [PATCH 04/16] Add nsfw flag & improved error handling --- reddit/subreddit.py | 1 + video_creation/screenshot_downloader.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 8fb9e9d..ed1e8cf 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -134,6 +134,7 @@ def get_subreddit_threads(POST_ID: str): content["thread_url"] = threadurl content["thread_title"] = submission.title content["thread_id"] = submission.id + content["is_nsfw"] = submission.over_18 content["comments"] = [] if settings.config["settings"]["storymode"]: if settings.config["settings"]["storymodemethod"] == 1: diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index 8e537d1..f7fe7db 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -110,13 +110,18 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): page.locator('[data-test-id="post-content"]').screenshot(path=postcontentpath) except TimeoutError as e: - print_step("unable to locate post It is possibly Due to a NSFW post or unstable internet") - resp = input("Do you want to skip the post?(y/n)") - if resp.startswith("y"): - save_data("","","skiped",reddit_id,"") - print("Now you can re run the program this post will skipped") - exit() - raise e + if settings.config["is_nsfw"] : + print_step("Unable to get post It is due to a NSFW post") + resp = input("Do you want to skip the post?(y/n)") + if resp.casefold().startswith("y"): + save_data("","","skiped",reddit_id,"") + print("Now you can re run the program this post will skipped") + exit() + else: + raise e + + + if storymode: page.locator('[data-click-id="text"]').first.screenshot( From bb06afa56d0511d7e4cd9ecb1e91fdfb0328ff2e Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 2 Feb 2023 15:22:30 +0100 Subject: [PATCH 05/16] Fix for NSFW --- video_creation/screenshot_downloader.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index 3a76b5b..5d608b2 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -4,7 +4,6 @@ from pathlib import Path from typing import Dict, Final import translators as ts -from playwright.async_api import async_playwright # pylint: disable=unused-import from playwright.sync_api import ViewportSize, sync_playwright from rich.progress import track @@ -12,9 +11,9 @@ from utils import settings from utils.console import print_step, print_substep from utils.imagenarator import imagemaker - __all__ = ["download_screenshots_of_reddit_posts"] + def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): """Downloads screenshots of reddit posts as seen on the web. Downloads to assets/temp/png @@ -37,7 +36,7 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): with sync_playwright() as p: print_substep("Launching Headless Browser...") - browser = p.chromium.launch() # headless=False #to check for chrome view + browser = p.chromium.launch(headless=False) # headless=False #to check for chrome view context = browser.new_context() # Device scale factor (or dsf for short) allows us to increase the resolution of the screenshots # When the dsf is 1, the width of the screenshot is 600 pixels @@ -71,6 +70,20 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): context.add_cookies(cookies) # load preference cookies + # Login to Reddit + print_substep("Logging in to Reddit...") + page = context.new_page() + page.goto("https://www.reddit.com/login", timeout=0) + page.set_viewport_size(ViewportSize(width=1920, height=1080)) + page.wait_for_load_state() + + page.locator('[name="username"]').fill(settings.config["reddit"]["creds"]["username"]) + page.locator('[name="password"]').fill(settings.config["reddit"]["creds"]["password"]) + page.locator("button:has-text('Log In')").click() + + page.wait_for_load_state() # Wait for page to fully load and add 5 seconds + page.wait_for_timeout(5000) + # Get the thread screenshot page = context.new_page() page.goto(reddit_object["thread_url"], timeout=0) @@ -151,6 +164,4 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): # close browser instance when we are done using it browser.close() - - - print_substep("Screenshots downloaded Successfully.", style="bold green") \ No newline at end of file + print_substep("Screenshots downloaded Successfully.", style="bold green") From 0a383ff93b84a2e999871e703a8c4b3aeecdef93 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 2 Feb 2023 15:38:38 +0100 Subject: [PATCH 06/16] Improved error-handeling --- video_creation/screenshot_downloader.py | 38 ++++++++++++------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index f7fe7db..2be93b4 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -4,7 +4,6 @@ from pathlib import Path from typing import Dict, Final import translators as ts -from playwright.async_api import async_playwright # pylint: disable=unused-import from playwright.sync_api import ViewportSize, sync_playwright from rich.progress import track @@ -13,9 +12,9 @@ from utils.console import print_step, print_substep from utils.imagenarator import imagemaker from utils.videos import save_data - __all__ = ["download_screenshots_of_reddit_posts"] + def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): """Downloads screenshots of reddit posts as seen on the web. Downloads to assets/temp/png @@ -106,23 +105,24 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): print_substep("Skipping translation...") postcontentpath = f"assets/temp/{reddit_id}/png/title.png" - try : + try: page.locator('[data-test-id="post-content"]').screenshot(path=postcontentpath) - - except TimeoutError as e: - if settings.config["is_nsfw"] : - print_step("Unable to get post It is due to a NSFW post") - resp = input("Do you want to skip the post?(y/n)") - if resp.casefold().startswith("y"): - save_data("","","skiped",reddit_id,"") - print("Now you can re run the program this post will skipped") - exit() + except Exception as e: + OKGREEN = '\033[92m' + WARNING = '\033[93m' + ENDC = '\033[0m' + print_step(f"{WARNING}Something went wrong!{ENDC}") + 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}") + resp = input("Do you want the error traceback for debugging purposes? (y/n)") + if resp.casefold().startswith("y"): + print(e) + exit() else: - raise e - - - - + exit() + if storymode: page.locator('[data-click-id="text"]').first.screenshot( path=f"assets/temp/{reddit_id}/png/story_content.png" @@ -167,6 +167,4 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): # close browser instance when we are done using it browser.close() - - - print_substep("Screenshots downloaded Successfully.", style="bold green") \ No newline at end of file + print_substep("Screenshots downloaded Successfully.", style="bold green") From 25ce2af3508894e42196ee93cf96575be44b865b Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 2 Feb 2023 15:51:43 +0100 Subject: [PATCH 07/16] Fix backgrounds bug --- utils/backgrounds.json | 8 ++++---- video_creation/screenshot_downloader.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/backgrounds.json b/utils/backgrounds.json index 8cb01d1..6e00992 100644 --- a/utils/backgrounds.json +++ b/utils/backgrounds.json @@ -4,13 +4,13 @@ "https://www.youtube.com/watch?v=vw5L4xCPy9Q", "bike-parkour-gta.mp4", "Achy Gaming", - 480 + "center" ], "rocket-league": [ "https://www.youtube.com/watch?v=2X9QGY__0II", "rocket_league.mp4", "Orbital Gameplay", - 200 + "center" ], "minecraft": [ "https://www.youtube.com/watch?v=n_Dv4JMiwK8", @@ -22,7 +22,7 @@ "https://www.youtube.com/watch?v=qGa9kWREOnE", "gta-stunt-race.mp4", "Achy Gaming", - 480 + "center" ], "csgo-surf": [ "https://www.youtube.com/watch?v=E-8JlyO59Io", @@ -34,7 +34,7 @@ "https://www.youtube.com/watch?v=uVKxtdMgJVU", "cluster_truck.mp4", "No Copyright Gameplay", - 480 + "center" ], "minecraft-2": [ "https://www.youtube.com/watch?v=Pt5_GSKIWQM", diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index d3fbf17..71bfb70 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -38,7 +38,7 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): with sync_playwright() as p: print_substep("Launching Headless Browser...") - browser = p.chromium.launch(headless=False) # headless=False #to check for chrome view + browser = p.chromium.launch() # headless=False for debugging context = browser.new_context() # Device scale factor (or dsf for short) allows us to increase the resolution of the screenshots # When the dsf is 1, the width of the screenshot is 600 pixels From 6d177d36b74a15538a9c9560a5a70df65aa5234e Mon Sep 17 00:00:00 2001 From: Simon <65854503+OpenSourceSimon@users.noreply.github.com> Date: Thu, 2 Feb 2023 16:24:54 +0100 Subject: [PATCH 08/16] Version 3.0.1 includes a couple of bug fixes --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index dcb1861..7e4d1b9 100755 --- a/main.py +++ b/main.py @@ -23,7 +23,7 @@ from video_creation.final_video import make_final_video from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts from video_creation.voices import save_text_to_mp3 -__VERSION__ = "3.0" +__VERSION__ = "3.0.1" print( """ From 905c506ff08b57c924b1511c7bc24eb1479b1e05 Mon Sep 17 00:00:00 2001 From: electro199 Date: Fri, 3 Feb 2023 22:53:52 +0500 Subject: [PATCH 09/16] 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 10/16] 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 11/16] 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 12/16] 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 From aacd63116ddfe09439f6ee26068e6510a787898f Mon Sep 17 00:00:00 2001 From: Poogee Date: Thu, 9 Feb 2023 22:25:21 +0300 Subject: [PATCH 13/16] fix: tts blending sentences from diff. paragraphs --- TTS/engine_wrapper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index 6ca63d5..d25b622 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -51,11 +51,18 @@ class TTSEngine: self.length = 0 self.last_clip_length = last_clip_length + def add_periods(self): # adds periods to the end of paragraphs (where people often forget to put them) so tts doesn't blend sentences + for comment in self.reddit_object["comments"]: + comment["comment_body"] = comment["comment_body"].replace('\n', '. ') + if comment["comment_body"][-1] != '.': + comment["comment_body"] += '.' + def run(self) -> Tuple[int, int]: Path(self.path).mkdir(parents=True, exist_ok=True) print_step("Saving Text to MP3 files...") - + + self.add_periods() self.call_tts("title", process_text(self.reddit_object["thread_title"])) # processed_text = ##self.reddit_object["thread_post"] != "" idx = None From b137bb615579477219e59419e7d64a51abae91fc Mon Sep 17 00:00:00 2001 From: Simon <65854503+OpenSourceSimon@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:00:17 +0100 Subject: [PATCH 14/16] Update video_creation/screenshot_downloader.py --- video_creation/screenshot_downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index 806ccc6..009ab17 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -38,7 +38,7 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): with sync_playwright() as p: print_substep("Launching Headless Browser...") - browser = p.chromium.launch() # headless=False for debugging + browser = p.chromium.launch(headless=True) # headless=False will show the browser for debugging purposes context = browser.new_context() # Device scale factor (or dsf for short) allows us to increase the resolution of the screenshots # When the dsf is 1, the width of the screenshot is 600 pixels From 9ce6a38684c79255ef6bc3e2778f5b6830cdb513 Mon Sep 17 00:00:00 2001 From: Simon <65854503+OpenSourceSimon@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:01:11 +0100 Subject: [PATCH 15/16] Update screenshot_downloader.py --- video_creation/screenshot_downloader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index 009ab17..eae0403 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -4,6 +4,7 @@ from pathlib import Path from typing import Dict, Final import translators as ts +from playwright.async_api import async_playwright from playwright.sync_api import ViewportSize, sync_playwright from rich.progress import track From c582b0454ffa4f0c793ccce8ee2664fe4e2a2f1c Mon Sep 17 00:00:00 2001 From: Simon <65854503+OpenSourceSimon@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:04:16 +0100 Subject: [PATCH 16/16] Added comment --- video_creation/screenshot_downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index eae0403..c98fb56 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -4,7 +4,7 @@ from pathlib import Path from typing import Dict, Final import translators as ts -from playwright.async_api import async_playwright +from playwright.async_api import async_playwright # pylint: disable=unused-import from playwright.sync_api import ViewportSize, sync_playwright from rich.progress import track