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.
31 lines
988 B
Python
31 lines
988 B
Python
from typing import List
|
|
import json
|
|
from os import getenv
|
|
from utils.console import print_substep
|
|
|
|
def get_subreddit_undone(submissions: List, subreddit):
|
|
"""
|
|
recursively checks if the top submission in the list was already done.
|
|
"""
|
|
with open("./video_creation/data/videos.json", "r") as done_vids_raw:
|
|
done_videos = json.load(done_vids_raw)
|
|
for submission in submissions:
|
|
if already_done(done_videos, submission):
|
|
continue
|
|
if submission.over_18:
|
|
if getenv("ALLOW_NSFW").casefold() == "false":
|
|
print_substep("NSFW Post Detected. Skipping...")
|
|
continue
|
|
return submission
|
|
return get_subreddit_undone(
|
|
subreddit.top(time_filter="hour"), subreddit
|
|
) # all of the videos in hot have already been done
|
|
|
|
|
|
def already_done(done_videos: list, submission):
|
|
|
|
for video in done_videos:
|
|
if video["id"] == str(submission):
|
|
return True
|
|
return False
|