from srtranslator import SrtFile
from srtranslator.translators.translatepy import TranslatePy
translator = TranslatePy()
filepath = "video.srt"
srt = SrtFile(filepath)
srt.translate(translator, "en", "id")
# Making the result subtitles prettier
srt.wrap_lines()
srt.save(f"{os.path.splitext(filepath)[0]}_translated.srt")
Traceback (most recent call last):
File "/app/plugins/code_runner.py", line 24, in code_runner
await aexec(cmd, bot, update)
File "/app/plugins/code_runner.py", line 61, in aexec
return await locals()["__aexec"](bot, update)
File "", line 7, in __aexec
File "/usr/local/lib/python3.9/site-packages/srtranslator/srt_file.py", line 156, in translate
translation = translation.splitlines()
AttributeError: 'NoneType' object has no attribute 'splitlines'