From d1bb2d1a8af9a0d48e3f2370a2b7c52868266010 Mon Sep 17 00:00:00 2001 From: Kristian Date: Wed, 20 Mar 2024 14:03:16 +0100 Subject: [PATCH] Fix for new UI by changing domain --- TTS/streamlabs_polly.py | 2 +- reddit/subreddit.py | 2 +- video_creation/data/videos.json | 51 ++++++++++++++++++++++++- video_creation/screenshot_downloader.py | 12 +++--- 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/TTS/streamlabs_polly.py b/TTS/streamlabs_polly.py index dddeedc..9ecabf4 100644 --- a/TTS/streamlabs_polly.py +++ b/TTS/streamlabs_polly.py @@ -45,7 +45,7 @@ class StreamlabsPolly: voice = str(settings.config["settings"]["tts"]["streamlabs_polly_voice"]).capitalize() body = {"voice": voice, "text": text, "service": "polly"} headers = {"Referer" : "https://streamlabs.com/" } - response = requests.post(self.url, headers=headers,data=body) + response = requests.post(self.url, headers=headers, data=body) if not check_ratelimit(response): self.run(text, filepath, random_voice) diff --git a/reddit/subreddit.py b/reddit/subreddit.py index e1def23..419cf79 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -106,7 +106,7 @@ def get_subreddit_threads(POST_ID: str): upvotes = submission.score ratio = submission.upvote_ratio * 100 num_comments = submission.num_comments - threadurl = f"https://reddit.com{submission.permalink}" + threadurl = f"https://new.reddit.com/{submission.permalink}" print_substep(f"Video will be: {submission.title} :thumbsup:", style="bold green") print_substep(f"Thread url is: {threadurl} :thumbsup:", style="bold green") diff --git a/video_creation/data/videos.json b/video_creation/data/videos.json index fe51488..674d67b 100644 --- a/video_creation/data/videos.json +++ b/video_creation/data/videos.json @@ -1 +1,50 @@ -[] +[ + { + "subreddit": "", + "id": "1bhrs61", + "time": "1710787283", + "background_credit": "", + "reddit_title": "skipped", + "filename": "" + }, + { + "subreddit": "", + "id": "1bhk4f3", + "time": "1710787512", + "background_credit": "", + "reddit_title": "skipped", + "filename": "" + }, + { + "subreddit": "", + "id": "1bhwnnw", + "time": "1710791048", + "background_credit": "", + "reddit_title": "skipped", + "filename": "" + }, + { + "subreddit": "askreddit", + "id": "1bi9nhh", + "time": "1710859130", + "background_credit": "bbswitzer", + "reddit_title": "What is something presently happening that people dont realize could have huge consequences", + "filename": "What is something presently happening that people dont realize could have huge consequences.mp4" + }, + { + "subreddit": "askreddit", + "id": "1bimyrg", + "time": "1710869538", + "background_credit": "bbswitzer", + "reddit_title": "What do you think the USA will be most known for 100 years from now", + "filename": "What do you think the USA will be most known for 100 years from now.mp4" + }, + { + "subreddit": "", + "id": "1bilpoz", + "time": "1710870790", + "background_credit": "", + "reddit_title": "skipped", + "filename": "" + } +] \ No newline at end of file diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index cdc8d61..fb60bfc 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -75,7 +75,7 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): print_substep("Launching Headless Browser...") browser = p.chromium.launch( - headless=True + headless=False ) # headless=False will show the browser for debugging purposes # 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 @@ -100,9 +100,9 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): 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[class$='m-full-width']").click() + page.locator(f'input[name="username"]').fill(settings.config["reddit"]["creds"]["username"]) + page.locator(f'input[name="password"]').fill(settings.config["reddit"]["creds"]["password"]) + page.get_by_role("button", name="Log In").click() page.wait_for_timeout(5000) login_error_div = page.locator(".AnimatedForm__errorMessage").first @@ -220,7 +220,7 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): if page.locator('[data-testid="content-gate"]').is_visible(): page.locator('[data-testid="content-gate"] button').click() - page.goto(f'https://reddit.com{comment["comment_url"]}', timeout=0) + page.goto(f"https://new.reddit.com/{comment['comment_url']}") # translate code @@ -263,4 +263,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") + print_substep("Screenshots downloaded Successfully.", style="bold green") \ No newline at end of file