mirror of
https://github.com/barkeser2002/srtranslator-bariskeser.git
synced 2026-09-25 03:49:55 +03:00
19 lines
521 B
Python
19 lines
521 B
Python
import httpx
|
|
import json
|
|
from .base import Translator
|
|
|
|
|
|
class DeepLX(Translator):
|
|
max_char = 1500
|
|
|
|
def translate(self, text: str, source_language: str, destination_language: str):
|
|
deeplx_api = "http://node-kyb.bariskeser.com:1188/translate"
|
|
data = {
|
|
"text": text,
|
|
"source_lang": source_language,
|
|
"target_lang": destination_language
|
|
}
|
|
post_data = json.dumps(data)
|
|
result = httpx.post(url = deeplx_api, data = post_data).text
|
|
return result
|