sinedie/SRTranslator

Translation timeout (I will post the srt file)

Closed this issue · 15 comments

using 2.3.0 here is the srt

INFO:root:Creating Selenium Webdriver instance
INFO:root:Going to https://www.deepl.com/translator
Loading Anime/[Judas] Horimiya (Season 1) [1080p][HEVC x265 10bit][Multi-Subs]/[Judas] Horimiya - S01E07.srt
... Translating chunk. 0 %
... Translating chunk. 24 %
... Translating chunk. 48 %
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/tbb/.local/lib/python3.10/site-packages/srtranslator/__main__.py", line 110, in <module>
    srt.translate(translator, args.src_lang, args.dest_lang)
  File "/home/tbb/.local/lib/python3.10/site-packages/srtranslator/srt_file.py", line 151, in translate
    translation = translator.translate(
  File "/home/tbb/.local/lib/python3.10/site-packages/srtranslator/translators/deepl_scrap.py", line 133, in translate
    raise TimeOutException("Translation timed out")
srtranslator.translators.base.TimeOutException: Translation timed out
Traceback (most recent call last):
  File "/home/tbb/translate.py", line 104, in <module>
    main(args)
  File "/home/tbb/translate.py", line 24, in main
    translate_srt(srt_file)
  File "/home/tbb/translate.py", line 58, in translate_srt
    subprocess.run(cmd, shell=True, check=True)
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'python -m srtranslator 'Anime/[Judas] Horimiya (Season 1) [1080p][HEVC x265 10bit][Multi-Subs]/[Judas] Horimiya - S01E07.srt' -i en -o tr -v -t deepl-scrap' returned non-zero exit status 1.```

Can't replicate. Maybe try run it with -S flag and show me what happens, cause It works for me.

@sinedie it stucked at 2751/3000 while writing them, if I remember correctly srtranslator over typed these lines and got stuck but I'm not sure about over typing, but im sure it stucked while writing these lines

00:16:58,580 --> 00:16:58,620
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

236
00:16:58,620 --> 00:16:58,660
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

237
00:16:58,660 --> 00:16:58,700
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

238
00:16:58,700 --> 00:16:58,740
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

239
00:16:58,740 --> 00:16:58,780
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

240
00:16:58,780 --> 00:16:58,830
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

241
00:16:58,830 --> 00:16:58,870
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

242
00:16:58,870 --> 00:16:58,910
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

243
00:16:58,910 --> 00:16:58,950
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

244
00:16:58,950 --> 00:16:58,990
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

245
00:16:58,990 --> 00:16:59,030
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

246
00:16:59,030 --> 00:16:59,080
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

247
00:16:59,080 --> 00:16:59,120
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

248
00:16:59,120 --> 00:16:59,160
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

249
00:16:59,160 --> 00:16:59,200
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

250
00:16:59,200 --> 00:16:59,240
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

251
00:16:59,240 --> 00:16:59,280
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

252
00:16:59,280 --> 00:16:59,330
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

253
00:16:59,330 --> 00:16:59,370
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

254
00:16:59,370 --> 00:16:59,410
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

255
00:16:59,410 --> 00:16:59,450
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

256
00:16:59,450 --> 00:16:59,490
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

257
00:16:59,490 --> 00:16:59,530
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

258
00:16:59,530 --> 00:16:59,580
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

259
00:16:59,580 --> 00:16:59,620
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

260
00:16:59,620 --> 00:16:59,660
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

261
00:16:59,660 --> 00:16:59,700
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

262
00:16:59,700 --> 00:16:59,740
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

263
00:16:59,740 --> 00:16:59,780
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

264
00:16:59,780 --> 00:16:59,830
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

265
00:16:59,830 --> 00:16:59,870
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

266
00:16:59,870 --> 00:16:59,910
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

267
00:16:59,910 --> 00:16:59,950
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

268
00:16:59,950 --> 00:16:59,990
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

269
00:16:59,990 --> 00:17:00,040
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

270
00:17:00,040 --> 00:17:00,080
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

271
00:17:00,080 --> 00:17:00,120
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

272
00:17:00,120 --> 00:17:00,160
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

273
00:17:00,160 --> 00:17:00,200
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

274
00:17:00,200 --> 00:17:00,240
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

275
00:17:00,240 --> 00:17:00,290
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

276
00:17:00,290 --> 00:17:00,330
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

277
00:17:00,330 --> 00:17:00,370
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

278
00:17:00,370 --> 00:17:00,410
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

279
00:17:00,410 --> 00:17:00,450
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

280
00:17:00,450 --> 00:17:00,490
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

281
00:17:00,490 --> 00:17:00,540
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

282
00:17:00,540 --> 00:17:00,580
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

283
00:17:00,580 --> 00:17:00,620
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

284
00:17:00,620 --> 00:17:00,660
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

285
00:17:00,660 --> 00:17:00,700
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

286
00:17:00,700 --> 00:17:00,740
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>

287
00:17:00,740 --> 00:17:00,790
<font face="Open Sans Semibold" size="45"><b>{=1}<font size="35">{\an1}<font color="#a0a0a0"><font face="Open Sans"></font></font></font></b>Hurry up and get back
here, dummy.</font>``` 

Translating to spanish is not problem for me. Please run it with -s flag to be sure.

I run it with it already though @sinedie translation was eng to tr, I mean last comment was runned with -s flag i tried to debug it -vv it was the latest log

DEBUG:selenium.webdriver.remote.remote_connection:Finished Request
DEBUG:selenium.webdriver.remote.remote_connection:POST http://localhost:38807/session/ebf7f7bb-78ee-4b53-a0db-153d4d95f32b/execute/sync ```

I guess its about the zoom with the deepl page, I made it %80 and it worked(its ctrl+ - twice) @sinedie (tested it with %80 twice my monitor is 1366*768 ) now the problem is how to make %80 default for selenium

Ok... thats really weird, but I'll try in another resolutions so I can replicate. Ty for invest time finding a solution

adding self.driver.execute_script("document.body.style.zoom='80%'") to def __init__(self, driver: Optional[WebDriver] = None): in deepl_scrap.py solved my problem.

it started again, I guess it because of selected proxy for that session, i guess we should select the proxies by location I mean which is closer to user @sinedie

DeepL page has different version per country... We can do that, but I don't want to mess with getting the current user location, it would be better if you can choose the enabled countries for the proxy.

Also don't want to force the selection of the country, so it could be a custom usage, not built-in in the core, but shown in examples how to do it. Just to keep the core as simple as possible (and also It is a custom configuration, so...)

It could work something like this:

   proxy = create_proxy(country_id=['US']) # the country ids are the ones in https://www.sslproxies.org/
   driver = create_driver(proxy)
   translator = DeeplTranslator(driver)

In CLI usage... maybe enable add your own proxy url? (not sure about that) or even better, always work with US proxies, that way it's gonna be the same page version on each run

Should be fixed on v0.2.4 (hope so)

@sinedie Friend sorry I know i am bothering you but I guess I really found the solution right now!
srtranslator was stuck the lines like this <i></i><i>Frankfurter</i> I delete these coding, and ocnvert them for example Frankfurter it worked, I think srtranslator should handle these cases
Ehh I really dont know there is same styling other subtitles but they works, I dunno.
I am trying again edited version and original version I will post result

And tried again, without editing it does not work, I will provide edited and non edited version of srts to you.
https://send.vis.ee/download/d3079522309a4386/#HL3pAC-d-DIyqlVMNI5Mvg

No problem. But that is not the error. Actually, the first subtitle is <i></i><i></i>. This library indeed handle this cases, and convert the line to an empty string. So.... when deepl translate it the translation length (number of lines) is different from source text length, that's why it timeout : one of the checks to know if translation is done is to check the equalty of those lenghts.

A possible quick solution could be to replace empty string for a ... character. As I really don't want to mess up deleting subtitles lines. And this library is not meant for that.

Gonna work on it. You could just add it by hand by now and translate it. Ty for catching this. 👍

@toprak Solved in v0.2.5 already in PyPi

then we can close this, thanks!