diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 5f2ac5f..d30d6ba 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -104,7 +104,7 @@ def get_subreddit_threads(POST_ID: str): upvotes = submission.score ratio = submission.upvote_ratio * 100 num_comments = submission.num_comments - threadurl = f"https://new.reddit.com/{submission.permalink}" + threadurl = f"https://www.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/utils/.config.template.toml b/utils/.config.template.toml index 09a20ee..90f286a 100644 --- a/utils/.config.template.toml +++ b/utils/.config.template.toml @@ -26,7 +26,6 @@ times_to_run = { optional = false, default = 1, example = 2, explanation = "Used opacity = { optional = false, default = 0.9, example = 0.8, explanation = "Sets the opacity of the comments when overlayed over the background", type = "float", nmin = 0, nmax = 1, oob_error = "The opacity HAS to be between 0 and 1", input_error = "The opacity HAS to be a decimal number between 0 and 1" } #transition = { optional = true, default = 0.2, example = 0.2, explanation = "Sets the transition time (in seconds) between the comments. Set to 0 if you want to disable it.", type = "float", nmin = 0, nmax = 2, oob_error = "The transition HAS to be between 0 and 2", input_error = "The opacity HAS to be a decimal number between 0 and 2" } mememode = { optional = true, type = "bool", default = false, example = false, options = [true, false,], explanation = "Only show post content, and multipile of them (no comments)" } -memes_per_vid = { optional = true, default = 10, example = 10, explanation = "Number of memes per video", type = "int", nmin = 1, oob_error = "It's very hard to run something less than once." } storymode = { optional = true, type = "bool", default = false, example = false, options = [true, false,], explanation = "Only read out title and post content, great for subreddits with stories" } storymodemethod= { optional = true, default = 1, example = 1, explanation = "Style that's used for the storymode. Set to 0 for single picture display in whole video, set to 1 for fancy looking video ", type = "int", nmin = 0, oob_error = "It's very hard to run something less than once.", options = [0, 1] } storymode_max_length = { optional = true, default = 1000, example = 1000, explanation = "Max length of the storymode video in characters. 200 characters are approximately 50 seconds.", type = "int", nmin = 1, oob_error = "It's very hard to make a video under a second." } diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 8ed9de9..e4d9367 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -241,7 +241,7 @@ def make_final_video( image_clips = list() - if not settings.config["settings"]["mememode"] and settings.config["settings"]["storymodemethod"] == 1: + if not settings.config["settings"]["mememode"]: Path(f"assets/temp/{reddit_id}/png").mkdir(parents=True, exist_ok=True) # Copyright 2024 beingbored (aka. Tim), MIT License, permission granted to use, copy, modify, and distribute. diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index 3e9ef40..7839b56 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -103,9 +103,9 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): 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(f'input[name="username"]').fill(settings.config["reddit"]["creds"]["username"]) - page.locator(f'input[name="password"]').fill(settings.config["reddit"]["creds"]["password"]) + + page.locator('[autocomplete="username"]').fill(settings.config["reddit"]["creds"]["username"]) + page.locator('[autocomplete="current-password"]').fill(settings.config["reddit"]["creds"]["password"]) page.get_by_role("button", name="Log In").click() page.wait_for_timeout(5000) @@ -173,7 +173,7 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): else: print_substep("Skipping translation...") - if mememode or settings.config["settings"]["storymodemethod"] == 0: + if mememode or settings.config["settings"]["storymodemethod"] == 0 and settings.config["settings"]["storymode"]: postcontentpath = f"assets/temp/{reddit_id}/png/title.png" try: if settings.config["settings"]["zoom"] != 1: @@ -227,7 +227,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://www.reddit.com{comment['comment_url']}") + page.goto(f"https://www.reddit.com/{comment['comment_url']}") # translate code @@ -247,10 +247,12 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): zoom = settings.config["settings"]["zoom"] # zoom the body of the page page.evaluate("document.body.style.zoom=" + str(zoom)) + # scroll comment into view - page.locator(f"#t1_{comment['comment_id']}").scroll_into_view_if_needed() + page.locator(f"#thing_t1_{comment['comment_id']} > div.entry.unvoted").scroll_into_view_if_needed() # as zooming the body doesn't change the properties of the divs, we need to adjust for the zoom - location = page.locator(f"#t1_{comment['comment_id']}").bounding_box() + location = page.locator(f"#thing_t1_{comment['comment_id']} > div.entry.unvoted").bounding_box()#thing_t1_l37rczw > div.entry.unvoted + for i in location: location[i] = float("{:.2f}".format(location[i] * zoom)) page.screenshot(