fix library deletion and strm path handling

This commit is contained in:
ShukeBta
2026-06-27 15:58:15 +08:00
parent d18d4239db
commit e22b537de4
6 changed files with 147 additions and 12 deletions
+16
View File
@@ -58,6 +58,8 @@ export function inferSTRMOutputRoot(saved: string, libraries: Library[]) {
}
if (slashSaved === toSlash(subdir).toLowerCase()) return ''
}
const inferredBySTRMRoot = stripLibraryCategoryAfterSTRMRoot(normalized)
if (inferredBySTRMRoot) return inferredBySTRMRoot
return normalized
}
@@ -133,6 +135,20 @@ function splitPath(raw: string) {
return raw.split('/').map((part) => part.trim()).filter((part) => part && part !== '.')
}
function stripLibraryCategoryAfterSTRMRoot(raw: string) {
const normalized = toSlash(raw)
const parts = normalized.split('/')
let strmIndex = -1
for (let index = 0; index < parts.length; index += 1) {
if (parts[index].trim().toLowerCase() === 'strm') strmIndex = index
}
if (strmIndex < 0 || strmIndex >= parts.length - 1) return ''
const tail = parts.slice(strmIndex + 1).filter((part) => part.trim())
const categoryParts = categoryPartsFromPath(tail)
if (!categoryParts?.length) return ''
return trimPath(parts.slice(0, strmIndex + 1).join('/'))
}
function joinPath(root: string, ...parts: string[]) {
return [trimPath(root), ...parts.map(trimPath)].filter(Boolean).join('/')
}
+2 -1
View File
@@ -99,8 +99,9 @@ export function isSeriesCard(card: SeriesCard): boolean {
}
export function seriesTitle(media: Media): string {
const title = media.title?.trim()
const fromPath = seriesTitleFromPath(media.path)
return fromPath || media.title || media.original_name || '未命名节目'
return (title && !unsafeEpisodeTitle(title) ? title : '') || fromPath || media.original_name || title || '未命名节目'
}
function normalizeTitle(value?: string): string {