pull/1671/head
Simon 2 years ago
parent 0a1ba17d0e
commit 280b125505

@ -6,7 +6,6 @@ from pathlib import Path
from subprocess import Popen
from typing import NoReturn
import ffmpeg
from prawcore import ResponseException
from utils.console import print_substep
from reddit.subreddit import get_subreddit_threads
@ -62,7 +61,6 @@ def main(POST_ID=None) -> None:
make_final_video(number_of_comments, length, reddit_object, bg_config)
def run_many(times) -> None:
for x in range(1, times + 1):
print_step(
@ -73,30 +71,24 @@ def run_many(times) -> None:
def shutdown() -> NoReturn:
if "redditid" in globals() :
if "redditid" in globals():
print_markdown("## Clearing temp files")
cleanup(redditid)
print("Exiting...")
sys.exit()
print("Exiting...")
sys.exit()
if __name__ == "__main__":
if sys.version_info.major != 3 or sys.version_info.minor != 10:
print("Hey! Congratulations, you've made it so far (which is pretty rare with no Python 3.10). Unfortunately, this program only works on Python 3.10. Please install Python 3.10 and try again.")
sys.exit()
ffmpeg_install() # install ffmpeg if not installed
ffmpeg_install()
directory = Path().absolute()
config = settings.check_toml(
f"{directory}/utils/.config.template.toml", f"{directory}/config.toml"
)
if not config :
sys.exit()
config is False and sys.exit()
if (
not settings.config["settings"]["tts"]["tiktok_sessionid"]
@ -125,10 +117,8 @@ if __name__ == "__main__":
except KeyboardInterrupt:
shutdown()
except ResponseException:
# error for invalid credentials
print_markdown("## Invalid credentials")
print_markdown("Please check your credentials in the config.toml file")
shutdown()
except Exception as err:
config["settings"]["tts"]["tiktok_sessionid"] = "REDACTED"

@ -6,6 +6,9 @@ if exist "%VENV_DIR%" (
call "%VENV_DIR%\Scripts\activate.bat"
)
echo Installing dependencies...
pip install -r requirements.txt
echo Running Python script...
python main.py
@ -13,8 +16,3 @@ if errorlevel 1 (
echo An error occurred. Press any key to exit.
pause >nul
)
if exist "%VENV_DIR%" (
echo Deactivating virtual environment...
call "%VENV_DIR%\Scripts\deactivate.bat"
)

@ -22,13 +22,11 @@ def ffmpeg_install_windows():
for file in os.listdir("ffmpeg/doc"):
os.remove(f"ffmpeg/doc/{file}")
os.rmdir("ffmpeg/doc")
os.rmdir("ffmpeg/LICENSE.txt")
os.remove("ffmpeg/LICENSE.txt")
os.rmdir("ffmpeg/")
print("FFmpeg installed successfully! Please restart your computer and then re-run the program.")
except Exception as e:
print(
"An error occurred while trying to install FFmpeg. Please try again. Otherwise, please install FFmpeg manually and try again."
@ -77,10 +75,13 @@ def ffmpeg_install():
# Try to run the FFmpeg command
subprocess.run(['ffmpeg', '-version'], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except FileNotFoundError as e:
if not os.path.exists("./results") :
# Check if there's ffmpeg.exe in the current directory
if os.path.exists("./ffmpeg.exe"):
print('FFmpeg is installed on this system! If you are seeing this error for the second time, restart your computer.')
print('FFmpeg is not installed on this system.')
resp = input(
"We can try to automatically install it for you. Would you like to do that? (y/n): "
)
if resp.lower() == "y":
print("Installing FFmpeg...")
if os.name == "nt":

@ -1,5 +1,6 @@
import os
import re
import time
from typing import List
import spacy
@ -9,19 +10,19 @@ from utils.voice import sanitize_text
# working good
def posttextparser(obj,*,tried:bool=False) -> List[str]:
text:str = re.sub("\n", " ", obj)
def posttextparser(obj, *, tried: bool = False) -> List[str]:
text: str = re.sub("\n", " ", obj)
try:
nlp = spacy.load("en_core_web_sm")
except OSError as e:
if not tried:
os.system("python -m spacy download en_core_web_sm")
return posttextparser(obj,tried=True)
print_step(" The spacy model can't load. You need to install it with the command \npython -m spacy download en_core_web_sm ")
time.sleep(5)
return posttextparser(obj, tried=True)
print_step(
"The spacy model can't load. You need to install it with the command \npython -m spacy download en_core_web_sm ")
raise e
doc = nlp(text)
newtext: list = []

@ -1,20 +0,0 @@
import sys
from typing import NoReturn
from utils import settings
from utils.console import print_substep
def validat_env(obj) -> NoReturn | None:
"""
check for wrong
"""
if (
settings.config["settings"]["tts"]["tiktok_sessionid"] == ""
and settings.config["settings"]["tts"]["voice_choice"] == "tiktok"
):
print_substep(
"TikTok voice requires a sessionid! Check our documentation on how to obtain one.",
"bold red",
)
sys.exit()
Loading…
Cancel
Save