Fix TikTok error message

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

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

@ -7,38 +7,31 @@ from pathlib import Path
from subprocess import Popen from subprocess import Popen
from prawcore import ResponseException from prawcore import ResponseException
from utils.console import print_substep
from reddit.subreddit import get_subreddit_threads from reddit.subreddit import get_subreddit_threads
from utils import settings from utils import settings
from utils.cleanup import cleanup from utils.cleanup import cleanup
from utils.console import print_markdown, print_step from utils.console import print_markdown, print_step
from utils.id import id from utils.id import id
from utils.version import checkversion from utils.version import checkversion
from video_creation.background import ( from video_creation.background import (download_background, chop_background_video, get_background_config, )
download_background,
chop_background_video,
get_background_config,
)
from video_creation.final_video import make_final_video from video_creation.final_video import make_final_video
from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts
from video_creation.voices import save_text_to_mp3 from video_creation.voices import save_text_to_mp3
__VERSION__ = "3.0.1" __VERSION__ = "3.0.1"
print( print("""
"""
""" """)
)
# Modified by JasonLovesDoggo # Modified by JasonLovesDoggo
print_markdown( 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__) checkversion(__VERSION__)
@ -58,8 +51,7 @@ def main(POST_ID=None) -> None:
def run_many(times) -> None: def run_many(times) -> None:
for x in range(1, times + 1): for x in range(1, times + 1):
print_step( print_step(
f'on the {x}{("th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th")[x % 10]} iteration of {times}' 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....
) # correct 1st 2nd 3rd 4th 5th....
main() main()
Popen("cls" if name == "nt" else "clear", shell=True).wait() Popen("cls" if name == "nt" else "clear", shell=True).wait()
@ -80,19 +72,18 @@ def shutdown():
if __name__ == "__main__": if __name__ == "__main__":
assert sys.version_info >= (3, 9), "Python 3.10 or higher is required" assert sys.version_info >= (3, 9), "Python 3.10 or higher is required"
directory = Path().absolute() directory = Path().absolute()
config = settings.check_toml( config = settings.check_toml(f"{directory}/utils/.config.template.toml", "config.toml")
f"{directory}/utils/.config.template.toml", "config.toml"
)
config is False and exit() 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: try:
if config["reddit"]["thread"]["post_id"]: if config["reddit"]["thread"]["post_id"]:
for index, post_id in enumerate( for index, post_id in enumerate(config["reddit"]["thread"]["post_id"].split("+")):
config["reddit"]["thread"]["post_id"].split("+")
):
index += 1 index += 1
print_step( 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) main(post_id)
Popen("cls" if name == "nt" else "clear", shell=True).wait() Popen("cls" if name == "nt" else "clear", shell=True).wait()
elif config["settings"]["times_to_run"]: elif config["settings"]["times_to_run"]:
@ -108,8 +99,10 @@ if __name__ == "__main__":
shutdown() shutdown()
except Exception as err: 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' config["settings"]["tts"]["tiktok_sessionid"] = "REDACTED"
f'Version: {__VERSION__},Story mode: {str(config["settings"]["storymode"])}, Story mode method: {str(config["settings"]["storymodemethod"])},\n' print_step(
f'Postid : {str(config["settings"])},allownsfw :{config["settings"]["allow_nsfw"]},is_nsfw : {str(reddit_object["is_nsfw"])}' 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 raise err

Loading…
Cancel
Save