reverted unnecessary changes

pull/963/head
Drugsosos 2 years ago
parent 15aa7fa45b
commit ec2292bae3
No known key found for this signature in database
GPG Key ID: 8E35176FE617E28D

@ -37,9 +37,7 @@ print_markdown(
print_step(f"You are using v{__VERSION__} of the bot")
async def main(
POST_ID=None
):
async def main(POST_ID=None):
cleanup()
reddit_object = get_subreddit_threads(POST_ID)
comments_created = save_text_to_mp3(reddit_object)
@ -84,7 +82,7 @@ if __name__ == "__main__":
Popen("cls" if name == "nt" else "clear", shell=True).wait()
else:
main()
except KeyboardInterrupt:
except KeyboardInterrupt: # TODO wont work with async code
shutdown()
except ResponseException:
# error for invalid credentials

@ -10,9 +10,7 @@ from utils.videos import check_done
from utils.voice import sanitize_text
def get_subreddit_threads(
POST_ID: str
):
def get_subreddit_threads(POST_ID: str):
"""
Returns a list of threads from the AskReddit subreddit.
"""

@ -3,13 +3,13 @@ import toml
from rich.console import Console
import re
from typing import Tuple, Dict
from typing import Tuple, Dict, Optional
from utils.console import handle_input
console = Console()
config = dict() # calling instance of a dict to calm lint down (dict[any] will work as well)
config: Optional[dict] = None # autocomplete
def crawl(obj: dict, func=lambda x, y: print(x, y, end="\n"), path=None):

@ -57,7 +57,7 @@ def get_subreddit_undone(submissions: list, subreddit, times_checked=0):
return get_subreddit_undone(
subreddit.top(
time_filter=VALID_TIME_FILTERS[index], limit=100
time_filter=VALID_TIME_FILTERS[index], limit=(50 if int(index) == 0 else index + 1 * 50)
),
subreddit,
times_checked=index,

@ -1,3 +1,5 @@
from __future__ import annotations
from typing import Tuple
from PIL import ImageFont, Image, ImageDraw, ImageEnhance
@ -26,7 +28,7 @@ class Video:
draw = ImageDraw.Draw(wm)
w, h = draw.textsize(text, font)
draw.text(((width - w) / 2, (height - h) / 2), text, white, font)
en = ImageEnhance.Brightness(wm) # TODO allow it to use the fontsize
en = ImageEnhance.Brightness(wm) # todo allow it to use the fontsize
mask = en.enhance(1 - opacity)
im.paste(wm, (25, 25), mask)
im.save(path)
@ -40,11 +42,13 @@ class Video:
ndigits=2,
)
position = (compensation, position[1])
# print(f'{compensation=}')
# print(f'{position=}')
img_clip = self._create_watermark(text, opacity=opacity, fontsize=fontsize)
img_clip = img_clip.set_opacity(opacity).set_duration(duration)
img_clip = img_clip.set_position(
position, relative=True
) # TODO get data from utils/CONSTANTS.py and adapt position accordingly
) # todo get data from utils/CONSTANTS.py and adapt position accordingly
# Overlay the img clip on the first video clip
self.video = CompositeVideoClip([self.video, img_clip])

@ -10,9 +10,7 @@ if sys.version_info[0] >= 3:
from datetime import timezone
def check_ratelimit(
response: Response,
):
def check_ratelimit(response: Response):
"""
Checks if the response is a ratelimit response.
If it is, it sleeps for the time specified in the response.

@ -38,7 +38,7 @@ def get_background_config():
# Handle default / not supported background using default option.
# Default : pick random from supported background.
if choice not in background_options:
if not choice or choice not in background_options:
choice = random.choice(list(background_options.keys()))
return background_options[choice]

@ -57,7 +57,7 @@ class FinalVideo:
name = re.sub(r"(\d+)\s?/\s?(\d+)", r"\1 of \2", name)
name = re.sub(r"(\w+)\s?/\s?(\w+)", r"\1 or \2", name)
name = re.sub(r"/", "", name)
# name[:30] # the hell this little guy does? commented until explained
# name[:30] # does nothing
lang = settings.config["reddit"]["thread"]["post_lang"]
if lang:

@ -89,6 +89,7 @@ class Browser:
default_Viewport: dict = attrib(
validator=instance_of(dict),
default={
# 9x21 to see long posts
"defaultViewport": {
"width": 500,
"height": 1200,

@ -3,7 +3,6 @@ from TTS.GTTS import GTTS
from TTS.streamlabs_polly import StreamlabsPolly
from TTS.aws_polly import AWSPolly
from TTS.TikTok import TikTok
from utils import settings
from utils.console import print_table, print_step
@ -41,11 +40,7 @@ def save_text_to_mp3(
return engine_instance.run()
def get_case_insensitive_key_value(
input_dict,
key,
) -> object:
# TODO add a factory later
def get_case_insensitive_key_value(input_dict, key):
return next(
(value for dict_key, value in input_dict.items() if dict_key.lower() == key.lower()),
None,

Loading…
Cancel
Save