add: NSFW to videos.json

pull/894/head
Tomovic 3 years ago
parent 40bfcf468e
commit 14b7f574b7

@ -34,7 +34,7 @@ def check_done(
return redditobj return redditobj
def save_data(filename: str, reddit_title: str, reddit_id: str, credit: str): def save_data(filename: str, reddit_title: str, reddit_id: str, credit: str, NSFW: bool):
"""Saves the videos that have already been generated to a JSON file in video_creation/data/videos.json """Saves the videos that have already been generated to a JSON file in video_creation/data/videos.json
Args: Args:
@ -42,6 +42,7 @@ def save_data(filename: str, reddit_title: str, reddit_id: str, credit: str):
@param filename: @param filename:
@param reddit_id: @param reddit_id:
@param reddit_title: @param reddit_title:
@param NSFW:
""" """
with open("./video_creation/data/videos.json", "r+", encoding="utf-8") as raw_vids: with open("./video_creation/data/videos.json", "r+", encoding="utf-8") as raw_vids:
done_vids = json.load(raw_vids) done_vids = json.load(raw_vids)
@ -53,6 +54,7 @@ def save_data(filename: str, reddit_title: str, reddit_id: str, credit: str):
"background_credit": credit, "background_credit": credit,
"reddit_title": reddit_title, "reddit_title": reddit_title,
"filename": filename, "filename": filename,
"nsfw": NSFW,
} }
done_vids.append(payload) done_vids.append(payload)
raw_vids.seek(0) raw_vids.seek(0)

@ -28,6 +28,10 @@ console = Console()
W, H = 1080, 1920 W, H = 1080, 1920
nsfw = False
def isNSFW():
global nsfw
nsfw = True
def name_normalize(name: str) -> str: def name_normalize(name: str) -> str:
name = re.sub(r'[?\\"%*:|<>]', "", name) name = re.sub(r'[?\\"%*:|<>]', "", name)
@ -115,7 +119,7 @@ def make_final_video(
filename = f"{name_normalize(title)}.mp4" filename = f"{name_normalize(title)}.mp4"
subreddit = settings.config["reddit"]["thread"]["subreddit"] subreddit = settings.config["reddit"]["thread"]["subreddit"]
save_data(filename, title, idx, background_config[2]) save_data(filename, title, idx, background_config[2], nsfw)
if not exists(f"./results/{subreddit}"): if not exists(f"./results/{subreddit}"):
print_substep("The results folder didn't exist so I made it") print_substep("The results folder didn't exist so I made it")

@ -12,6 +12,7 @@ from rich.progress import track
import translators as ts import translators as ts
from utils.console import print_step, print_substep from utils.console import print_step, print_substep
from video_creation.final_video import isNSFW
storymode = False storymode = False
@ -47,6 +48,7 @@ def download_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: in
if page.locator('[data-testid="content-gate"]').is_visible(): if page.locator('[data-testid="content-gate"]').is_visible():
# This means the post is NSFW and requires to click the proceed button. # This means the post is NSFW and requires to click the proceed button.
isNSFW()
print_substep("Post is NSFW. You are spicy...") print_substep("Post is NSFW. You are spicy...")
page.locator('[data-testid="content-gate"] button').click() page.locator('[data-testid="content-gate"] button').click()
page.locator( page.locator(

Loading…
Cancel
Save