|
|
@ -19,16 +19,16 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme):
|
|
|
|
# ! Make sure the reddit screenshots folder exists
|
|
|
|
# ! Make sure the reddit screenshots folder exists
|
|
|
|
Path("assets/png").mkdir(parents=True, exist_ok=True)
|
|
|
|
Path("assets/png").mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
with sync_playwright() as p:
|
|
|
|
with sync_playwright() as browser_:
|
|
|
|
print_substep("Launching Headless Browser...")
|
|
|
|
print_substep("Launching Headless Browser...")
|
|
|
|
|
|
|
|
|
|
|
|
browser = p.chromium.launch()
|
|
|
|
browser = browser_.chromium.launch()
|
|
|
|
context = browser.new_context()
|
|
|
|
context = browser.new_context()
|
|
|
|
|
|
|
|
|
|
|
|
if theme.casefold() == "dark":
|
|
|
|
if theme.casefold() == "dark":
|
|
|
|
cookie_file = open("video_creation/cookies.json")
|
|
|
|
with open("video_creation/cookies.json", encoding="utf-8") as cookie_file:
|
|
|
|
cookies = json.load(cookie_file)
|
|
|
|
cookies = json.load(cookie_file)
|
|
|
|
context.add_cookies(cookies)
|
|
|
|
context.add_cookies(cookies)
|
|
|
|
|
|
|
|
|
|
|
|
# Get the thread screenshot
|
|
|
|
# Get the thread screenshot
|
|
|
|
page = context.new_page()
|
|
|
|
page = context.new_page()
|
|
|
@ -45,8 +45,8 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
for idx, comment in track(
|
|
|
|
for idx, comment in track(
|
|
|
|
enumerate(reddit_object["comments"]), "Downloading screenshots..."
|
|
|
|
enumerate(reddit_object["comments"]), "Downloading screenshots..."
|
|
|
|
):
|
|
|
|
):
|
|
|
|
|
|
|
|
|
|
|
|
# Stop if we have reached the screenshot_num
|
|
|
|
# Stop if we have reached the screenshot_num
|
|
|
|
if idx >= screenshot_num:
|
|
|
|
if idx >= screenshot_num:
|
|
|
|