diff --git a/LunaTranslator/LunaTranslator/cishu/mojidict.py b/LunaTranslator/LunaTranslator/cishu/mojidict.py new file mode 100644 index 00000000..259bbdba --- /dev/null +++ b/LunaTranslator/LunaTranslator/cishu/mojidict.py @@ -0,0 +1,624 @@ +import requests, re, json + +from cishu.cishubase import cishubase + + +def mojiclicksearch(self,word): + + headers = { + "accept": "*/*", + "accept-language": "zh-CN,zh;q=0.9,ar;q=0.8,sq;q=0.7,ru;q=0.6", + "content-type": "text/plain", + "origin": "https://www.mojidict.com", + "priority": "u=1, i", + "referer": "https://www.mojidict.com/", + "sec-ch-ua": '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Windows"', + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "same-site", + "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", + } + data = json.dumps( + { + "searchText": word, + "langEnv": "zh-CN_ja", + "_SessionToken": "r:718e90d7837c22ac48f71d000d0a62f4", + "_ClientVersion": "js3.4.1", + "_ApplicationId": "E62VyFVLMiW7kvbtVq3p", + "g_os": "PCWeb", + "g_ver": "v4.8.1.20240522", + "_InstallationId": "101241e8-4004-40b2-a040-f6839ed76d32", + }, + ensure_ascii=False, + ).encode() + + response = requests.post( + "https://api.mojidict.com/parse/functions/word-clickSearchV2", + headers=headers, + data=data, + proxies=self.proxy, + ) + + result = response.json()["result"]["result"] + word = result["word"] + + subdetails = result["subdetails"] + collect = [] + relaid = [] + + for subdetail in subdetails: + title = subdetail["title"] + # print(title,subdetail) + + good = False + for i in range(len(relaid)): + if relaid[i] == subdetail["relaId"]: + if subdetail["lang"] == "zh-CN": + collect[i] = title + collect[i] + elif subdetail["lang"] == "ja": + title = f"({title})" + collect[i] = collect[i] + title + good = True + if not good: + collect.append(title) + relaid.append(subdetail["relaId"]) + # print('\n'.join(collect)) + excerpt = word[0]["excerpt"] + accent = word[0]["accent"] + spell = word[0]["spell"] + pron = word[0]["pron"] + style = r""" + + + """ + spell = f"{spell}|{pron}{accent}" + spell = f'
{spell}
' + _type = re.match("\\[(.*?)\\]", excerpt).groups()[0] + _type = f'

{_type}

' + + for i in range(len(collect)): + collect[i] = f"

{i+1}. {collect[i]}

" + detail = f"""
{_type}{''.join(collect)}
""" + result = f'
{spell}{detail}
' + result += style + return result + + +def mojizonghe(self,word): + response = requests.post( + "https://api.mojidict.com/parse/functions/union-api", + json={ + "functions": [ + { + "name": "search-all", + "params": { + "text": word, + "types": [ + 102, + 106, + 103, + ], + }, + }, + ], + "_ApplicationId": "E62VyFVLMiW7kvbtVq3p", + }, + headers={ + "content-type": "text/plain", + "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", + }, + proxies=self.proxy, + ) + + result = "" + for i in response.json()["result"]["results"]["search-all"]["result"]["word"][ + "searchResult" + ]: + result += "{}
{}

".format(i["title"], i["excerpt"]) + + return result + + +class mojidict(cishubase): + def search(self, word): + + result = "" + try: + result += mojiclicksearch(self,word) + result += "
" + except: + pass + try: + result += mojizonghe(self,word) + except: + pass + return result \ No newline at end of file diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index ffefea99..2de69ee1 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -1334,6 +1334,11 @@ }, "type": "offline" }, + "mojidict": { + "use": false, + "name": "Moji辞书", + "useproxy": false + }, "youdao": { "use": false, "name": "有道词典", diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index f8e65ae7..e873c409 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -184,6 +184,7 @@ "使用代理": "استخدام وكيل", "使用代理的项目": "استخدام وكيل المشروع", "优先录制的翻译源": "يفضل تسجيل مصدر الترجمة", + "Moji辞书": "معجم موجي", "显示错误信息": "عرض رسالة خطأ", "水奈瀬コウ": "شوي ناي", "Unicode范围": "يونيكود مجموعة", diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index 74670bcd..24a7803c 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -219,6 +219,7 @@ "辞书": "辭書", "分词": "分詞", "过滤尖括号<>": "過濾角括弧 <>", + "Moji辞书": "MOJi 辭書", "清空": "清空", "不显示原文": "不顯示原文", "不显示api": "不顯示 API", diff --git a/LunaTranslator/files/lang/cs.json b/LunaTranslator/files/lang/cs.json index 5d78978b..a9a3389f 100644 --- a/LunaTranslator/files/lang/cs.json +++ b/LunaTranslator/files/lang/cs.json @@ -399,6 +399,7 @@ "飞书": "anonymní dopis", "用户词典选择JcUserdic文件夹": "Vyberte složku JcUserdic z uživatelského slovníku", "缩放时禁用窗口大小调整": "Zakázat změnu velikosti okna během škálování", + "Moji辞书": "Slovník Moji", "删除": "smazat", "图像一致性阈值": "Prahová hodnota konzistence obrazu", "封面": "kryt", diff --git a/LunaTranslator/files/lang/de.json b/LunaTranslator/files/lang/de.json index 5530f506..ebc90f3a 100644 --- a/LunaTranslator/files/lang/de.json +++ b/LunaTranslator/files/lang/de.json @@ -399,6 +399,7 @@ "飞书": "anonymer Brief", "用户词典选择JcUserdic文件夹": "Wählen Sie den Ordner JcUserdic aus dem Benutzerwörterbuch aus", "缩放时禁用窗口大小调整": "Fenstergröße während der Skalierung deaktivieren", + "Moji辞书": "Moji-Wörterbuch", "删除": "löschen", "图像一致性阈值": "Schwellenwert für Bildkonsistenz", "封面": "Abdeckung", diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index c76418a8..ee00f797 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -219,6 +219,7 @@ "辞书": "Dictionary", "分词": "Tokenization", "过滤尖括号<>": "Filter Angle Brackets <>", + "Moji辞书": "Moji Dictionary", "清空": "Clear", "不显示原文": "Don't Display Original Text", "不显示api": "Don't Display API", diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index c1fcd691..bafdccf3 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -219,6 +219,7 @@ "辞书": "Diccionario", "分词": "Participio", "过滤尖括号<>": "Soporte puntiagudo de filtro < >", + "Moji辞书": "Moji dict", "清空": "Vaciado", "不显示原文": "No muestra el texto original", "不显示api": "No muestra APIS", diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index eeca7abc..90254686 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -219,6 +219,7 @@ "辞书": "Dictionnaire", "分词": "Participant", "过滤尖括号<>": "Filtrer les crochets d'angle < >", + "Moji辞书": "Moji dict", "清空": "Vider", "不显示原文": "Ne pas afficher l'original", "不显示api": "Ne pas afficher l'API", diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index 084c5a91..e326ea6c 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -215,6 +215,7 @@ "辞书": "Dizionario", "分词": "participio", "过滤尖括号<>": "Parentes angolari del filtro<>", + "Moji辞书": "Dizionario Moji", "清空": "vuoto", "不显示原文": "Non visualizzare il testo originale", "不显示api": "Non visualizzare API", diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index 7338a630..ffdd59bc 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -219,6 +219,7 @@ "辞书": "辞書", "分词": "分詞", "过滤尖括号<>": "フィルタ山括弧<>", + "Moji辞书": "Moji辞書", "清空": "クリアランス", "不显示原文": "テキストを表示しない", "不显示api": "apiを表示しない", diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index a20c982c..d61be119 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -219,6 +219,7 @@ "辞书": "사서", "分词": "분사", "过滤尖括号<>": "괄호 필터링 <>", + "Moji辞书": "Moji dict", "清空": "비우기", "不显示原文": "원문을 나타내지 않다", "不显示api": "api 표시 안 함", diff --git a/LunaTranslator/files/lang/nl.json b/LunaTranslator/files/lang/nl.json index 5365521b..46b9c3c8 100644 --- a/LunaTranslator/files/lang/nl.json +++ b/LunaTranslator/files/lang/nl.json @@ -399,6 +399,7 @@ "飞书": "anonieme brief", "用户词典选择JcUserdic文件夹": "Selecteer de map JcUserdic uit het gebruikerswoordenboek", "缩放时禁用窗口大小调整": "Venstergrootte tijdens schalen uitschakelen", + "Moji辞书": "Moji-woordenboek", "删除": "verwijderen", "图像一致性阈值": "Drempelwaarde beeldconsistentie", "封面": "dekking", diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index 38e067e4..41d49c00 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -219,6 +219,7 @@ "辞书": "Słownik", "分词": "uczestnik", "过滤尖括号<>": "Nawiasy kąta filtra<>", + "Moji辞书": "Słownik Moji", "清空": "pusty", "不显示原文": "Nie wyświetlaj oryginalnego tekstu", "不显示api": "Nie wyświetlaj interfejsu API", diff --git a/LunaTranslator/files/lang/pt.json b/LunaTranslator/files/lang/pt.json index 313ad0ac..c8657f3c 100644 --- a/LunaTranslator/files/lang/pt.json +++ b/LunaTranslator/files/lang/pt.json @@ -399,6 +399,7 @@ "飞书": "carta anónima", "用户词典选择JcUserdic文件夹": "Seleccione a pasta JcUserdic no dicionário do utilizador", "缩放时禁用窗口大小调整": "Desactivar o redimensionamento da janela durante a escala", + "Moji辞书": "Dicionário Moji", "删除": "apagar", "图像一致性阈值": "Limiar de consistência da imagem", "封面": "capa", diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index b5cd445f..13ded479 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -219,6 +219,7 @@ "辞书": "Словарь", "分词": "Фрагмент", "过滤尖括号<>": "Фильтр острых скобок < >", + "Moji辞书": "Moji dict", "清空": "Очистить", "不显示原文": "Не показывать оригинал", "不显示api": "Не показывать API", diff --git a/LunaTranslator/files/lang/sv.json b/LunaTranslator/files/lang/sv.json index 1c0cf830..2d42e0e5 100644 --- a/LunaTranslator/files/lang/sv.json +++ b/LunaTranslator/files/lang/sv.json @@ -399,6 +399,7 @@ "飞书": "anonymt brev", "用户词典选择JcUserdic文件夹": "Välj katalogen JcUserdic från användarordlistan", "缩放时禁用窗口大小调整": "Inaktivera fönstrets storlek under skalning", + "Moji辞书": "Mojiordbok", "删除": "ta bort", "图像一致性阈值": "Tröskelvärde för bildkonsistens", "封面": "omslag", diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index de0a4f35..5c1908b7 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -399,6 +399,7 @@ "飞书": "หนังสือบิน", "用户词典选择JcUserdic文件夹": "พจนานุกรมผู้ใช้เลือกโฟลเดอร์ JcUserdic", "缩放时禁用窗口大小调整": "ปิดการปรับขนาดหน้าต่างเมื่อซูม", + "Moji辞书": "ใบลาออกของโมจิ", "删除": "ลบ", "图像一致性阈值": "เกณฑ์ความสอดคล้องของภาพ", "封面": "ปก", diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index c0d29935..22af9408 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -219,6 +219,7 @@ "辞书": "Sözlük", "分词": "participle", "过滤尖括号<>": "Süzgüç bracketleri < >", + "Moji辞书": "Moji Sözlük", "清空": "boş", "不显示原文": "Önce metini gösterme", "不显示api": "api gösterme", diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index c8de0cea..3d1325f0 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -215,6 +215,7 @@ "辞书": "Словник", "分词": "частинка", "过滤尖括号<>": "Фільтрувати дужки кутів<>", + "Moji辞书": "Словник Moji", "清空": "порожній", "不显示原文": "Не показувати початковий текст", "不显示api": "Не показувати API", diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index cb36daf5..5bc9c6b3 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -219,6 +219,7 @@ "辞书": "Thư từ", "分词": "Phân từ", "过滤尖括号<>": "Lọc ngoặc nhọn<>", + "Moji辞书": "Từ điển Moji", "清空": "Trống rỗng", "不显示原文": "Không hiển thị bản gốc", "不显示api": "Không hiển thị API", diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index 795e5236..9994d7ac 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -399,6 +399,7 @@ "飞书": "", "用户词典选择JcUserdic文件夹": "", "缩放时禁用窗口大小调整": "", + "Moji辞书": "", "删除": "", "图像一致性阈值": "", "封面": "",