This commit is contained in:
恍兮惚兮 2024-12-19 22:08:07 +08:00
parent 658bfd1723
commit bd6786b924
2 changed files with 5 additions and 11 deletions

View File

@ -1,7 +1,7 @@
set(VERSION_MAJOR 6) set(VERSION_MAJOR 6)
set(VERSION_MINOR 14) set(VERSION_MINOR 14)
set(VERSION_PATCH 1) set(VERSION_PATCH 2)
set(VERSION_REVISION 0) set(VERSION_REVISION 0)
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}") set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp) add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)

View File

@ -5,21 +5,18 @@ import re, time
class OCR(baseocr): class OCR(baseocr):
def ocr(self, imagebinary): def ocr(self, imagebinary):
# https://github.com/AuroraWright/owocr/blob/master/owocr/ocr.py
regex = re.compile(r">AF_initDataCallback\(({key: 'ds:1'.*?)\);</script>") regex = re.compile(r">AF_initDataCallback\(({key: 'ds:1'.*?)\);</script>")
timestamp = int(time.time() * 1000) timestamp = int(time.time() * 1000)
url = "https://lens.google.com/v3/upload?stcs={}".format(timestamp) url = "https://lens.google.com/v3/upload?stcs={}".format(timestamp)
headers = { 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")} 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) match = regex.search(res.text)
if match == None: if not match:
return return
sideChannel = "sideChannel" sideChannel = "sideChannel"
null = None null = None
@ -32,8 +29,5 @@ class OCR(baseocr):
if "errorHasStatus" in lens_object: if "errorHasStatus" in lens_object:
raise Exception(False, "Unknown Lens error!") raise Exception(False, "Unknown Lens error!")
res = ""
text = lens_object["data"][3][4][0] text = lens_object["data"][3][4][0]
if len(text) == 0: return text[0] if text else None
return
return text[0]