mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 03:36:37 +08:00
fix library deletion and strm path handling
This commit is contained in:
@@ -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('/')
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user