Skip to content

Commit

Permalink
Merge branch 'dev' into refactor-defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng authored Jul 4, 2024
2 parents 9c9364a + 273cb16 commit 36e7c60
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
22 changes: 11 additions & 11 deletions Easydict/objc/Service/Youdao/EZYoudaoTranslate.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ @interface EZYoudaoTranslate ()

@implementation EZYoudaoTranslate

- (instancetype)init {
if (self = [super init]) {
// Youdao's cookie seems to have a long expiration date, so we don't need to update them frequently.
[self requestYoudaoCookie];
}
return self;
}

- (EZWebViewTranslator *)webViewTranslator {
if (!_webViewTranslator) {
NSString *selector = @"p.trans-content";
Expand Down Expand Up @@ -146,6 +138,14 @@ - (NSString *)cookie {
NSString *cookie = [NSUserDefaults mm_read:kYoudaoTranslatetURL];
if (!cookie) {
cookie = @"OUTFOX_SEARCH_USER_ID=833782676@113.88.171.235; domain=.youdao.com; expires=2052-12-31 13:12:38 +0000";
[NSUserDefaults mm_write:cookie forKey:kYoudaoTranslatetURL];

/**
Youdao's cookie seems to have a long expiration date, so we don't need to update them frequently.
So we only request the cookie the first time we use it, or webTranslate() fails.
*/
[self requestYoudaoCookie];
}
return cookie;
}
Expand Down Expand Up @@ -518,7 +518,7 @@ - (void)queryYoudaoDict:(NSString *)text from:(EZLanguage)from to:(EZLanguage)to

NSURLSessionTask *task = [self.jsonSession GET:url parameters:params progress:nil success:^(NSURLSessionDataTask *_Nonnull task, id _Nullable responseObject) {
NSString *message = nil;

if (responseObject) {
@try {
EZYoudaoDictModel *model = [EZYoudaoDictModel mj_objectWithKeyValues:responseObject];
Expand Down Expand Up @@ -800,7 +800,7 @@ - (void)youdaoAIDemoTranslate:(NSString *)text from:(EZLanguage)from to:(EZLangu
}];
}

// Get youdao fanyi cookie, and save it to user defaults.
// Get youdao fanyi cookie, and save it to NSUserDefaults.
- (void)requestYoudaoCookie {
// https://fanyi.youdao.com/index.html#/
NSString *cookieURL = [NSString stringWithFormat:@"%@/index.html#/", kYoudaoTranslatetURL];
Expand Down Expand Up @@ -935,7 +935,7 @@ - (NSString *)decryptAESText:(NSString *)encryptedText {
NSData *keyDataMD5Data = [keyData md5];
NSData *ivDataMD5Data = [ivData md5];

// NSString *decryptedText = [FWEncryptorAES decryptStrFromBase64:encryptedText Key:keyDataMD5Data IV:ivDataMD5Data];
// NSString *decryptedText = [FWEncryptorAES decryptStrFromBase64:encryptedText Key:keyDataMD5Data IV:ivDataMD5Data];
NSString *decryptedText = [encryptedText decryptAESWithKeyData:keyDataMD5Data ivData:ivDataMD5Data];

return decryptedText;
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
- [语种识别](#语种识别)
- [TTS 服务](#tts-服务)
- [查询服务](#查询服务)
- [ 各个服务支持的语言 ](#--各个服务支持的语言-)
- [各个服务支持的语言](#各个服务支持的语言)
- [🍎 苹果系统词典](#-苹果系统词典)
- [OpenAI 翻译](#openai-翻译)
- [配置个人的 APIKey](#配置个人的-apikey)
Expand Down Expand Up @@ -244,7 +244,14 @@ Easydict 启动之后,除了应用主界面(默认隐藏),还会有一
> [!NOTE]
> Google 翻译中国版已无法使用,只能使用国际版,因此需要走代理才能使用 Google 翻译。
### <details> <summary> 各个服务支持的语言 </summary>

<details>
<summary>

### 各个服务支持的语言

</summary>


<p>

Expand Down
8 changes: 7 additions & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ We plan to refactor the project with Swift. If you are interested in this open s
- [Language Recognition](#language-recognition)
- [TTS Services](#tts-services)
- [Translation Services](#translation-services)
- [Supported languages](#supported-languages)
- [🍎 Apple System Dictionary](#-apple-system-dictionary)
- [OpenAI Translate](#openai-translate)
- [Configure Personal APIKey](#configure-personal-apikey)
Expand Down Expand Up @@ -241,7 +242,12 @@ Currently supports YouDao Dictionary, 🍎 Apple System Dictionary, 🍎 Apple S
> [!NOTE]
> Since the Chinese version of Google Translate is currently unavailable, you can only use the international version, so you need to use a proxy to use Google Translate.
<details> <summary> Supported languages: </summary>
<details>
<summary>

### Supported languages

</summary>

<p>

Expand Down

0 comments on commit 36e7c60

Please sign in to comment.