Closed Cheuring closed 1 month ago
目前发现少数单词或句子 手动发送request每次得到的结果不固定 不确定是为什么
谢谢 PR,添加到 userAHK 很好,不会干预到正常功能,如果放在正式代码中,我觉得这个方法不算正规,随时可能失效,没法合的,放在 userAHK 倒是可以何进去让用户自己选、或者充当一个 userAHK demo。但是有2个问题希望可以解决下:
demo.ahk
需要加回去,你自己在自己分支上用确实无所谓,但是面向用户的话它可以给 userAHK 提供一个最简单的 demo,引导用户怎么把自己添加的脚本放在独立文件,并引入。keyFunc_translate_cus()
上方添加注释,告诉用户怎么使用这个新增的函数,给个例子怎么在设置文件中添加设置以及怎么使用,比如:# Capslock+Settings.ini
[Keys]
caps_t=keyFunc_translate_cus
另外我直接运行代码没什么问题,但是用这边用你图片里的同样的请求返回了一个奇怪的结果,不确定原因:
request: POST https://dict.youdao.com/jsonapi_s?doctype=json&jsonversion=4&le=en&q=efficiency
response:
{
"web_trans": {
"web-translation": [
{
"@same": "true",
"key": "negro spiritual",
"key-speech": "negro+spiritual",
"trans": [
{
"summary": {
"line": [
"... 底特律灵歌 motown soul <b>黑人灵歌</b> negro spiritual; spiritual 滑步灵歌 soul shuffle ..."
]
},
"value": "黑人灵歌",
"support": 1,
"url": ""
}
]
}
]
},
"oxfordAdvanceHtml": {
"encryptedData": "Oi7q_uLf41Op8q1BEZge7AaqKJM17DSt_ReKlwt7eUMxWRttip4jkypjKLC7VyDWH9KrmZVeDKaC6ARQv2Q6Y9vEpdrmzHX-TKNVT4EsaSk_xiotw6vE_6xW6j5yOVsiborIPoRDdFl11z4uOK5-DWMfIfapZ8yMCLMNs3bNAm-qEDJJRAv-5F9bklpRe4N5aOh15osUVPmR-c0zfowVhfdef5CZWyhp52oWTdqxszTmmQRS_g5inF5QcE2iUn2nwvDjlSbFsDYRx_2fGqXeKn8wD_0eSq5_piurwFdvazzYc26Sr44Xp1XWhPQdQOI5BuK08yaY1UuaPIJKX0Pz8eA8USpADG7al4P0YBikFUbosyiXrkSGiwBh98tIxGhHuRPw7X2-ZFcwzkul7WBoR2XrMhrs2PhLuMkvwEq7L45-Ir73JbhXvTffRKBdytWXh7zihgzZP0RLqW7amjEJdElRPzl0t8i8OYf82SHHuIYFQa1eBFwL1EhENdtxrrs9y_GnVxe6Gq8F90qBXB21GkPVaWitC90Frb_cnUR2tiF40I4b1gKDlIwBg_3_mGfelsYAoR5jjpDtugHFNvtnNU406TwnFPUqockXryviFTbPU1prjYL-t3IA1Jch19G50T4_XroSEA-pvNlnoL8H4EIeF9rWr5isoWr5uh8NZK_ngMW3cS8vmeVKsme-IHEer5ZmlD_eEEVWMRQJBBSpgK0GtYTRHuYsCXF-yARVAPj2B_nkE3G69PTZUcsCQwovkHC6b3_BcldAn0khEGuRGnP41k_Edx3rvbo2ztOfYARZtvPcvMRsYdt3JMR-8elNgL1wvnM8VqMiaLOYmPGQ4IUdBVZrCvcN532U0lLPJbRKugopfJb7Se35eGw4CEW8sApN2NPAlTWtu4WLrcOWaIFCvqa9YVN87CaNuemuWzwwEJ1QxbQDqe-zM_bKLmUB"
},
"ee": {
"source": {
"name": "WordNet",
"url": "https://wordnet.princeton.edu"
},
"word": {
"trs": [
{
"pos": "n.",
"tr": [
{
"l": {
"i": "a kind of religious song originated by Blacks in the southern United States"
},
"similar-words": [
{
"similar": "spiritual"
}
]
}
]
}
],
"phone": "",
"speech": "Negro+spiritual",
"return-phrase": {
"l": {
"i": "Negro spiritual"
}
}
}
},
"simple": {
"query": "Negro spiritual",
"word": [
{
"ukphone": "ˌniːɡrəʊ ˈspɪrɪtʃuəl",
"ukspeech": "Negro+spiritual&type=1",
"return-phrase": "Negro spiritual"
}
]
},
"media_sents_part": {
"query": "Negro spiritual",
"sent": [
{
"@mediatype": "audio",
"snippets": {
"snippet": [
{
"streamUrl": "https://dict.youdao.com/pureaudio?docid=-4275335735339739380",
"duration": "5500",
"swf": "",
"name": "special.2009.07.27",
"source": "VOA",
"win8": "https://dict.youdao.com/pureaudio?docid=-4275335735339739380&dist=win8"
}
]
},
"speech-size": "18kb",
"eng": "\"We Shall Overcome\" came from a <b>Negro </b><b>spiritual</b>."
},
{
"@mediatype": "audio",
"snippets": {
"snippet": [
{
"streamUrl": "https://dict.youdao.com/pureaudio?docid=-4761239923507855871",
"duration": "14900",
"swf": "",
"name": "special.2010.04.16",
"source": "VOA",
"win8": "https://dict.youdao.com/pureaudio?docid=-4761239923507855871&dist=win8"
}
]
},
"speech-size": "65kb",
"eng": "\" ...when all of God's children, black men and white men, Jews and Gentiles, Protestants and Catholics, will be able to join hands and sing in the words of the old <b>Negro </b><b>spiritual</b>: Free at last! Free at last!"
}
]
},
"etym": {
"etyms": {
"zh": [
{
"source": "童理民",
"word": "Negro spiritual",
"value": "Negro,黑人,spiritual,灵魂乐。",
"url": "",
"desc": "黑人灵魂乐"
}
]
},
"word": "Negro spiritual"
},
"oxford": {
"encryptedData": "UktO0nno49_7qSeorNM95m0CSRCgAK8ouso2FDElvoUVs5hsTo3e4D0HPaYRLd5w8LN4ZdgiL8pXugGfX27j5OP3FoQEoh_t-3dWX5KwZ6C75I0-b4Xc1vJtUKwQ7RpwkaQtNR2TNndfdah1A7hzGi_3AYVKA5FtdHpLGDCxtiA="
},
"input": "Negro spiritual",
"collins": {
"collins_entries": [
{
"entries": {
"entry": [
{
"tran_entry": [
{
"pos_entry": {
"pos": "N",
"pos_tips": "名词"
},
"tran": "a type of religious song originating among Black slaves in the American South (美国南方的)黑人灵歌"
}
]
}
]
},
"phonetic": "ˈniːɡrəʊ",
"basic_entries": {
"basic_entry": [
{
"headword": "Negro spiritual"
}
]
},
"headword": "Negro spiritual"
}
]
},
"meta": {
"input": "Negro spiritual",
"guessLanguage": "eng",
"isHasSimpleDict": "1",
"le": "en",
"lang": "eng",
"dicts": [
"web_trans",
"oxfordAdvanceHtml",
"ee",
"oxford",
"collins",
"meta",
"simple",
"media_sents_part",
"etym",
"ec",
"oxfordAdvance"
]
},
"le": "en",
"lang": "eng",
"ec": {
"source": {
"name": "有道词典",
"url": "https://dict.youdao.com"
},
"word": [
{
"ukphone": "ˌniːɡrəʊ ˈspɪrɪtʃuəl",
"ukspeech": "Negro+spiritual&type=1",
"trs": [
{
"tr": [
{
"l": {
"i": [
"n. 黑人灵歌"
]
}
}
]
}
],
"return-phrase": {
"l": {
"i": "Negro spiritual"
}
}
}
]
},
"oxfordAdvance": {
"encryptedData": "VOalywxKg51bjbWsBH44UtJ9CY2RsIDUpWweTc6e6X7rhuoKvqmbJMdcXES-sYcjtUMwoK54x78MUnAVqIUDvEhm8WVYpiM0dtkgjF-8FHESSXWdqDaFdrbzEPr_I_XzNT10yh9qETQktRtVTB1iAuG8s_jvM7DdfIQKoIWwljqhjTc9BS_p_LHlEXGaijdydLUG4z9zaORt0DqefE6h0xN-KrtFOysW86ByTp_pjJmaYdK5s0C7CkCAQo7xtrTu5KYJkZSTvnihuUKXt0TNpkSqaCXHHOq0ZYT53QJ_jZwy4643Sh-qVf2q6KFZWK7w599krx2uIHqL0jXn0qny90OgUIc2RYC-5tdq35trM2oN36IGk6CHNMJ8KoYoZUizYnSzZ37QHjOFd_EOLgu8d8DH78JOEtvzo5s2MTojv83TDZcOlTALj_12SWZNY_n1uygxkOxIscU7t5ur2X2szA1dqiyuQA4q38sPTOBMwiQFlsOtB10SW8PhjgGSOVNRcL_PX5SVLOIb2cfRDoUkvoTVghHCoXnDKPMxCuEirq4="
}
}
只保留了一个request, 简化了代码 发现在请求发送时,末尾加上一个符号,会减少response混乱的情况
单词
句子
用的是网页版有道翻译的api (f12抓的) 要同时发两个request 一个获取音标 一个获取翻译结果 使用了异步 请求时间能接受 增加在了userAHK目录下 不影响源代码本体 我自己测了一下 单词 句子都能翻译 看起来无bug 欢迎指正