From 584d981713ec13b65636427a739a21340bd48229 Mon Sep 17 00:00:00 2001 From: cxfksword <718792+cxfksword@users.noreply.github.com> Date: Thu, 19 Jan 2023 12:47:15 +0800 Subject: [PATCH] Optimize introduce multiline --- Jellyfin.Plugin.MetaShark/Api/DoubanApi.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Jellyfin.Plugin.MetaShark/Api/DoubanApi.cs b/Jellyfin.Plugin.MetaShark/Api/DoubanApi.cs index fcfe335..7c9f41a 100644 --- a/Jellyfin.Plugin.MetaShark/Api/DoubanApi.cs +++ b/Jellyfin.Plugin.MetaShark/Api/DoubanApi.cs @@ -79,6 +79,7 @@ namespace Jellyfin.Plugin.MetaShark.Api Regex regFamily = new Regex(@"家庭成员: \n(.+?)\n", RegexOptions.Compiled); Regex regCelebrityImdb = new Regex(@"imdb编号:\s+?(nm\d+)", RegexOptions.Compiled); Regex regImgHost = new Regex(@"\/\/(img\d+?)\.", RegexOptions.Compiled); + Regex regIntroduceSpace = new Regex(@"\n\s+", RegexOptions.Compiled); // 默认200毫秒请求1次 private TimeLimiter _defaultTimeConstraint = TimeLimiter.GetFromMaxCountByInterval(1, TimeSpan.FromMilliseconds(200)); @@ -329,9 +330,11 @@ namespace Jellyfin.Plugin.MetaShark.Api var year = yearStr.GetMatchGroup(this.regYear); var rating = contentNode.GetText("div.rating_self strong.rating_num") ?? "0"; var img = contentNode.GetAttr("a.nbgnbg>img", "src") ?? string.Empty; - var intro = contentNode.GetText("div.indent>span") ?? string.Empty; - intro = intro.Replace("©豆瓣", string.Empty); var category = contentNode.QuerySelector("div.episode_list") == null ? "电影" : "电视剧"; + var intro = contentNode.GetText("div.indent>span") ?? string.Empty; + intro = formatIntroduce(intro); + + var info = contentNode.GetText("#info") ?? string.Empty; var director = info.GetMatchGroup(this.regDirector); @@ -815,6 +818,12 @@ namespace Jellyfin.Plugin.MetaShark.Api return string.Empty; } + private string formatIntroduce(string intro) + { + intro = intro.Replace("©豆瓣", string.Empty); + return regIntroduceSpace.Replace(intro, "\n"); + } + private bool IsEnableAvoidRiskControl() { return Plugin.Instance?.Configuration.EnableDoubanAvoidRiskControl ?? false;