Skip to content

Commit

Permalink
up-feedly. 影视条目标题解析
Browse files Browse the repository at this point in the history
  • Loading branch information
wdssmq committed Nov 12, 2024
1 parent 2cc2e49 commit 21e2d22
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions packages/feedly/src/_other.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,38 @@ const fnItemTitle = ($e) => {
if ($e.dataset.ptDone) {
return;
}
const strTitle = $e.innerText;
const arrMatch = strTitle.match(/(?<cate>\[[^\]]+\])[^[]+-(?<group>[^[]+)(?<title>\[.+\])$/);
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";
}
Expand Down

0 comments on commit 21e2d22

Please sign in to comment.