Working but normal mode need improvements on looks

pull/2041/head
cyteon 1 year ago
parent 18eb749bee
commit b34a8d1ae9

@ -104,7 +104,7 @@ def get_subreddit_threads(POST_ID: str):
upvotes = submission.score upvotes = submission.score
ratio = submission.upvote_ratio * 100 ratio = submission.upvote_ratio * 100
num_comments = submission.num_comments 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"Video will be: {submission.title} :thumbsup:", style="bold green")
print_substep(f"Thread url is: {threadurl} :thumbsup:", style="bold green") print_substep(f"Thread url is: {threadurl} :thumbsup:", style="bold green")

@ -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" } 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" } #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)" } 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" } 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] } 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." } 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." }

@ -241,7 +241,7 @@ def make_final_video(
image_clips = list() 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) 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. # Copyright 2024 beingbored (aka. Tim), MIT License, permission granted to use, copy, modify, and distribute.

@ -104,8 +104,8 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
page.set_viewport_size(ViewportSize(width=1920, height=1080)) page.set_viewport_size(ViewportSize(width=1920, height=1080))
page.wait_for_load_state() page.wait_for_load_state()
page.locator(f'input[name="username"]').fill(settings.config["reddit"]["creds"]["username"]) page.locator('[autocomplete="username"]').fill(settings.config["reddit"]["creds"]["username"])
page.locator(f'input[name="password"]').fill(settings.config["reddit"]["creds"]["password"]) page.locator('[autocomplete="current-password"]').fill(settings.config["reddit"]["creds"]["password"])
page.get_by_role("button", name="Log In").click() page.get_by_role("button", name="Log In").click()
page.wait_for_timeout(5000) page.wait_for_timeout(5000)
@ -173,7 +173,7 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
else: else:
print_substep("Skipping translation...") 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" postcontentpath = f"assets/temp/{reddit_id}/png/title.png"
try: try:
if settings.config["settings"]["zoom"] != 1: 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(): if page.locator('[data-testid="content-gate"]').is_visible():
page.locator('[data-testid="content-gate"] button').click() 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 # translate code
@ -247,10 +247,12 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
zoom = settings.config["settings"]["zoom"] zoom = settings.config["settings"]["zoom"]
# zoom the body of the page # zoom the body of the page
page.evaluate("document.body.style.zoom=" + str(zoom)) page.evaluate("document.body.style.zoom=" + str(zoom))
# scroll comment into view # 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 # 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: for i in location:
location[i] = float("{:.2f}".format(location[i] * zoom)) location[i] = float("{:.2f}".format(location[i] * zoom))
page.screenshot( page.screenshot(

Loading…
Cancel
Save