From be3a29da94f5fdc5edf77ee148a11812aa0ac0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:02:47 +0800 Subject: [PATCH] rm --- .../LunaTranslator/gui/translatorUI.py | 112 +- .../LunaTranslator/ocrengines/volcengine.py | 1190 +---------------- .../files/defaultconfig/ocrsetting.json | 5 - docs/zh/guochandamoxing.md | 8 +- 4 files changed, 5 insertions(+), 1310 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 641215fd..ba387256 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -877,7 +877,7 @@ class TranslatorWindow(resizableframeless): self.translate_text.textbrowser.setselectable(globalconfig["selectable"]) self.titlebar.raise_() t = QTimer(self) - t.setInterval(33) + t.setInterval(25) self._isentered = False t.timeout.connect(self.__betterenterevent) t.start() @@ -894,116 +894,6 @@ class TranslatorWindow(resizableframeless): self.enterfunction(2 + globalconfig["disappear_delay_tool"]) self.autohidedelaythread() self.tracewindowposthread() - today = time.strftime("%Y-%m-%d", time.localtime()) - if globalconfig.get("lastvisday", None) != today: - globalconfig["lastvisday"] = today - self.__showlinks() - - def __showsupport(self, _): - dia = QDialog(self, Qt.WindowType.WindowCloseButtonHint) - dia.setWindowTitle("支持作者") - vbox = QVBoxLayout() - dia.setLayout(vbox) - vbox.addWidget(QLabel("如果你感觉该软件对你有帮助,欢迎微信扫码赞助,谢谢~")) - _view = pixmapviewer(self) - _view.showpixmap(QPixmap.fromImage(QImage("./files/zan.jpg"))) - _view.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) - dia.resize(400, 400) - vbox.addWidget(_view) - dia.exec() - - def __showlinks(self): - __text = ( - _TR("欢迎使用") - + " LunaTranslator\nGithub " - + _TR("官方网站") - + " " - + _TR("使用说明") - + "\n" - ) - __tags = [ - { - "orig": _TR("欢迎使用") + " LunaTranslator", - "hira": "", - }, - {"orig": "\n", "hira": "\n"}, - { - "orig": "Github", - "hira": "1", - "clickfunction": lambda s: gobject.baseobject.openlink( - "https://github.com/HIllya51/LunaTranslator" - ), - }, - {"orig": " ", "hira": ""}, - { - "orig": _TR("官方网站"), - "hira": "1", - "clickfunction": lambda s: gobject.baseobject.openlink( - dynamiclink("{main_server}/") - ), - }, - {"orig": " ", "hira": ""}, - { - "orig": _TR("使用说明"), - "hira": "1", - "clickfunction": lambda s: gobject.baseobject.openlink( - dynamiclink("{docs_server}/") - ), - }, - {"orig": "\n", "hira": ""}, - ] - if getlanguse() == "zh": - __text += "支持作者 QQ群 Bilibili" - __tags += [ - { - "orig": "支持作者", - "hira": "1", - "clickfunction": self.__showsupport, - }, - {"orig": " ", "hira": ""}, - { - "orig": "QQ群", - "hira": "1", - "clickfunction": lambda s: gobject.baseobject.openlink( - dynamiclink("{main_server}/Resource/QQGroup") - ), - }, - {"orig": " ", "hira": ""}, - { - "orig": "Bilibili", - "hira": "1", - "clickfunction": lambda s: gobject.baseobject.openlink( - dynamiclink("{main_server}/Resource/Bilibili") - ), - }, - ] - else: - __text += "Discord Patreon" - __tags += [ - { - "orig": "Discord", - "hira": "1", - "clickfunction": lambda s: gobject.baseobject.openlink( - dynamiclink("{main_server}/Resource/DiscordGroup") - ), - }, - {"orig": " ", "hira": ""}, - { - "orig": "Patreon", - "hira": "1", - "clickfunction": lambda s: gobject.baseobject.openlink( - "https://www.patreon.com/hillya51" - ), - }, - ] - self.translate_text.append( - True, - globalconfig["showatcenter"], - __text, - __tags, - (False, True, True), - "black", - ) def setselectable(self): diff --git a/LunaTranslator/LunaTranslator/ocrengines/volcengine.py b/LunaTranslator/LunaTranslator/ocrengines/volcengine.py index f0f48dd5..dbdde4fc 100644 --- a/LunaTranslator/LunaTranslator/ocrengines/volcengine.py +++ b/LunaTranslator/LunaTranslator/ocrengines/volcengine.py @@ -136,16 +136,6 @@ class Util(object): key, bytes(content.encode("utf-8")), hashlib.sha256 ).digest() - @staticmethod - def hmac_sha1(key, content): - # type(key) == - if sys.version_info[0] == 3: - return hmac.new( - key, bytes(content, encoding="utf-8"), hashlib.sha1 - ).digest() - else: - return hmac.new(key, bytes(content.encode("utf-8")), hashlib.sha1).digest() - @staticmethod def sha256(content): # type(content) == @@ -173,60 +163,6 @@ class Util(object): lst.append(hv) return reduce(lambda x, y: x + y, lst) - @staticmethod - def pad(plain_text): - block_size = AES.block_size - - number_of_bytes_to_pad = block_size - len(plain_text) % block_size - ascii_string = chr(0) - padding_str = number_of_bytes_to_pad * ascii_string - padded_plain_text = plain_text + padding_str - return padded_plain_text - - @staticmethod - def generate_access_key_id(prefix): - uid = str(uuid.uuid4()) - uid_base64 = base64.b64encode(uid.replace("-", "").encode(encoding="utf-8")) - - s = ( - uid_base64.decode() - .replace("=", "") - .replace("/", "") - .replace("+", "") - .replace("-", "") - ) - return prefix + s - - @staticmethod - def rand_string_runes(length): - return "".join(random.sample(list(LETTER_RUNES), length)) - - @staticmethod - def aes_encrypt_cbc_with_base64(orig_data, key): - # type(orig_data) == - # type(key) == - generator = AES.new(key, AES.MODE_CBC, key) - if sys.version_info[0] == 3: - crypt = generator.encrypt(Util.pad(orig_data).encode("utf-8")) - return base64.b64encode(crypt).decode() - else: - crypt = generator.encrypt(Util.pad(orig_data)) - return base64.b64encode(crypt) - - @staticmethod - def generate_secret_key(): - rand_str = Util.rand_string_runes(32) - return Util.aes_encrypt_cbc_with_base64( - rand_str, "bytedance-isgood".encode("utf-8") - ) - - @staticmethod - def crc32(file_path): - prev = 0 - for eachLine in open(file_path, "rb"): - prev = crc32(eachLine, prev) - return prev & 0xFFFFFFFF - class Credentials(object): def __init__(self, ak, sk, service, region, session_token=""): @@ -318,77 +254,6 @@ class SignerV4(object): query["X-Signature"] = sign return urlencode(query) - @staticmethod - def sign_only(param, credentials): - request = Request() - request.host = param.host - request.method = param.method - request.path = param.path - request.body = param.body - request.query = param.query - request.headers = param.header_list - - format_date = param.date.strftime("%Y%m%dT%H%M%SZ") - date = format_date[:8] - request.headers["X-Date"] = format_date - md = MetaData() - md.set_algorithm("HMAC-SHA256") - md.set_service(credentials.service) - md.set_region(credentials.region) - md.set_date(date) - md.set_credential_scope("/".join([md.date, md.region, md.service, "request"])) - - if param.is_sign_url: - md.set_signed_headers("") - md.set_credential_scope( - "/".join([md.date, md.region, md.service, "request"]) - ) - query = request.query - query["X-Date"] = format_date - query["X-NotSignBody"] = "" - query["X-Credential"] = credentials.ak + "/" + md.credential_scope - query["X-Algorithm"] = md.algorithm - query["X-SignedHeaders"] = md.signed_headers - query["X-SignedQueries"] = "" - query["X-SignedQueries"] = ";".join(sorted(query.keys())) - if credentials.session_token != "": - query["X-Security-Token"] = credentials.session_token - hashed_canon_req = SignerV4.hashed_simple_canonical_request_v4(request, md) - else: - if credentials.session_token != "": - request.headers["X-Security-Token"] = credentials.session_token - hashed_canon_req = SignerV4.hashed_canonical_request_v4(request, md) - - signing_str = "\n".join( - [md.algorithm, format_date, md.credential_scope, hashed_canon_req] - ) - signing_key = SignerV4.get_signing_secret_key_v4( - credentials.sk, md.date, md.region, md.service - ) - sign = SignerV4.signature_v4(signing_key, signing_str) - - result = SignResult() - result.xdate = format_date - result.xAlgorithm = md.algorithm - if param.is_sign_url: - result.xSignedQueries = request.query["X-SignedQueries"] - result.xSignedHeaders = md.signed_headers - result.xCredential = credentials.ak + "/" + md.credential_scope - result.xSignature = sign - result.xContextSha256 = request.headers["X-Content-Sha256"] - result.authorization = ( - result.xAlgorithm - + " Credential=" - + result.xCredential - + ", SignedHeaders=" - + md.signed_headers - + ", Signature=" - + result.xSignature - ) - result.xSecurityToken = credentials.session_token - - return result - @staticmethod def hashed_simple_canonical_request_v4(request, meta): body = bytes() @@ -522,44 +387,6 @@ class Service(object): self.service_info = service_info self.api_info = api_info self.session = requests.session() - self.init() - - def init(self): - if "VOLC_ACCESSKEY" in os.environ and "VOLC_SECRETKEY" in os.environ: - self.service_info.credentials.set_ak(os.environ["VOLC_ACCESSKEY"]) - self.service_info.credentials.set_sk(os.environ["VOLC_SECRETKEY"]) - else: - if os.environ.get("HOME", None) is None: - return - # 先尝试从credentials中读取ak、sk,credentials不存在则从config中读取 - path_ini = os.environ["HOME"] + "/.volc/credentials" - path_json = os.environ["HOME"] + "/.volc/config" - if os.path.isfile(path_ini): - conf = configparser.ConfigParser() - conf.read(path_ini) - default_section, ak_option, sk_option = ( - "default", - "access_key_id", - "secret_access_key", - ) - if conf.has_section(default_section): - if conf.has_option(default_section, ak_option): - ak = conf.get(default_section, ak_option) - self.service_info.credentials.set_ak(ak) - if conf.has_option(default_section, sk_option): - sk = conf.get(default_section, sk_option) - self.service_info.credentials.set_sk(sk) - elif os.path.isfile(path_json): - with open(path_json, "r") as f: - try: - j = json.load(f) - except Exception: - logging.warning("%s is not json file", path_json) - return - if "ak" in j: - self.service_info.credentials.set_ak(j["ak"]) - if "sk" in j: - self.service_info.credentials.set_sk(j["sk"]) def set_ak(self, ak): self.service_info.credentials.set_ak(ak) @@ -590,29 +417,6 @@ class Service(object): return SignerV4.sign_url(r, self.service_info.credentials) - def get(self, api, params, doseq=0): - if not (api in self.api_info): - raise Exception("no such api") - api_info = self.api_info[api] - - r = self.prepare_request(api_info, params, doseq) - - SignerV4.sign(r, self.service_info.credentials) - - url = r.build(doseq) - resp = self.session.get( - url, - headers=r.headers, - timeout=( - self.service_info.connection_timeout, - self.service_info.socket_timeout, - ), - ) - if resp.status_code == 200: - return resp.text - else: - raise Exception(resp.text) - def post(self, api, params, form, proxy): if not (api in self.api_info): raise Exception("no such api") @@ -640,46 +444,6 @@ class Service(object): else: raise Exception(resp.text) - def json(self, api, params, body): - if not (api in self.api_info): - raise Exception("no such api") - api_info = self.api_info[api] - r = self.prepare_request(api_info, params) - r.headers["Content-Type"] = "application/json" - r.body = body - - SignerV4.sign(r, self.service_info.credentials) - - url = r.build() - resp = self.session.post( - url, - headers=r.headers, - data=r.body, - timeout=( - self.service_info.connection_timeout, - self.service_info.socket_timeout, - ), - ) - if resp.status_code == 200: - return json.dumps(resp.json()) - else: - raise Exception(resp.text.encode("utf-8")) - - def put(self, url, file_path, headers): - with open(file_path, "rb") as f: - resp = self.session.put(url, headers=headers, data=f) - if resp.status_code == 200: - return True, resp.text.encode("utf-8") - else: - return False, resp.text.encode("utf-8") - - def put_data(self, url, data, headers): - resp = self.session.put(url, headers=headers, data=data) - if resp.status_code == 200: - return True, resp.text.encode("utf-8") - else: - return False, resp.text.encode("utf-8") - def prepare_request(self, api_info, params, doseq=0): for key in params: if ( @@ -740,7 +504,7 @@ class VisualService(Service): def __init__(self): self.service_info = VisualService.get_service_info() - self.api_info = VisualService.get_api_info() + self.api_info = {} super(VisualService, self).__init__(self.service_info, self.api_info) @staticmethod @@ -754,403 +518,6 @@ class VisualService(Service): ) return service_info - @staticmethod - def get_api_info(): - api_info = { - "JPCartoonCut": ApiInfo( - "POST", "/", {"Action": "JPCartoonCut", "Version": "2020-08-26"}, {}, {} - ), - "JPCartoon": ApiInfo( - "POST", "/", {"Action": "JPCartoon", "Version": "2020-08-26"}, {}, {} - ), - "IDCard": ApiInfo( - "POST", "/", {"Action": "IDCard", "Version": "2020-08-26"}, {}, {} - ), - "FaceSwap": ApiInfo( - "POST", "/", {"Action": "FaceSwap", "Version": "2020-08-26"}, {}, {} - ), - "OCRNormal": ApiInfo( - "POST", "/", {"Action": "OCRNormal", "Version": "2020-08-26"}, {}, {} - ), - "BankCard": ApiInfo( - "POST", "/", {"Action": "BankCard", "Version": "2020-08-26"}, {}, {} - ), - "HumanSegment": ApiInfo( - "POST", "/", {"Action": "HumanSegment", "Version": "2020-08-26"}, {}, {} - ), - "GeneralSegment": ApiInfo( - "POST", - "/", - {"Action": "GeneralSegment", "Version": "2020-08-26"}, - {}, - {}, - ), - "EnhancePhoto": ApiInfo( - "POST", "/", {"Action": "EnhancePhoto", "Version": "2020-08-26"}, {}, {} - ), - "ConvertPhoto": ApiInfo( - "POST", "/", {"Action": "ConvertPhoto", "Version": "2020-08-26"}, {}, {} - ), - "VideoSceneDetect": ApiInfo( - "POST", - "/", - {"Action": "VideoSceneDetect", "Version": "2020-08-26"}, - {}, - {}, - ), - "OverResolution": ApiInfo( - "POST", - "/", - {"Action": "OverResolution", "Version": "2020-08-26"}, - {}, - {}, - ), - "GoodsSegment": ApiInfo( - "POST", "/", {"Action": "GoodsSegment", "Version": "2020-08-26"}, {}, {} - ), - "ImageOutpaint": ApiInfo( - "POST", - "/", - {"Action": "ImageOutpaint", "Version": "2020-08-26"}, - {}, - {}, - ), - "ImageInpaint": ApiInfo( - "POST", "/", {"Action": "ImageInpaint", "Version": "2020-08-26"}, {}, {} - ), - "ImageCut": ApiInfo( - "POST", "/", {"Action": "ImageCut", "Version": "2020-08-26"}, {}, {} - ), - "EntityDetect": ApiInfo( - "POST", "/", {"Action": "EntityDetect", "Version": "2020-08-26"}, {}, {} - ), - "GoodsDetect": ApiInfo( - "POST", "/", {"Action": "GoodsDetect", "Version": "2020-08-26"}, {}, {} - ), - "VideoSummarizationSubmitTask": ApiInfo( - "POST", - "/", - {"Action": "VideoSummarizationSubmitTask", "Version": "2020-08-26"}, - {}, - {}, - ), - "VideoSummarizationQueryTask": ApiInfo( - "GET", - "/", - {"Action": "VideoSummarizationQueryTask", "Version": "2020-08-26"}, - {}, - {}, - ), - "VideoOverResolutionSubmitTask": ApiInfo( - "POST", - "/", - {"Action": "VideoOverResolutionSubmitTask", "Version": "2020-08-26"}, - {}, - {}, - ), - "VideoOverResolutionQueryTask": ApiInfo( - "GET", - "/", - {"Action": "VideoOverResolutionQueryTask", "Version": "2020-08-26"}, - {}, - {}, - ), - "VideoRetargetingSubmitTask": ApiInfo( - "POST", - "/", - {"Action": "VideoRetargetingSubmitTask", "Version": "2020-08-26"}, - {}, - {}, - ), - "VideoRetargetingQueryTask": ApiInfo( - "GET", - "/", - {"Action": "VideoRetargetingQueryTask", "Version": "2020-08-26"}, - {}, - {}, - ), - "VideoInpaintSubmitTask": ApiInfo( - "POST", - "/", - {"Action": "VideoInpaintSubmitTask", "Version": "2020-08-26"}, - {}, - {}, - ), - "VideoInpaintQueryTask": ApiInfo( - "GET", - "/", - {"Action": "VideoInpaintQueryTask", "Version": "2020-08-26"}, - {}, - {}, - ), - "CarPlateDetection": ApiInfo( - "POST", - "/", - {"Action": "CarPlateDetection", "Version": "2020-08-26"}, - {}, - {}, - ), - "DistortionFree": ApiInfo( - "POST", - "/", - {"Action": "DistortionFree", "Version": "2020-08-26"}, - {}, - {}, - ), - "StretchRecovery": ApiInfo( - "POST", - "/", - {"Action": "StretchRecovery", "Version": "2020-08-26"}, - {}, - {}, - ), - "ImageFlow": ApiInfo( - "POST", "/", {"Action": "ImageFlow", "Version": "2020-08-26"}, {}, {} - ), - "ImageScore": ApiInfo( - "POST", "/", {"Action": "ImageScore", "Version": "2020-08-26"}, {}, {} - ), - "PoemMaterial": ApiInfo( - "POST", "/", {"Action": "PoemMaterial", "Version": "2020-08-26"}, {}, {} - ), - "EmoticonEdit": ApiInfo( - "POST", "/", {"Action": "EmoticonEdit", "Version": "2020-08-26"}, {}, {} - ), - "EyeClose2Open": ApiInfo( - "POST", - "/", - {"Action": "EyeClose2Open", "Version": "2020-08-26"}, - {}, - {}, - ), - "CarSegment": ApiInfo( - "POST", "/", {"Action": "CarSegment", "Version": "2020-08-26"}, {}, {} - ), - "CarDetection": ApiInfo( - "POST", "/", {"Action": "CarDetection", "Version": "2020-08-26"}, {}, {} - ), - "SkySegment": ApiInfo( - "POST", "/", {"Action": "SkySegment", "Version": "2020-08-26"}, {}, {} - ), - "ImageSearchImageAdd": ApiInfo( - "POST", - "/", - {"Action": "ImageSearchImageAdd", "Version": "2020-08-26"}, - {}, - {}, - ), - "ImageSearchImageDelete": ApiInfo( - "POST", - "/", - {"Action": "ImageSearchImageDelete", "Version": "2020-08-26"}, - {}, - {}, - ), - "ImageSearchImageSearch": ApiInfo( - "POST", - "/", - {"Action": "ImageSearchImageSearch", "Version": "2020-08-26"}, - {}, - {}, - ), - "ProductSearchAddImage": ApiInfo( - "POST", - "/", - {"Action": "ProductSearchAddImage", "Version": "2022-06-16"}, - {}, - {}, - ), - "ProductSearchDeleteImage": ApiInfo( - "POST", - "/", - {"Action": "ProductSearchDeleteImage", "Version": "2022-06-16"}, - {}, - {}, - ), - "ProductSearchSearchImage": ApiInfo( - "POST", - "/", - {"Action": "ProductSearchSearchImage", "Version": "2022-06-16"}, - {}, - {}, - ), - "ClueLicense": ApiInfo( - "POST", - "/", - {"Action": "OcrClueLicense", "Version": "2020-08-26"}, - {}, - {}, - ), - "DrivingLicense": ApiInfo( - "POST", - "/", - {"Action": "DrivingLicense", "Version": "2020-08-26"}, - {}, - {}, - ), - "VehicleLicense": ApiInfo( - "POST", - "/", - {"Action": "VehicleLicense", "Version": "2020-08-26"}, - {}, - {}, - ), - "TaxiInvoice": ApiInfo( - "POST", - "/", - {"Action": "OcrTaxiInvoice", "Version": "2020-08-26"}, - {}, - {}, - ), - "TrainTicket": ApiInfo( - "POST", - "/", - {"Action": "OcrTrainTicket", "Version": "2020-08-26"}, - {}, - {}, - ), - "FlightInvoice": ApiInfo( - "POST", - "/", - {"Action": "OcrFlightInvoice", "Version": "2020-08-26"}, - {}, - {}, - ), - "VatInvoice": ApiInfo( - "POST", - "/", - {"Action": "OcrVatInvoice", "Version": "2020-08-26"}, - {}, - {}, - ), - "QuotaInvoice": ApiInfo( - "POST", - "/", - {"Action": "OcrQuotaInvoice", "Version": "2020-08-26"}, - {}, - {}, - ), - "HairStyle": ApiInfo( - "POST", "/", {"Action": "HairStyle", "Version": "2020-08-26"}, {}, {} - ), - "FacePretty": ApiInfo( - "POST", "/", {"Action": "FacePretty", "Version": "2020-08-26"}, {}, {} - ), - "ImageAnimation": ApiInfo( - "POST", - "/", - {"Action": "ImageAnimation", "Version": "2020-08-26"}, - {}, - {}, - ), - "CoverVideo": ApiInfo( - "POST", "/", {"Action": "CoverVideo", "Version": "2020-08-26"}, {}, {} - ), - "DollyZoom": ApiInfo( - "POST", "/", {"Action": "DollyZoom", "Version": "2020-08-26"}, {}, {} - ), - "PotraitEffect": ApiInfo( - "POST", - "/", - {"Action": "PotraitEffect", "Version": "2020-08-26"}, - {}, - {}, - ), - "ImageStyleConversion": ApiInfo( - "POST", - "/", - {"Action": "ImageStyleConversion", "Version": "2020-08-26"}, - {}, - {}, - ), - "3DGameCartoon": ApiInfo( - "POST", - "/", - {"Action": "3DGameCartoon", "Version": "2020-08-26"}, - {}, - {}, - ), - "HairSegment": ApiInfo( - "POST", "/", {"Action": "HairSegment", "Version": "2020-08-26"}, {}, {} - ), - "OcrSeal": ApiInfo( - "POST", "/", {"Action": "OcrSeal", "Version": "2021-08-23"}, {}, {} - ), - "OcrPassInvoice": ApiInfo( - "POST", - "/", - {"Action": "OcrPassInvoice", "Version": "2021-08-23"}, - {}, - {}, - ), - "OCRTrade": ApiInfo( - "POST", "/", {"Action": "OCRTrade", "Version": "2020-12-21"}, {}, {} - ), - "OCRRuanzhu": ApiInfo( - "POST", "/", {"Action": "OCRRuanzhu", "Version": "2020-12-21"}, {}, {} - ), - "OCRCosmeticProduct": ApiInfo( - "POST", - "/", - {"Action": "OCRCosmeticProduct", "Version": "2020-12-21"}, - {}, - {}, - ), - "OCRPdf": ApiInfo( - "POST", "/", {"Action": "OCRPdf", "Version": "2021-08-23"}, {}, {} - ), - "OCRTable": ApiInfo( - "POST", "/", {"Action": "OCRTable", "Version": "2021-08-23"}, {}, {} - ), - "VideoCoverSelection": ApiInfo( - "POST", - "/", - {"Action": "VideoCoverSelection", "Version": "2020-08-26"}, - {}, - {}, - ), - "VideoHighlightExtractionSubmitTask": ApiInfo( - "POST", - "/", - { - "Action": "VideoHighlightExtractionSubmitTask", - "Version": "2020-08-26", - }, - {}, - {}, - ), - "VideoHighlightExtractionQueryTask": ApiInfo( - "GET", - "/", - { - "Action": "VideoHighlightExtractionQueryTask", - "Version": "2020-08-26", - }, - {}, - {}, - ), - "CertToken": ApiInfo( - "POST", "/", {"Action": "CertToken", "Version": "2022-08-31"}, {}, {} - ), - "CertVerifyQuery": ApiInfo( - "POST", - "/", - {"Action": "CertVerifyQuery", "Version": "2022-08-31"}, - {}, - {}, - ), - "T2ILDM": ApiInfo( - "POST", "/", {"Action": "T2ILDM", "Version": "2022-08-31"}, {}, {} - ), - "Img2ImgStyle": ApiInfo( - "POST", "/", {"Action": "Img2ImgStyle", "Version": "2022-08-31"}, {}, {} - ), - "Img2ImgAnime": ApiInfo( - "POST", "/", {"Action": "Img2ImgAnime", "Version": "2022-08-31"}, {}, {} - ), - } - return api_info - def common_handler(self, api, form, proxy): params = dict() try: @@ -1165,561 +532,6 @@ class VisualService(Service): except: raise Exception(str(e)) - def common_get_handler(self, api, params): - try: - res = self.get(api, params) - res_json = json.loads(res) - return res_json - except Exception as e: - res = str(e) - try: - res_json = json.loads(res) - return res_json - except: - raise Exception(str(e)) - - def common_json_handler(self, api, form): - params = dict() - try: - res = self.json(api, params, json.dumps(form)) - res_json = json.loads(res) - - return res_json - except Exception as e: - res = str(e) - try: - res_json = json.loads(res) - return res_json - except: - raise Exception(str(e)) - - def jpcartoon_cut(self, form): - try: - res_json = self.common_handler("JPCartoonCut", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def jpcartoon(self, form): - try: - res_json = self.common_handler("JPCartoon", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def id_card(self, form): - try: - res_json = self.common_handler("IDCard", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def face_swap(self, form): - try: - res_json = self.common_handler("FaceSwap", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def ocr_normal(self, form): - try: - res_json = self.common_handler("OCRNormal", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def bank_card(self, form): - try: - res_json = self.common_handler("BankCard", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def human_segment(self, form): - try: - res_json = self.common_handler("HumanSegment", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def general_segment(self, form): - try: - res_json = self.common_handler("GeneralSegment", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def enhance_photo(self, form): - try: - res_json = self.common_handler("EnhancePhoto", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def convert_photo(self, form): - try: - res_json = self.common_handler("ConvertPhoto", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_scene_detect(self, form): - try: - res_json = self.common_handler("VideoSceneDetect", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def over_resolution(self, form): - try: - res_json = self.common_handler("OverResolution", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def goods_segment(self, form): - try: - res_json = self.common_handler("GoodsSegment", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_outpaint(self, form): - try: - res_json = self.common_handler("ImageOutpaint", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_inpaint(self, form): - try: - res_json = self.common_handler("ImageInpaint", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_cut(self, form): - try: - res_json = self.common_handler("ImageCut", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def entity_detect(self, form): - try: - res_json = self.common_handler("EntityDetect", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def goods_detect(self, form): - try: - res_json = self.common_handler("GoodsDetect", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_summarization_submit_task(self, form): - try: - res_json = self.common_handler("VideoSummarizationSubmitTask", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_summarization_query_task(self, params): - try: - res_json = self.common_get_handler("VideoSummarizationQueryTask", params) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_over_resolution_submit_task(self, form): - try: - res_json = self.common_handler("VideoOverResolutionSubmitTask", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_over_resolution_query_task(self, params): - try: - res_json = self.common_get_handler("VideoOverResolutionQueryTask", params) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_retargeting_submit_task(self, form): - try: - res_json = self.common_handler("VideoRetargetingSubmitTask", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_retargeting_query_task(self, params): - try: - res_json = self.common_get_handler("VideoRetargetingQueryTask", params) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_inpaint_submit_task(self, form): - try: - res_json = self.common_handler("VideoInpaintSubmitTask", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_inpaint_query_task(self, params): - try: - res_json = self.common_get_handler("VideoInpaintQueryTask", params) - return res_json - except Exception as e: - raise Exception(str(e)) - - def car_plate_detection(self, form): - try: - res_json = self.common_handler("CarPlateDetection", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def distortion_free(self, form): - try: - res_json = self.common_handler("DistortionFree", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def stretch_recovery(self, form): - try: - res_json = self.common_handler("StretchRecovery", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_flow(self, form): - try: - res_json = self.common_handler("ImageFlow", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_score(self, form): - try: - res_json = self.common_handler("ImageScore", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def poem_material(self, form): - try: - res_json = self.common_handler("PoemMaterial", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def emoticon_edit(self, form): - try: - res_json = self.common_handler("EmoticonEdit", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def eye_close2open(self, form): - try: - res_json = self.common_handler("EyeClose2Open", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def car_segment(self, form): - try: - res_json = self.common_handler("CarSegment", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def car_detection(self, form): - try: - res_json = self.common_handler("CarDetection", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def sky_segment(self, form): - try: - res_json = self.common_handler("SkySegment", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_search_image_add(self, form): - try: - res_json = self.common_handler("ImageSearchImageAdd", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_search_image_delete(self, form): - try: - res_json = self.common_handler("ImageSearchImageDelete", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_search_image_search(self, form): - try: - res_json = self.common_handler("ImageSearchImageSearch", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def product_search_add_image(self, params): - try: - res_json = self.json("ProductSearchAddImage", [], json.dumps(params)) - return res_json - except Exception as e: - raise Exception(str(e)) - - def product_search_delete_image(self, params): - try: - res_json = self.json("ProductSearchDeleteImage", [], json.dumps(params)) - return res_json - except Exception as e: - raise Exception(str(e)) - - def product_search_search_image(self, params): - try: - res_json = self.json("ProductSearchSearchImage", [], json.dumps(params)) - return res_json - except Exception as e: - raise Exception(str(e)) - - def clue_license(self, form): - try: - res_json = self.common_handler("ClueLicense", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def driving_license(self, form): - try: - res_json = self.common_handler("DrivingLicense", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def vehicle_license(self, form): - try: - res_json = self.common_handler("VehicleLicense", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def taxi_invoice(self, form): - try: - res_json = self.common_handler("TaxiInvoice", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def train_ticket(self, form): - try: - res_json = self.common_handler("TrainTicket", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def flight_invoice(self, form): - try: - res_json = self.common_handler("FlightInvoice", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def vat_invoice(self, form): - try: - res_json = self.common_handler("VatInvoice", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def quota_invoice(self, form): - try: - res_json = self.common_handler("QuotaInvoice", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def hair_style(self, form): - try: - res_json = self.common_handler("HairStyle", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def face_pretty(self, form): - try: - res_json = self.common_handler("FacePretty", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_animation(self, form): - try: - res_json = self.common_handler("ImageAnimation", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def cover_video(self, form): - try: - res_json = self.common_handler("CoverVideo", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def dolly_zoom(self, form): - try: - res_json = self.common_handler("DollyZoom", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def potrait_effect(self, form): - try: - res_json = self.common_handler("PotraitEffect", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def image_style_conversion(self, form): - try: - res_json = self.common_handler("ImageStyleConversion", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def three_d_game_cartoon(self, form): - try: - res_json = self.common_handler("3DGameCartoon", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def hair_segment(self, form): - try: - res_json = self.common_handler("HairSegment", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def ocr_seal(self, form): - try: - res_json = self.common_handler("OcrSeal", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def ocr_pass_invoice(self, form): - try: - res_json = self.common_handler("OcrPassInvoice", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def ocr_trade(self, form): - try: - res_json = self.common_handler("OCRTrade", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def ocr_ruanzhu(self, form): - try: - res_json = self.common_handler("OCRRuanzhu", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def ocr_cosmetic_product(self, form): - try: - res_json = self.common_handler("OCRCosmeticProduct", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def ocr_pdf(self, form): - try: - res_json = self.common_handler("OCRPdf", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def ocr_table(self, form): - try: - res_json = self.common_handler("OCRTable", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_cover_selection(self, form): - try: - res_json = self.common_handler("VideoCoverSelection", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_highlight_extraction_submit_task(self, form): - try: - res_json = self.common_handler("VideoHighlightExtractionSubmitTask", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def video_highlight_extraction_query_task(self, params): - try: - res_json = self.common_get_handler( - "VideoHighlightExtractionQueryTask", params - ) - return res_json - except Exception as e: - raise Exception(str(e)) - - def cert_token(self, form): - try: - res_json = self.common_json_handler("CertToken", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def cert_verify_query(self, form): - try: - res_json = self.common_json_handler("CertVerifyQuery", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def t2i_ldm(self, form): - try: - res_json = self.common_json_handler("T2ILDM", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def img2img_style(self, form): - try: - res_json = self.common_json_handler("Img2ImgStyle", form) - return res_json - except Exception as e: - raise Exception(str(e)) - - def img2img_anime(self, form): - try: - res_json = self.common_json_handler("Img2ImgAnime", form) - return res_json - except Exception as e: - raise Exception(str(e)) - def ocr_api(self, action, form, proxy): try: res_json = self.common_handler(action, form, proxy) diff --git a/LunaTranslator/files/defaultconfig/ocrsetting.json b/LunaTranslator/files/defaultconfig/ocrsetting.json index 2c943280..37d6c2b3 100644 --- a/LunaTranslator/files/defaultconfig/ocrsetting.json +++ b/LunaTranslator/files/defaultconfig/ocrsetting.json @@ -221,16 +221,11 @@ }, "volcengine": { "args": { - "注册网址": "https://console.volcengine.com/ai/ability/detail/1", "密钥获取": "https://console.volcengine.com/iam/keymanage/", "Access Key ID": "", "Secret Access Key": "" }, "argstype": { - "注册网址": { - "type": "label", - "islink": true - }, "密钥获取": { "type": "label", "islink": true diff --git a/docs/zh/guochandamoxing.md b/docs/zh/guochandamoxing.md index 7f1e50f9..50975910 100644 --- a/docs/zh/guochandamoxing.md +++ b/docs/zh/guochandamoxing.md @@ -52,15 +52,13 @@ **model** https://help.aliyun.com/zh/model-studio/product-overview/billing-for-alibaba-cloud-model-studio/#2550bcc04d2tk -### **字节跳动豆包大模型** - - +### **字节跳动豆包大模型(火山引擎)** **API接口地址** `https://ark.cn-beijing.volces.com/api/v3` -**SECRET_KEY** 跟[官方文档](https://www.volcengine.com/docs/82379/1263279)获取 +**SECRET_KEY** [创建API Key](https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey?apikey=%7B%7D)获取 -**model** 创建[推理接入点](https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint?current=1&pageSize=10)后,填入**接入点**而非**模型** +**model** [创建推理接入点](https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint?current=1&pageSize=10)后,填入**接入点**而非**模型** ![img](https://image.lunatranslator.org/zh/damoxing/doubao.png)