From cbdaafceff7bcdc7539a9b8367539b6d671cd6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E7=85=8C?= Date: Thu, 22 Aug 2019 13:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0Settings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NLyric/Ncm/NcmApi.cs | 7 ++++++- NLyric/Settings.json | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NLyric/Ncm/NcmApi.cs b/NLyric/Ncm/NcmApi.cs index bb660c6..05dbfae 100644 --- a/NLyric/Ncm/NcmApi.cs +++ b/NLyric/Ncm/NcmApi.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Extensions; using System.Net.Http; @@ -34,13 +35,17 @@ public static async Task SearchAsync(IEnumerable keywords, Searc using (HttpClient client = new HttpClient()) using (HttpResponseMessage response = await client.SendAsync(HttpMethod.Get, SEARCH_URL, queries, null)) { JObject json; + JToken result; if (!response.IsSuccessStatusCode) throw new HttpRequestException(); json = JObject.Parse(await response.Content.ReadAsStringAsync()); if ((int)json["code"] != 200) throw new HttpRequestException(); - return json["result"]; + result = json["result"]; + if (result is null) + throw new ArgumentException($"\"{string.Join(" ", keywords)}\" 中有关键词被屏蔽"); + return result; } } diff --git a/NLyric/Settings.json b/NLyric/Settings.json index 4ab2274..9f0037d 100644 --- a/NLyric/Settings.json +++ b/NLyric/Settings.json @@ -13,7 +13,8 @@ "Separators": "|;,/\\&:", // 分隔符,用于分割歌手名 "WholeWordReplace": { "sh0ut": "shØut", - "あやぽんず*": "あやぽんず*" + "あやぽんず*": "あやぽんず", + "あやぽんず*": "あやぽんず" }, // 前面是被替换的词,后面是要替换成的词,比如歌名"sh0ut",搜索的时候会被替换成"shØut"来搜索,网易云音乐部分歌曲歌手名收录有问题,只能这么办 "Limit": 15 // 搜索结果数量 },