Better anti NSFW

Instead of looking at the screen to look if it's nsfw it checks it earlier so it doesn't have to create all the mp3's and open the browser to do it. Also it fixes some errors because of it cause playwright was being buggy with it for some reason.
pull/418/head
PatatjeMC 2 years ago
parent 3b49adffc1
commit 73b2a29f1a

@ -1,6 +1,7 @@
from typing import List from typing import List
import json import json
from os import getenv
from utils.console import print_substep
def get_subreddit_undone(submissions: List, subreddit): def get_subreddit_undone(submissions: List, subreddit):
""" """
@ -11,6 +12,10 @@ def get_subreddit_undone(submissions: List, subreddit):
for submission in submissions: for submission in submissions:
if already_done(done_videos, submission): if already_done(done_videos, submission):
continue continue
if submission.over_18:
if getenv("ALLOW_NSFW").casefold() == "false":
print_substep("NSFW Post Detected. Skipping...")
continue
return submission return submission
return get_subreddit_undone( return get_subreddit_undone(
subreddit.top(time_filter="hour"), subreddit subreddit.top(time_filter="hour"), subreddit

@ -42,12 +42,6 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num):
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.
if getenv("ALLOW_NSFW").casefold() == "false":
print_substep("NSFW Post Detected. Skipping...")
from main import main
main()
print_substep("Post is NSFW. You are spicy... :fire:") print_substep("Post is NSFW. You are spicy... :fire:")
page.locator('[data-testid="content-gate"] button').click() page.locator('[data-testid="content-gate"] button').click()

Loading…
Cancel
Save