virtual paths fall back to parsedTitle when a file has no title or originalTitle (claims model)
Build and Push Docker Image / build (push) Successful in 2m15s

This commit is contained in:
Worph
2026-10-25 19:25:17 +00:00
parent e03b6b1fd4
commit b1179a6f94
2 changed files with 16 additions and 1 deletions
@@ -62,7 +62,8 @@ export function renamingRule(metadata: Partial<MediaMeta>, filepath?: string): s
// Get title - try various fields // Get title - try various fields
// The display name — never the `titles/*` name set (METADATA_KEYS.md §3). // The display name — never the `titles/*` name set (METADATA_KEYS.md §3).
const title = metadata.title || metadata.originalTitle; // `parsedTitle` is filename-parser's guess (claims model, D12): last resort.
const title = metadata.title || metadata.originalTitle || (metadata as { parsedTitle?: string }).parsedTitle;
if (!title) { if (!title) {
if (metadata.fileType !== 'torrent') { if (metadata.fileType !== 'torrent') {
// Don't warn for torrent files because they don't always have a title // Don't warn for torrent files because they don't always have a title
@@ -436,6 +436,7 @@ export class VirtualFileSystem implements VFSUpdateCallback {
* Compute virtual path for a file using template rules * Compute virtual path for a file using template rules
*/ */
private computeVirtualPath(metadata: FileMetadata, sourcePath: string): string { private computeVirtualPath(metadata: FileMetadata, sourcePath: string): string {
metadata = withParsedTitleFallback(metadata);
if (!this.rulesConfig) { if (!this.rulesConfig) {
// Fallback to old behavior // Fallback to old behavior
return this.metaDataToFolderStruct.generateSingleVirtualPath(sourcePath, metadata); return this.metaDataToFolderStruct.generateSingleVirtualPath(sourcePath, metadata);
@@ -1105,6 +1106,7 @@ export class VirtualFileSystem implements VFSUpdateCallback {
rules: RenamingRule[], rules: RenamingRule[],
defaultRule?: RenamingRule defaultRule?: RenamingRule
): string { ): string {
metadata = withParsedTitleFallback(metadata);
// Sort rules by priority (descending) // Sort rules by priority (descending)
const sortedRules = [...rules] const sortedRules = [...rules]
.filter(r => r.enabled) .filter(r => r.enabled)
@@ -1304,3 +1306,15 @@ export class VirtualFileSystem implements VFSUpdateCallback {
this.onFileComplete(hashId, metadata); this.onFileComplete(hashId, metadata);
} }
} }
/**
* filename-parser's guessed title lives under `parsedTitle` since the claims
* model (it no longer writes `originalTitle`, which tmdb also writes). The
* rules and templates fall back `title` → `originalTitle`; fill a missing
* `originalTitle` from `parsedTitle` on a copy so a file with only a parsed
* title still gets a path. The record itself is never changed.
*/
function withParsedTitleFallback<T extends { originalTitle?: unknown; parsedTitle?: unknown }>(metadata: T): T {
if (metadata.originalTitle || !metadata.parsedTitle) return metadata;
return { ...metadata, originalTitle: metadata.parsedTitle };
}