HTTPError: 429 Client Error: Too many requests
In particular, when running the unit tests, deepl.com sometimes returns an Error 429: Too many requests.
Structured testing should be done to determine when this error occurs and what time periods are allowed without returning an error.
Another approach to fix this is to add a retry_after argument to wait a certain number of milliseconds between each request.
Another solution could be to implement support for proxies as suggested in: https://github.com/ytdl-org/youtube-dl/issues/22839
A potential problem could be that the generated data always contains the exact same id and not the generated one.
https://github.com/ptrstn/deepl-translate/blob/ca61c63ff23031291fbaf220de92018fb85a57f0/deepl/generators.py#L5-L14
https://github.com/ptrstn/deepl-translate/blob/ca61c63ff23031291fbaf220de92018fb85a57f0/deepl/generators.py#L41-L64
https://github.com/ptrstn/deepl-translate/blob/ca61c63ff23031291fbaf220de92018fb85a57f0/deepl/hacks.py#L21-L22
This id should probably be maintained and incremented in a translation session.
A potential problem could be that the generated data always contains the exact same id and not the generated one.
https://github.com/ptrstn/deepl-translate/blob/ca61c63ff23031291fbaf220de92018fb85a57f0/deepl/generators.py#L5-L14
https://github.com/ptrstn/deepl-translate/blob/ca61c63ff23031291fbaf220de92018fb85a57f0/deepl/generators.py#L41-L64
https://github.com/ptrstn/deepl-translate/blob/ca61c63ff23031291fbaf220de92018fb85a57f0/deepl/hacks.py#L21-L22
This
idshould probably be maintained and incremented in a translation session.
Hi, I did some research and believe it is a generated field. Could try decompile the Windows client to get some inspiration
Hi, I did some research and believe it is a generated field. Could try decompile the Windows client to get some inspiration
Yes, it is generated and the javascript is quite simply.
utils.chunk.js:1511
var l = 1e4 * Math.round(1e4 * Math.random())
utils.chunk.js:1532
return function h(y, m) {
var g = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 0
, b = ++l
, w = {
jsonrpc: "2.0",
method: t,
params: void 0 !== y ? y : {},
id: b
}
In Python:
def generate_id() -> int:
"""
From utils.chunk.$16023f.js:formatted:1511
var l = 1e4 * Math.round(1e4 * Math.random())
:return:
"""
return int(1e4) * round(1e4 * random.random())
I still experienced the HTTP 429 error though. Not sure when I will find some time to do some experiments.
also deepl uses fake timestamp
Try below
fn gen_fake_timestamp(texts: &Vec<String>) -> u128 {
let ts = tool::get_epoch_ms();
let i_count = texts
.iter()
.fold(
1,
|s, t| s + t.text.matches('i').count()
) as u128;
ts - ts % i_count + i_count
}
if u know chinese, try read https://zu1k.com/posts/thinking/deception-tactics-in-deepl-api-design/
also deepl uses fake timestamp
Try below
fn gen_fake_timestamp(texts: &Vec<String>) -> u128 { let ts = tool::get_epoch_ms(); let i_count = texts .iter() .fold( 1, |s, t| s + t.text.matches('i').count() ) as u128; ts - ts % i_count + i_count }if u know chinese, try read https://zu1k.com/posts/thinking/deception-tactics-in-deepl-api-design/
Yes, thanks. Its already implemented in https://github.com/ptrstn/deepl-translate/blob/master/deepl/hacks.py
@ptrstn
See https://github.com/rx-ts/deepl-translate/blob/master/src/api.ts#L30-L40
Stringified "method":" need to be changed a bit. 😂