|
|
@ -35,22 +35,6 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
|
|
|
|
# ! Make sure the reddit screenshots folder exists
|
|
|
|
# ! Make sure the reddit screenshots folder exists
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
screenshot_num: int
|
|
|
|
|
|
|
|
with sync_playwright() as p:
|
|
|
|
|
|
|
|
print_substep("Launching Headless Browser...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
browser = p.chromium.launch(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
|
|
|
|
|
|
|
|
# so we need a dsf such that the width of the screenshot is greater than the final resolution of the video
|
|
|
|
|
|
|
|
dsf = (W // 600) + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context = browser.new_context(
|
|
|
|
|
|
|
|
locale=lang or "en-us",
|
|
|
|
|
|
|
|
color_scheme="dark",
|
|
|
|
|
|
|
|
viewport=ViewportSize(width=W, height=H),
|
|
|
|
|
|
|
|
device_scale_factor=dsf,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
# set the theme and disable non-essential cookies
|
|
|
|
# set the theme and disable non-essential cookies
|
|
|
|
if settings.config["settings"]["theme"] == "dark":
|
|
|
|
if settings.config["settings"]["theme"] == "dark":
|
|
|
|
cookie_file = open(
|
|
|
|
cookie_file = open(
|
|
|
@ -85,7 +69,25 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
|
|
|
|
transparent = False
|
|
|
|
transparent = False
|
|
|
|
if storymode and settings.config["settings"]["storymodemethod"] == 1:
|
|
|
|
if storymode and settings.config["settings"]["storymodemethod"] == 1:
|
|
|
|
# for idx,item in enumerate(reddit_object["thread_post"]):
|
|
|
|
# for idx,item in enumerate(reddit_object["thread_post"]):
|
|
|
|
|
|
|
|
print_substep("Generating images...")
|
|
|
|
return imagemaker(theme=bgcolor, reddit_obj=reddit_object, txtclr=txtcolor, transparent=transparent)
|
|
|
|
return imagemaker(theme=bgcolor, reddit_obj=reddit_object, txtclr=txtcolor, transparent=transparent)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screenshot_num: int
|
|
|
|
|
|
|
|
with sync_playwright() as p:
|
|
|
|
|
|
|
|
print_substep("Launching Headless Browser...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
browser = p.chromium.launch(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
|
|
|
|
|
|
|
|
# so we need a dsf such that the width of the screenshot is greater than the final resolution of the video
|
|
|
|
|
|
|
|
dsf = (W // 600) + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context = browser.new_context(
|
|
|
|
|
|
|
|
locale=lang or "en-us",
|
|
|
|
|
|
|
|
color_scheme="dark",
|
|
|
|
|
|
|
|
viewport=ViewportSize(width=W, height=H),
|
|
|
|
|
|
|
|
device_scale_factor=dsf,
|
|
|
|
|
|
|
|
)
|
|
|
|
cookies = json.load(cookie_file)
|
|
|
|
cookies = json.load(cookie_file)
|
|
|
|
cookie_file.close()
|
|
|
|
cookie_file.close()
|
|
|
|
|
|
|
|
|
|
|
|