Fix TikTok error message

pull/1552/head
Simon 2 years ago
parent fcb55e0426
commit d959bf2ce1

@ -79,8 +79,6 @@ vocals: Final[tuple] = (
class TikTok:
"""TikTok Text-to-Speech Wrapper"""
def __init__(self):
if not settings.config['settings']['tts']['tiktok_sessionid']:
raise TikTokTTSException(5)
headers = {
"User-Agent": "com.zhiliaoapp.musically/2022600030 (Linux; U; Android 7.1.2; es_ES; SM-G988N; "
"Build/NRD90M;tt-ok/3.12.13.1)",
@ -161,7 +159,4 @@ class TikTokTTSException(Exception):
if self._code == 4:
return f"Code: {self._code}, reason: the speaker doesn't exist, message: {self._message}"
if self._code == 5:
return f"You have to add session id in config to use titok TTS"
return f"Code: {self._message}, reason: unknown, message: {self._message}"

@ -7,38 +7,31 @@ from pathlib import Path
from subprocess import Popen
from prawcore import ResponseException
from utils.console import print_substep
from reddit.subreddit import get_subreddit_threads
from utils import settings
from utils.cleanup import cleanup
from utils.console import print_markdown, print_step
from utils.id import id
from utils.version import checkversion
from video_creation.background import (
download_background,
chop_background_video,
get_background_config,
)
from video_creation.background import (download_background, chop_background_video, get_background_config, )
from video_creation.final_video import make_final_video
from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts
from video_creation.voices import save_text_to_mp3
__VERSION__ = "3.0.1"
print(
"""
print("""
"""
)
""")
# Modified by JasonLovesDoggo
print_markdown(
"### Thanks for using this tool! [Feel free to contribute to this project on GitHub!](https://lewismenelaws.com) If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue. You can find solutions to many common problems in the [Documentation](): https://reddit-video-maker-bot.netlify.app/"
)
"### Thanks for using this tool! [Feel free to contribute to this project on GitHub!](https://lewismenelaws.com) If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue. You can find solutions to many common problems in the [Documentation](): https://reddit-video-maker-bot.netlify.app/")
checkversion(__VERSION__)
@ -58,8 +51,7 @@ def main(POST_ID=None) -> None:
def run_many(times) -> None:
for x in range(1, times + 1):
print_step(
f'on the {x}{("th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th")[x % 10]} iteration of {times}'
) # correct 1st 2nd 3rd 4th 5th....
f'on the {x}{("th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th")[x % 10]} iteration of {times}') # correct 1st 2nd 3rd 4th 5th....
main()
Popen("cls" if name == "nt" else "clear", shell=True).wait()
@ -80,19 +72,18 @@ def shutdown():
if __name__ == "__main__":
assert sys.version_info >= (3, 9), "Python 3.10 or higher is required"
directory = Path().absolute()
config = settings.check_toml(
f"{directory}/utils/.config.template.toml", "config.toml"
)
config = settings.check_toml(f"{directory}/utils/.config.template.toml", "config.toml")
config is False and exit()
if (not settings.config['settings']['tts']['tiktok_sessionid'] or settings.config['settings']['tts'][
'tiktok_sessionid'] == "") and config["settings"]["tts"]["voice_choice"] == "tiktok":
print_substep("TikTok voice requires a sessionid! Check our documentation on how to obtain one.", "bold red")
exit()
try:
if config["reddit"]["thread"]["post_id"]:
for index, post_id in enumerate(
config["reddit"]["thread"]["post_id"].split("+")
):
for index, post_id in enumerate(config["reddit"]["thread"]["post_id"].split("+")):
index += 1
print_step(
f'on the {index}{("st" if index % 10 == 1 else ("nd" if index % 10 == 2 else ("rd" if index % 10 == 3 else "th")))} post of {len(config["reddit"]["thread"]["post_id"].split("+"))}'
)
f'on the {index}{("st" if index % 10 == 1 else ("nd" if index % 10 == 2 else ("rd" if index % 10 == 3 else "th")))} post of {len(config["reddit"]["thread"]["post_id"].split("+"))}')
main(post_id)
Popen("cls" if name == "nt" else "clear", shell=True).wait()
elif config["settings"]["times_to_run"]:
@ -108,8 +99,10 @@ if __name__ == "__main__":
shutdown()
except Exception as err:
print_step(f'Sorry, something went wrong with this version! Try again, and feel free to report this issue at GitHub or the Discord community.\n'
f'Version: {__VERSION__},Story mode: {str(config["settings"]["storymode"])}, Story mode method: {str(config["settings"]["storymodemethod"])},\n'
f'Postid : {str(config["settings"])},allownsfw :{config["settings"]["allow_nsfw"]},is_nsfw : {str(reddit_object["is_nsfw"])}'
)
config["settings"]["tts"]["tiktok_sessionid"] = "REDACTED"
print_step(
f'Sorry, something went wrong with this version! Try again, and feel free to report this issue at GitHub or the Discord community.\n'
f'Version: {__VERSION__} \n'
f'Error: {err} \n'
f'Config: {config["settings"]}')
raise err

Loading…
Cancel
Save