SRT-DeepL-Translator icon indicating copy to clipboard operation
SRT-DeepL-Translator copied to clipboard

Longer subtitles problem

Open andy144 opened this issue 4 years ago • 13 comments

I uninstalled old srt-deepl and reinstalled, then launched it as usual with python -m srt_deepl -g 1000 lines srt works fine, then I tested with 1700 lines and these errors appear:

Traceback (most recent call last): File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/chi/.local/lib/python3.9/site-packages/srt_deepl/main.py", line 112, in translate( File "/home/chi/.local/lib/python3.9/site-packages/srt_deepl/main.py", line 127, in translate subs = translator.translate( File "/home/chi/.local/lib/python3.9/site-packages/srt_deepl/deepl.py", line 84, in translate raise Exception( Exception: Timeout for traslating portion.

andy144 avatar Jun 15 '21 17:06 andy144

It should work without trouble but maybe we can figure out what is wrong. That error happens cause we need to wait until srt portion is translated, maximun 1 min wait, so something deepl can take more, idk, dont think so.

First, check that there are not this character on the srt [...] (including [ and ]). I assume you already check it and there is none. (also i should solve this, it is kind of tedious check for this on each subtitle, but thats another issue).

Try using python -m srt_deepl -g -s (with -s flag to show the browser) and see if the translation in the right text area is completed or not. It should not contain [...].

If you want, send me the srt file i could try on my computer and check if i had the same trouble.

Probably i should change the way the program knows when the translation is done. At the moment it check if the same amount or phrases are in the both text areas and there is no [...] on the translation.

Let me know if you see something, if not, i'll think in another way to check this.

sinedie avatar Jun 15 '21 17:06 sinedie

With -s, 'Access temporarily suspended' message appears. I attach srt here, just change extension, cause srts are not accepted here.

EN David Wilcock Explores Lost Pyramids Of An Advanced Ancient Global Civilization.txt

andy144 avatar Jun 15 '21 17:06 andy144

@andy144 couldnt replicate, it works out of the box on my computer. I dont know why you got access suspended, maybe the proxy was unavailable.

It translate it all in one run.

sinedie avatar Jun 15 '21 18:06 sinedie

Ok, I tried with another computer, same internet connection, but this computer is much slower, and it worked. It took it 5 min for srt I sent you. Then I tried again with the fast computer, and stopped at line 1554 with that [...] error message, after 3 min. Could it be that it was too fast and deepl is catching something? :) I checked dependencies, they are same versions on both computers.

andy144 avatar Jun 16 '21 06:06 andy144

mmm, thats weird, anyway, keep track of #15, when i solve that this should be solved as well. Right now im working, so probably the weekend i'll work on it.

sinedie avatar Jun 16 '21 14:06 sinedie

Subtitles.str `--------------------------------------------------------------------------- TimeoutException Traceback (most recent call last) in 1 from srt_deepl import translate 2 ----> 3 translate( 4 filepath='./captions.srt', 5 lang_from='en',

/opt/anaconda3/envs/general/lib/python3.9/site-packages/srt_deepl/main.py in translate(filepath, lang_from, lang_to, wrap_limit, delete_old, driver) 82 83 if driver is None: ---> 84 proxies = get_proxies() 85 if len(proxies) == 0: 86 proxies = get_proxies(https=False)

/opt/anaconda3/envs/general/lib/python3.9/site-packages/srt_deepl/utils.py in get_proxies(https) 8 9 proxies = [] ---> 10 table_rows = Text(driver, "XPATH", "//tr[@role='row']", multiple=True).text 11 for proxy in table_rows: 12 proxy = proxy.split()

/opt/anaconda3/envs/general/lib/python3.9/site-packages/srt_deepl/elements.py in init(self, driver, locate_by, locate_value, multiple) 8 locator = (getattr(By, locate_by.upper(), "ID"), locate_value) 9 find_element = driver.find_elements if multiple else driver.find_element ---> 10 WebDriverWait(driver, 100).until(lambda driver: find_element(*locator)) 11 self.element = find_element(*locator) 12

/opt/anaconda3/envs/general/lib/python3.9/site-packages/selenium/webdriver/support/wait.py in until(self, method, message) 78 if time.time() > end_time: 79 break ---> 80 raise TimeoutException(message, screen, stacktrace) 81 82 def until_not(self, method, message=''):

TimeoutException: Message: `

SauBuen avatar Sep 09 '21 19:09 SauBuen

In PR #22 there is a new way to get the proxy... Merging when test are complete.

sinedie avatar Jul 21 '22 15:07 sinedie

I was using srt-deepl 0.8.9, last version without proxies, but after deepl updated their site two days ago, this version is also no longer working. Hope to fix the proxy problem on the newest version, or maybe make it work with tor only. Proxies come and go...

andy144 avatar Jul 22 '22 10:07 andy144

@andy144 Upgrade to 0.9.1 version, it works with the new deepl webpage.

Proxy are fixed in the PR #22 but waiting to merge... Also, see the examples folder to see how would you use it with tor.

sinedie avatar Jul 22 '22 13:07 sinedie

With 0.9.1 this is what I get:

Traceback (most recent call last): File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/srt_deepl/main.py", line 112, in translate( File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/srt_deepl/main.py", line 84, in translate proxies = get_proxies() File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/srt_deepl/utils.py", line 10, in get_proxies table_rows = Text(driver, "XPATH", "//tr[@role='row']", multiple=True).text File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/srt_deepl/elements.py", line 10, in init WebDriverWait(driver, 100).until(lambda driver: find_element(*locator)) File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/selenium/webdriver/support/wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:

adding -s argument is opening https://free-proxy-list.net/ page and that's it. Nothing happens.

I tried with tor but when I run tor_driver.py I get

[chi@PC examples]$ python -m tor_driver.py Traceback (most recent call last): File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 188, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 111, in _get_module_details import(pkg_name) File "/home/chi/Traduceri/SRT-DeepL-Translator-master/examples/tor_driver.py", line 1, in import tbselenium.common as cm ModuleNotFoundError: No module named 'tbselenium'

And with the other file I get this:

python -m translate_using_tor_service.py INFO:root:Begin translate process INFO:root:Going to DeepL Traceback (most recent call last): File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 188, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 111, in _get_module_details import(pkg_name) File "/home/chi/Traduceri/SRT-DeepL-Translator-master/examples/translate_using_tor_service.py", line 18, in translate( File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/srt_deepl/main.py", line 103, in translate translator = Translator(driver) File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/srt_deepl/deepl.py", line 16, in init self.driver.get("https://www.deepl.com/translator") File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/chi/.pyenv/versions/3.9.0/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=proxyConnectFailure&u=https%3A//www.deepl.com/translator&c=UTF-8&d=Firefox%20is%20configured%20to%20use%20a%20proxy%20server%20that%20is%20refusing%20connections.

Sorry for the long message...

andy144 avatar Jul 22 '22 14:07 andy144

Ok... in the first error.. yeah, it is the proxy... you could pass your own selenium driver if u want to avoid this issue.... (gonna fixed in the night tho).

The second, need to install "tbselenium" library to make it work

The third... I dont know the way you started tor service... look into https://github.com/sinedie/SRT-DeepL-Translator/issues/18#issuecomment-1111172304

sinedie avatar Jul 22 '22 14:07 sinedie

Ok, it works now. I'm on archlinux and had to install torsocks and tbselenium and to start the tor service. Thanks!

andy144 avatar Jul 22 '22 15:07 andy144

No problem, this weekend proxy issue sould be solved and new version come out. Wait for it.

sinedie avatar Jul 22 '22 15:07 sinedie