sinedie / SRTranslator

SRT files translator
Do What The F*ck You Want To Public License
219 stars 27 forks source link

Timed out trying to get element #90

Closed h9052300 closed 4 months ago

h9052300 commented 4 months ago

Timed out trying to get element (XPATH = //button[@data-testid='translator-lang-option-zh'] | //button[text()='Chinese'])

sinedie commented 4 months ago

Are you translating FROM chinese or TO chinese?

h9052300 commented 4 months ago

Translation from English to Chinese. Thx~

sinedie commented 4 months ago

Deepl use two chinese options for target language (TO chinese).

Those are zh-Hans for simplified and zh-Hant for traditional. Use that instead of zh, this only works if translation is FROM chinese. I may update the docs soon.

pd: I don't remember if options should be case sensitive, so better write them as it is.

h9052300 commented 4 months ago

Thank you very much.

sinedie commented 4 months ago

Docs are updated here.

Closing it

h9052300 commented 4 months ago

from srtranslator.translators.deepl_scrap import DeeplTranslator

translator = DeeplTranslator(driver=driver)

oo = translator.translate("going to pull the small one for auto completion and a big one for actually", 'en', "zh-Hant") print(oo)

translator.quit()

Traceback (most recent call last): File "C:\Users\user\Desktop\Python Project\flask_view\videoToOOXX\srtranslatorTest.py", line 61, in oo = translator.translate("going to pull the small one for auto completion and a big one for actually", 'en', "zh-Hant") File "C:\Users\user\Desktop\Python Project\flask_view\venv\lib\site-packages\srtranslator\translators\deepl_scrap.py", line 137, in translate self._set_destination_language(destination_language) File "C:\Users\user\Desktop\Python Project\flask_view\venv\lib\site-packages\srtranslator\translators\deepl_scrap.py", line 108, in _set_destination_language self._set_language(language, "//*[@data-testid='translator-target-lang']") File "C:\Users\user\Desktop\Python Project\flask_view\venv\lib\site-packages\srtranslator\translators\deepl_scrap.py", line 119, in _set_language x_path_by_text = f"//button[text()='{self.languages[language]}']" KeyError: 'zh-Hant'

How can I adjust it?

sinedie commented 1 month ago

@h9052300 I haven't seen this, sry. Do you still have this issue? If so, pls reopen