mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-26 23:24:13 +08:00
.
This commit is contained in:
parent
658bfd1723
commit
bd6786b924
@ -1,7 +1,7 @@
|
||||
|
||||
set(VERSION_MAJOR 6)
|
||||
set(VERSION_MINOR 14)
|
||||
set(VERSION_PATCH 1)
|
||||
set(VERSION_PATCH 2)
|
||||
set(VERSION_REVISION 0)
|
||||
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
|
||||
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)
|
||||
|
@ -5,21 +5,18 @@ import re, time
|
||||
class OCR(baseocr):
|
||||
|
||||
def ocr(self, imagebinary):
|
||||
# https://github.com/AuroraWright/owocr/blob/master/owocr/ocr.py
|
||||
|
||||
regex = re.compile(r">AF_initDataCallback\(({key: 'ds:1'.*?)\);</script>")
|
||||
|
||||
timestamp = int(time.time() * 1000)
|
||||
url = "https://lens.google.com/v3/upload?stcs={}".format(timestamp)
|
||||
headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Linux; Android 13; RMX3771) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.144 Mobile Safari/537.36",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
||||
}
|
||||
cookies = {"SOCS": "CAESEwgDEgk0ODE3Nzk3MjQaAmVuIAEaBgiA_LyaBg"}
|
||||
|
||||
files = {"encoded_image": ("screenshot.png", imagebinary, "image/png")}
|
||||
res = self.proxysession.post(url, files=files, headers=headers, cookies=cookies)
|
||||
res = self.proxysession.post(url, files=files, headers=headers)
|
||||
match = regex.search(res.text)
|
||||
if match == None:
|
||||
if not match:
|
||||
return
|
||||
sideChannel = "sideChannel"
|
||||
null = None
|
||||
@ -32,8 +29,5 @@ class OCR(baseocr):
|
||||
if "errorHasStatus" in lens_object:
|
||||
raise Exception(False, "Unknown Lens error!")
|
||||
|
||||
res = ""
|
||||
text = lens_object["data"][3][4][0]
|
||||
if len(text) == 0:
|
||||
return
|
||||
return text[0]
|
||||
return text[0] if text else None
|
Loading…
x
Reference in New Issue
Block a user