refactor: screenshot_downloader.py uses toml config
This commit is contained in:
1 file changed
+6
-6
@@ -1,9 +1,9 @@
|
||||
import json
|
||||
import os
|
||||
from os import getenv
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
from utils import settings
|
||||
from playwright.async_api import async_playwright # pylint: disable=unused-import
|
||||
|
||||
# do not remove the above line
|
||||
@@ -35,7 +35,7 @@ def download_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: in
|
||||
browser = p.chromium.launch()
|
||||
context = browser.new_context()
|
||||
|
||||
if getenv("THEME").upper() == "DARK":
|
||||
if settings.config["settings"]["theme"] == "dark":
|
||||
cookie_file = open("./video_creation/data/cookie-dark-mode.json", encoding="utf-8")
|
||||
else:
|
||||
cookie_file = open("./video_creation/data/cookie-light-mode.json", encoding="utf-8")
|
||||
@@ -56,7 +56,7 @@ def download_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: in
|
||||
|
||||
# translate code
|
||||
|
||||
if getenv("POSTLANG"):
|
||||
if settings.config["reddit"]["thread"]["post_lang"]:
|
||||
print_substep("Translating post...")
|
||||
texts_in_tl = ts.google(reddit_object["thread_title"], to_language=os.getenv("POSTLANG"))
|
||||
|
||||
@@ -88,9 +88,9 @@ def download_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: in
|
||||
|
||||
# translate code
|
||||
|
||||
if getenv("POSTLANG"):
|
||||
if settings.config["reddit"]["thread"]["post_lang"]:
|
||||
comment_tl = ts.google(
|
||||
comment["comment_body"], to_language=os.getenv("POSTLANG")
|
||||
comment["comment_body"], to_language=settings.config["reddit"]["thread"]["post_lang"]
|
||||
)
|
||||
page.evaluate(
|
||||
'([tl_content, tl_id]) => document.querySelector(`#t1_${tl_id} > div:nth-child(2) > div > div[data-testid="comment"] > div`).textContent = tl_content',
|
||||
|
||||
Reference in new issue
Block a user