some test changes
This commit is contained in:
BIN
lib/__pycache__/translate.cpython-310.pyc
Normal file
BIN
lib/__pycache__/translate.cpython-310.pyc
Normal file
Binary file not shown.
@@ -1,10 +1,13 @@
|
||||
#!/usr/bin/pyhton3
|
||||
import requests
|
||||
import time
|
||||
from random import randint
|
||||
|
||||
|
||||
|
||||
def translate(_input, lang='RU'):
|
||||
url = "https://www2.deepl.com/jsonrpc"
|
||||
_id = randint(10000000, 99999999)
|
||||
|
||||
r = requests.post(
|
||||
url,
|
||||
@@ -29,8 +32,14 @@ def translate(_input, lang='RU'):
|
||||
"commonJobParams": {},
|
||||
"timestamp": int(round(time.time() * 1000))
|
||||
},
|
||||
"id": 40890009
|
||||
"id": 40890008
|
||||
}
|
||||
)
|
||||
print(r.json())
|
||||
return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence']
|
||||
print(_id)
|
||||
try:
|
||||
return r.json()['result']['translations'][0]['beams'][0]['postprocessed_sentence']
|
||||
except:
|
||||
print(r.json())
|
||||
|
||||
|
||||
|
||||
|
||||
8
main.py
Normal file → Executable file
8
main.py
Normal file → Executable file
@@ -9,6 +9,7 @@ from lib.translate import translate
|
||||
# path = "C:\Users\riksl\PycharmProjects\weapon-project-extended"
|
||||
|
||||
name = "weapongenerator.lua"
|
||||
_tmp :str = ""
|
||||
|
||||
|
||||
def _lister(_path) -> list:
|
||||
@@ -31,7 +32,6 @@ def parsing_file(f):
|
||||
|
||||
for _str in _list:
|
||||
if _str.find('%_t') != -1 or _str.find('%_T') != -1:
|
||||
print(_str)
|
||||
_to_translate.append(_str)
|
||||
|
||||
return _to_translate
|
||||
@@ -45,9 +45,9 @@ def parsing_file(f):
|
||||
for _str in parsing_file(name):
|
||||
print(_str)
|
||||
test = re.findall('= "(.*[^/])(?: /\*(.*)\*/)?"%_[t|T]', _str)
|
||||
time.sleep(5)
|
||||
print(test)
|
||||
print(translate(test[0][0]), test[0][0])
|
||||
_tmp = _tmp + test[0][0] + '\n'
|
||||
|
||||
print(translate(_tmp))
|
||||
|
||||
def all_to_translate():
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user