Skip to content
This repository has been archived by the owner on Mar 18, 2023. It is now read-only.

Change browser to tor #12

Closed
andy144 opened this issue Jun 4, 2021 · 9 comments
Closed

Change browser to tor #12

andy144 opened this issue Jun 4, 2021 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@andy144
Copy link

andy144 commented Jun 4, 2021

Right now I have to translate many long subtitles (about 1600 lines each).
I noticed that deepl doesn't accept that and suspends your access for a while.
I then split them in 2 and it worked like a charm, for about 5-6 srts, after which
they suspended my access again.
So, question: can you change browser to Tor? :)
I translated some docx files like that, you know,
by having other ip on every Tor instance.
Or maybe tell me how to do it, if it's not very complicated.
Even better would be to make an option for choosing tor (not everybody uses it).
thanks

@sinedie sinedie self-assigned this Jun 5, 2021
@sinedie sinedie added the enhancement New feature or request label Jun 5, 2021
@sinedie
Copy link
Owner

sinedie commented Jun 5, 2021

OK... so, it brings up a problem i didnt think when writing it. DeepL is really good caching bots.

One posible solution could be copy and pasting the text with commands (ctrl + c and ctrl + v). Tried but doesnt seems to work. Other, could be change the browser to Tor like you say and create a different IP for each file translated.

That brings into my mind to enable an argument for each major browser (including Tor of course) and other argument for choosing the translator (cause deepl alone could not fullfill all the user requirements -maybe another languages that deepl doesnt support or something, idk-)

By the moment idk how to do it, never tried Tor at all, but should be the same, just change the selenium webdriver. Give me some time to think about it and came out with a solution. By the moment seems like you should reduce the SRT trafric on deepl.

Also, another advantage with Tor and different IPs is to open multiple instances of the browser for each portion of the srt and translate it simultaneously, reducing the translation time, but could be overkill, idk, it is worth to think about it too.

@sinedie
Copy link
Owner

sinedie commented Jun 9, 2021

In this moment I'm really busy so this will move slowly. I will work on it when I can, seems promising.

@sinedie
Copy link
Owner

sinedie commented Jun 14, 2021

@andy144 Manage to solve it with a different aproach. SRT-DeepL will continue to work with Geckodriver and Firefox by default, but now you can pass your own selenium web driver like an argument, so you could create your own Tor web driver and use it. Check the example folder (didnt try it tho, so maybe it is broken)

If u dont want to use Tor by any reason, now the default driver use a random free proxy on each instace, so it should not ban you even if you use it like you had been doing it

Gonna leave the issue open till you can confirm that it works. Didnt have the time to try with more than two srts.

This change should be in the v9.0, so dont forget to update

@andy144
Copy link
Author

andy144 commented Jun 15, 2021

Yes, it works now to bypass banning,
but still doesn't work for longer subtitles.
Anyway, it's fine for me like this,
I found that if I split srt files to have maximum about 500 lines,
and send fragments one by one, it's ok.
Maybe, when you have time, it would be great to have this splitting done automatically.
Thing is, splitting has to be done on end of phrases,
so the translation won't be affected.
In the end, translated fragments have to be joined, of course.
But as I said, for me is fine like this, I can do it manually with subtitle edit.
Change it only if you want to improve it.
Thanks again, you're great! :)

@sinedie
Copy link
Owner

sinedie commented Jun 15, 2021

Wait, how long are your subtitles? it works for me without any trouble. This program should slice the subtitle in 5000 characters and traslate portion by portion (each portion take care of the end of phrases as you said and wrap the line if needed). Idk the total length of the ones i had translated, but 2h long movie's srt works fine. Could you give me an example of what you are saying?.

Also, i think this should be in a different issue, just in case anyone needs it. If i manage to see the error i'll create it myself. Thank you :D.

@sinedie sinedie closed this as completed Jun 15, 2021
@andy144
Copy link
Author

andy144 commented Jun 15, 2021

Try with a srt longer than 1700 lines. Something like 2000.

@sinedie
Copy link
Owner

sinedie commented Jun 15, 2021

Can't replicate, I just translated 6000 lines long srt. Does it throw any error? or what happens? (please create another issue)

@andy144
Copy link
Author

andy144 commented Jun 15, 2021

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.

                Make sure your SRT file does not contain the characters '[...]'

@sinedie
Copy link
Owner

sinedie commented Jun 15, 2021

@andy144 could you create a new issue?, so i could answer you there

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants