From 90be9e09b3dc5027f11ebdd83e6a149f5f256e80 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 3 Jul 2022 12:43:44 -0400 Subject: [PATCH] fixed the typehiting that @HallowedDust5 broke for py versions < 3.9 --- utils/videos.py | 7 ++++--- video_creation/final_video.py | 4 +++- video_creation/screenshot_downloader.py | 5 +++-- video_creation/voices.py | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/utils/videos.py b/utils/videos.py index f675ecf..3a456cd 100755 --- a/utils/videos.py +++ b/utils/videos.py @@ -2,6 +2,7 @@ import json import os import time from os import getenv +from typing import Dict from praw.models import Submission @@ -9,16 +10,16 @@ from utils.console import print_step def check_done( - redditobj: dict[str], + redditobj: Dict[str], ) -> Submission: # don't set this to be run anyplace that isn't subreddit.py bc of inspect stack """Checks if the chosen post has already been generated Args: - redditobj (dict[str]): Reddit object gotten from reddit/subreddit.py + redditobj (Dict[str]): Reddit object gotten from reddit/subreddit.py Returns: - dict[str]|None: Reddit object in args + Dict[str]|None: Reddit object in args """ with open("./video_creation/data/videos.json", "r", encoding="utf-8") as done_vids_raw: diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 852c4b2..e429dbc 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -3,6 +3,7 @@ import multiprocessing import os import re from os.path import exists +from typing import Dict from moviepy.editor import ( VideoFileClip, @@ -25,12 +26,13 @@ console = Console() W, H = 1080, 1920 -def make_final_video(number_of_clips: int, length: int, reddit_obj: dict[str]): +def make_final_video(number_of_clips: int, length: int, reddit_obj: Dict[str]): """Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp Args: number_of_clips (int): Index to end at when going through the screenshots length (int): Length of the video + reddit_obj (Dict[str]): The reddit object that contains the posts to read. """ print_step("Creating the final video 🎥") VideoFileClip.reW = lambda clip: clip.resize(width=W) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index aa1c9d9..670a472 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -2,6 +2,7 @@ import json import os from os import getenv from pathlib import Path +from typing import Dict from playwright.async_api import async_playwright # pylint: disable=unused-import @@ -16,11 +17,11 @@ from utils.console import print_step, print_substep storymode = False -def download_screenshots_of_reddit_posts(reddit_object: dict[str], screenshot_num: int): +def download_screenshots_of_reddit_posts(reddit_object: Dict[str], screenshot_num: int): """Downloads screenshots of reddit posts as seen on the web. Downloads to assets/temp/png Args: - reddit_object (dict[str]): Reddit object received from reddit/subreddit.py + reddit_object (Dict[str]): Reddit object received from reddit/subreddit.py screenshot_num (int): Number of screenshots to downlaod """ diff --git a/video_creation/voices.py b/video_creation/voices.py index 240c851..d02a14e 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os +from typing import Dict, Tuple from rich.console import Console @@ -23,7 +24,7 @@ TTSProviders = { } -def save_text_to_mp3(reddit_obj: dict[str]) -> tuple[int, int]: +def save_text_to_mp3(reddit_obj: Dict[str]) -> Tuple[int, int]: """Saves text to MP3 files. Args: