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 1/2] 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 bb06afa56d0511d7e4cd9ecb1e91fdfb0328ff2e Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 2 Feb 2023 15:22:30 +0100 Subject: [PATCH 2/2] 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")