From 21e2d22c341b04642a9e5d1df2f43fdc22fc5277 Mon Sep 17 00:00:00 2001 From: wdssmq Date: Tue, 12 Nov 2024 15:56:17 +0800 Subject: [PATCH] =?UTF-8?q?up-feedly.=20=E5=BD=B1=E8=A7=86=E6=9D=A1?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E9=A2=98=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/feedly/src/_other.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/feedly/src/_other.js b/packages/feedly/src/_other.js index 3b07c12..b699f76 100644 --- a/packages/feedly/src/_other.js +++ b/packages/feedly/src/_other.js @@ -30,13 +30,38 @@ const fnItemTitle = ($e) => { if ($e.dataset.ptDone) { return; } - const strTitle = $e.innerText; - const arrMatch = strTitle.match(/(?\[[^\]]+\])[^[]+-(?[^[]+)(?\[.+\])$/); + const origTitle = $e.innerText; + // _log("origTitle", origTitle); + // 定义一个函数用于获取年度及分辨率 + const fnGetVideoLabel = (videoTitle) => { + videoTitle = videoTitle.replace("4K.", "2160p."); + // 定义一个正则数组,用于匹配年度及分辨率 + const arrRegexp = [ + /(?<year>\d{4})\.(?<res>\d+p)\./, + /(?<year>\d{4})\.S\d+.*?(?<res>\d+p)\./, + /(?<year>\d{4})\.Complete\.(?<res>\d+p)\./, + /(?<year>\d{4})\..+?(?<res>\d+p)\./i, + ]; + // 遍历正则数组,匹配年度及分辨率 + let objLabel = null; + for (let i = 0; i < arrRegexp.length; i++) { + const regexp = arrRegexp[i]; + const match = videoTitle.match(regexp); + if (match) { + objLabel = match.groups; + break; + } + } + return objLabel; + }; + const arrMatch = origTitle.match(/(?<cate>\[[^\]]+\])[^[]+-(?<group>[^[]+)(?<title>\[.+\])$/); if (arrMatch) { const strCate = arrMatch.groups.cate.replace(/^\[[^)]+\(([^)]+)\)\]/, "[$1]"); const strGroup = arrMatch.groups.group; const strTitle = arrMatch.groups.title; - const strNewTitle = `${strTitle} - ${strCate}[${strGroup}]`; + // 提取年度及分辨率 + const objLabel = fnGetVideoLabel(origTitle); + const strNewTitle = `${strTitle} - ${strCate}[${objLabel?.year}][${objLabel?.res}][${strGroup}]`; $e.innerText = strNewTitle; $e.dataset.ptDone = "1"; }