fix: improve discover and manual scrape controls

This commit is contained in:
ShukeBta
2026-06-24 15:56:35 +08:00
parent c212207f74
commit e56eed0758
5 changed files with 163 additions and 94 deletions
+14 -3
View File
@@ -113,15 +113,26 @@ function normalizeTitle(value?: string): string {
.trim()
}
const SERIES_SPECIAL_SUFFIX_RE =
/(?:\s+(?:s0+|season 0+|special episodes?|specials?|sp|ovas?|oads?|extras?|bonus(?:es)?|omake)|\s*(?:特别篇|特別篇|番外篇?|特典|外传|外傳|总集篇|總集篇))$/i
const SERIES_SPECIAL_CODE_RE =
/\s*[\[((【]?\s*(?:s0+\s*e?\s*\d+|season\s*0+(?:\s*episode)?\s*\d*|special(?:\s*episode)?s?\s*\d*|sp\s*\d*|ovas?\s*\d*|oads?\s*\d*|extras?\s*\d*|bonus(?:es)?\s*\d*|omake\s*\d*)\s*[\]))】]?$/i
const SERIES_SPECIAL_CJK_RE =
/\s*[\[((【]?\s*(?:特别篇|特別篇|番外篇?|特典|外传|外傳|总集篇|總集篇)(?:\s*第?\s*[0-9一二三四五六七八九十百零两]+(?:[集话話期])?)?\s*[\]))】]?$/i
function normalizePathSeriesTitle(value?: string): string {
const title = normalizeTitle(value)
const stripped = title.replace(SERIES_SPECIAL_SUFFIX_RE, '').trim()
const stripped = stripSeriesSpecialSuffix(title)
return stripped || title
}
function stripSeriesSpecialSuffix(title: string): string {
for (const pattern of [SERIES_SPECIAL_CODE_RE, SERIES_SPECIAL_CJK_RE]) {
const stripped = title.replace(pattern, '').trim()
if (stripped && stripped !== title) return stripped
}
return title
}
export function seriesTitleFromPath(path?: string): string {
if (!path) return ''
const parts = path.split(/[\\/]+/).filter(Boolean)