deepl-translate icon indicating copy to clipboard operation
deepl-translate copied to clipboard

if I have an account of deepL

Open Maokaitou opened this issue 3 years ago • 12 comments

how to use this with my account? sometime need to translate more than 5000 characters

Maokaitou avatar Oct 18 '21 09:10 Maokaitou

Currently there is no support for using an account to access the official deepl api with my tool.

Check out https://github.com/DeepLcom/deepl-python as this is the official Python library to use.

I may integrate it in the future if enough people want to see this feature.

ptrstn avatar Oct 18 '21 09:10 ptrstn

official api is too expansive, I mean can I use my account to use the web version of deepL so I can use it without the 5000 character limit.

Maokaitou avatar Oct 19 '21 10:10 Maokaitou

official api is too expansive, I mean can I use my account to use the web version of deepL so I can use it without the 5000 character limit.

at last , I have the same require with you.but i have searched all the github ,no one done this feature.

afowne avatar Feb 07 '22 09:02 afowne

I am willing to work on this if someone could provide me further information:

  • Does the official deepl-python package from DeepLcom not work with a DeepL API Free account?
  • What is the benefit of the DeepL API Free API?
  • Does logging in to https://www.deepl.com/translator with the DeepL API Free account increase any limits or give any benefits at all?
  • What are the official limits of using deepl.com without using an account?
  • Is the free remaining free quota visible somewhere?

ptrstn avatar Feb 11 '22 19:02 ptrstn

Does the official deepl-python package from DeepLcom not work with a DeepL API Free account? I think the official deepl-python package from DeepLcom work with a DeepL API Free account.

What is the benefit of the DeepL API Free API? DeepL API Free API has no limit on the number of characters per translation, but only 500,000 per month.

Does logging in to https://www.deepl.com/translator with the DeepL API Free account increase any limits or give any benefits at all? In fact, I will be logging in https://www.deepl.com/translator using a DeepL Pro account https://www.deepl.com/pro , which allows for no word limit per translation and no monthly total limit. If I use the api instead of the web or app, it will charge $25 per 1 million.

What are the official limits of using deepl.com without using an account? Only 5000 characters per translation.

Is the free remaining free quota visible somewhere? I'm not sure, because I don't have a free api account. But I am sure that DeepL Pro account can translate unlimited characters per time using web or app, and the total number of characters per month is also unlimited. You can see a description of the DeepL Pro account here https://www.deepl.com/pro .

Maokaitou avatar Feb 14 '22 05:02 Maokaitou

Okay, I'm not quite sure I understand the problem.

I just setup a DeepL API Free account and tried to translate text using the website, but ran into the following error message:

Your current plan does not include the use of DeepL Translator via our website.

deepl-free-website

Then I tried to translate text using the official deepl-python package and my Deepl API Free account it worked fine:

 deepl --auth-key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx:xx" text "Guten Tag!" --to "ZH"

Output:

日安!

So what is the problem with using the official python package? My package only allows text translation without an account, and signing in doesn't seem to give any advantages over just using the official package.

Edit: From how I understand the pricing page, neither the DeepL API Free nor the DeepL API Pro allows translation using the web translator

DeepL API plans don’t support usage of the web translator. If you want to use a DeepL plug-in with your CAT tool, please purchase an Advanced or Ultimate plan.

deepl-pricing-cut

ptrstn avatar Feb 16 '22 15:02 ptrstn

https://www.deepl.com/pro/change-plan#single

Maokaitou avatar Feb 17 '22 02:02 Maokaitou

Ah, I finally understand what you meant.

There are still some problems before being able to implement this feature.

After analyzing the requests during the login process, I found that the request with the name account?request_type=jsonrpc&il=D&method=login is responsible for it. This is the code to login to deepl.com (generated using Chromium DevTools and Postman):

import requests
import json

url = "https://w.deepl.com/account?request_type=jsonrpc&il=D&method=login"

email = "[email protected]"
password = "xxxxxxxx"
keep_login = True  # ?
login_id = 12345678  # ?
clearance_duration = 29  # ?

payload = json.dumps({
  "jsonrpc": "2.0",
  "method": "login",
  "params": {
    "email": email,
    "password": password,
    "keepLogin": keep_login,
    "version": "44",
    "loginDomain": "default",
    "clearanceInfo": {
      "status": 200,
      "duration": clearance_duration
    }
  },
  "id": login_id
})

headers = {
  'authority': 'w.deepl.com',
  'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="98"',
  'sec-ch-ua-mobile': '?0',
  'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36',
  'sec-ch-ua-platform': '"Linux"',
  'content-type': 'application/json',
  'accept': '*/*',
  'origin': 'https://www.deepl.com',
  'sec-fetch-site': 'same-site',
  'sec-fetch-mode': 'cors',
  'sec-fetch-dest': 'empty',
  'referer': 'https://www.deepl.com/',
  'accept-language': 'de-DE,de;q=0.9',
}

response = requests.request("POST", url, headers=headers, data=payload)

print(json.dumps(response.json(), indent=2))

Output:

{
  "jsonrpc": "2.0",
  "id": 12345678,
  "error": {
    "code": -31999,
    "message": "Insufficient clearance. Please solve challenge and come again",
    "data": {
      "challengeUri": "https://clearance.deepl.com/captcha?redirect_to=https%3A%2F%2Fw.deepl.com%2Fclearance%2Flogin"
    }
  }
}

The challengeUri leads to a captcha solving page, which is currently not easy to complete using python.

I assume the incorrect (?) duration parameter value in the clearanceInfo block prevents proper login.

What has to be found out is the following:

  • how and where is the duration parameter value calculated
  • does the id play a role?
  • does keepLogin play a role?
  • what does "code": -31999 mean?

Edit:

Partial answers:

{
  CLEARANCE_FETCH_FAILURE: 90991,
  CLEARANCE_INSUFFICIENT_BOT_SCORE: -31999,
  CLEARANCE_IP_MISMATCH: -31998,
  TOO_MANY_REQUESTS: 429,
}
c = e.sent
{
    email: t,
    password: n,
    keepLogin: r,
    version: '44',
    loginDomain: 'default',
    clearanceInfo: c
}

tl;dr: its not an easy task.

Basically, function V() in translator_late.min.$41c5cd.js needs to be reverse engineered, in particular how e (which contains c) is set.

ptrstn avatar Feb 17 '22 10:02 ptrstn

Is it possible to run translator_late.min.$41c5cd.js with Python? like pyexecjs?

Maokaitou avatar Feb 18 '22 00:02 Maokaitou

Is it possible to run translator_late.min.$41c5cd.js with Python? like pyexecjs?

There's way more to that, and it's not that easy.

If anyone wants to give it a try, go ahead.

ptrstn avatar Feb 18 '22 03:02 ptrstn

I have tried to use pro account and translated by loading session to simulate web request. But there is no limit as officially stated, after about 500000 characters of translation, the pro account will be cancelled. The pro account I purchased is a kind of team account sold online.

afowne avatar Mar 09 '22 09:03 afowne

I believe the message Insufficient clearance. Please solve challenge and come again is being triggered by cloudflare bot detection. In other words when trying to login using jsonrpc, cloudflare is detecting this is not coming from a browser and is prompting to solve a challenge. I believe to fix this you will have to either fool cloudflare into thinking the request is coming from a browser or you will have to figure out how to solve the challenge.

rteabeault avatar Mar 27 '22 17:03 rteabeault