reformatted using black

command
"black . --line-length 101"
pull/560/head
Jason 3 years ago
parent e6501f4337
commit c482266e5c

@ -59,9 +59,7 @@ class POLLY:
f.write(voice_data.content) f.write(voice_data.content)
except (KeyError, JSONDecodeError): except (KeyError, JSONDecodeError):
if response.json()["error"] == "Text length is too long!": if response.json()["error"] == "Text length is too long!":
chunks = [ chunks = [m.group().strip() for m in re.finditer(r" *((.{0,499})(\.|.$))", req_text)]
m.group().strip() for m in re.finditer(r" *((.{0,499})(\.|.$))", req_text)
]
audio_clips = [] audio_clips = []
cbn = sox.Combiner() cbn = sox.Combiner()

@ -67,7 +67,9 @@ noneng = [
class TikTok: # TikTok Text-to-Speech Wrapper class TikTok: # TikTok Text-to-Speech Wrapper
def __init__(self): def __init__(self):
self.URI_BASE = "https://api16-normal-useast5.us.tiktokv.com/media/api/text/speech/invoke/?text_speaker=" self.URI_BASE = (
"https://api16-normal-useast5.us.tiktokv.com/media/api/text/speech/invoke/?text_speaker="
)
def tts( def tts(
self, self,

@ -6,7 +6,7 @@ from TTS.GTTS import GTTS
from TTS.POLLY import POLLY from TTS.POLLY import POLLY
from TTS.TikTok import TikTok from TTS.TikTok import TikTok
CHOICE_DIR = {"tiktok": TikTok, "gtts": GTTS, 'polly': POLLY} CHOICE_DIR = {"tiktok": TikTok, "gtts": GTTS, "polly": POLLY}
class TTS: class TTS:
@ -15,7 +15,5 @@ class TTS:
CHOICE = getenv("TTsChoice").casefold() CHOICE = getenv("TTsChoice").casefold()
valid_keys = [key.lower() for key in CHOICE_DIR.keys()] valid_keys = [key.lower() for key in CHOICE_DIR.keys()]
if CHOICE not in valid_keys: if CHOICE not in valid_keys:
raise ValueError( raise ValueError(f"{CHOICE} is not valid. Please use one of these {valid_keys} options")
f"{CHOICE} is not valid. Please use one of these {valid_keys} options"
)
return CHOICE_DIR.get(CHOICE)() return CHOICE_DIR.get(CHOICE)()

@ -40,14 +40,10 @@ def handle_input(
except ValueError: except ValueError:
console.log("[red]" + err_message) # Type conversion failed console.log("[red]" + err_message) # Type conversion failed
continue continue
if ( if nmin is not None and len(user_input) < nmin: # Check if string is long enough
nmin is not None and len(user_input) < nmin
): # Check if string is long enough
console.log("[red]" + oob_error) console.log("[red]" + oob_error)
continue continue
if ( if nmax is not None and len(user_input) > nmax: # Check if string is not too long
nmax is not None and len(user_input) > nmax
): # Check if string is not too long
console.log("[red]" + oob_error) console.log("[red]" + oob_error)
continue continue
break break

@ -5,9 +5,7 @@ from os.path import exists
def cleanup() -> int: def cleanup() -> int:
if exists("./assets/temp"): if exists("./assets/temp"):
count = 0 count = 0
files = [ files = [f for f in os.listdir(".") if f.endswith(".mp4") and "temp" in f.lower()]
f for f in os.listdir(".") if f.endswith(".mp4") and "temp" in f.lower()
]
count += len(files) count += len(files)
for f in files: for f in files:
os.remove(f) os.remove(f)

@ -18,7 +18,7 @@ def get_subreddit_undone(submissions: List, subreddit):
print_substep("NSFW Post Detected. Skipping...") print_substep("NSFW Post Detected. Skipping...")
continue continue
return submission return submission
print('all submissions have been done going by top submission order') print("all submissions have been done going by top submission order")
return get_subreddit_undone( return get_subreddit_undone(
subreddit.top(time_filter="hour"), subreddit subreddit.top(time_filter="hour"), subreddit
) # all of the videos in hot have already been done ) # all of the videos in hot have already been done

@ -40,9 +40,7 @@ def download_background():
"assets/backgrounds", filename=f"{credit}-{filename}" "assets/backgrounds", filename=f"{credit}-{filename}"
) )
print_substep( print_substep("Background videos downloaded successfully! 🎉", style="bold green")
"Background videos downloaded successfully! 🎉", style="bold green"
)
def chop_background_video(video_length): def chop_background_video(video_length):

@ -51,9 +51,7 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num):
'[data-click-id="text"] button' '[data-click-id="text"] button'
).click() # Remove "Click to see nsfw" Button in Screenshot ).click() # Remove "Click to see nsfw" Button in Screenshot
page.locator('[data-test-id="post-content"]').screenshot( page.locator('[data-test-id="post-content"]').screenshot(path="assets/temp/png/title.png")
path="assets/temp/png/title.png"
)
if storymode: if storymode:
page.locator('[data-click-id="text"]').screenshot( page.locator('[data-click-id="text"]').screenshot(
path="assets/temp/png/story_content.png" path="assets/temp/png/story_content.png"

Loading…
Cancel
Save