0.13.1-5 Adjust Detection

This commit is contained in:
2026-04-14 05:54:48 +00:00
parent 3feb780e16
commit cac6442b5b
14 changed files with 937 additions and 156 deletions
+6 -124
View File
@@ -4967,114 +4967,6 @@ class HistoryService {
const sourceSelectedMetadata = sourceJobContext?.selectedMetadata && typeof sourceJobContext.selectedMetadata === 'object'
? sourceJobContext.selectedMetadata
: {};
const sourceAnalyzeContext = sourceJobContext?.analyzeContext && typeof sourceJobContext.analyzeContext === 'object'
? sourceJobContext.analyzeContext
: {};
const sourceHasSeriesSignals = hasSeriesMetadataSignals(sourceSelectedMetadata, sourceAnalyzeContext);
const seriesImportHints = effectiveDetectedMediaType === 'dvd' && (seriesRawPathHint || sourceHasSeriesSignals)
? buildSeriesImportHints({
folderName: path.basename(finalRawPath),
rawPath: finalRawPath,
metadata,
sourceSelectedMetadata,
sourceAnalyzeContext
})
: null;
let effectiveSeriesImportHints = seriesImportHints;
let inferredSeriesContainer = null;
if (effectiveDetectedMediaType === 'dvd') {
const hintedTmdbId = normalizePositiveIntegerOrNull(
effectiveSeriesImportHints?.selectedMetadata?.tmdbId
?? effectiveSeriesImportHints?.selectedMetadata?.providerId
?? null
);
const hintedSeasonNumber = normalizePositiveIntegerOrNull(
effectiveSeriesImportHints?.selectedMetadata?.seasonNumber
?? effectiveSeriesImportHints?.analyzeContextPatch?.seriesLookupHint?.seasonNumber
?? null
);
if (hintedTmdbId && hintedSeasonNumber) {
inferredSeriesContainer = await this.findSeriesContainerJob(hintedTmdbId, hintedSeasonNumber);
}
if (!inferredSeriesContainer && seriesRawPathHint) {
inferredSeriesContainer = await this.findLikelySeriesContainerJob({
title: sourceSelectedMetadata?.title || sourceSelectedMetadata?.seriesTitle || effectiveTitle || metadata.title || null,
year: sourceSelectedMetadata?.year || sourceJob?.year || metadata.year || null
});
}
if (inferredSeriesContainer) {
const containerInfo = parseJsonSafe(inferredSeriesContainer?.makemkv_info_json, {}) || {};
const containerSelectedMetadata = extractSelectedMetadataFromMakemkvInfo(containerInfo);
const containerAnalyzeContext = containerInfo?.analyzeContext && typeof containerInfo.analyzeContext === 'object'
? containerInfo.analyzeContext
: {};
const containerTmdbId = normalizePositiveIntegerOrNull(
containerSelectedMetadata?.tmdbId
|| containerSelectedMetadata?.providerId
|| null
);
const containerSeasonNumber = normalizePositiveIntegerOrNull(containerSelectedMetadata?.seasonNumber || null);
const discNumberHint = normalizePositiveIntegerOrNull(
effectiveSeriesImportHints?.selectedMetadata?.discNumber
?? extractDiscNumberFromText(`${path.basename(finalRawPath)} ${path.basename(absRawPath)}`)
?? null
);
if (containerTmdbId && containerSeasonNumber) {
const mergedTitle = String(
effectiveSeriesImportHints?.selectedMetadata?.title
|| containerSelectedMetadata?.title
|| effectiveTitle
|| inferredSeriesContainer?.title
|| ''
).trim() || null;
effectiveSeriesImportHints = {
selectedMetadata: {
...containerSelectedMetadata,
...(effectiveSeriesImportHints?.selectedMetadata && typeof effectiveSeriesImportHints.selectedMetadata === 'object'
? effectiveSeriesImportHints.selectedMetadata
: {}),
metadataProvider: 'tmdb',
metadataKind: String(containerSelectedMetadata?.metadataKind || 'series').trim().toLowerCase() || 'series',
tmdbId: containerTmdbId,
seasonNumber: containerSeasonNumber,
title: mergedTitle,
...(discNumberHint ? { discNumber: discNumberHint } : {})
},
analyzeContextPatch: {
...(effectiveSeriesImportHints?.analyzeContextPatch && typeof effectiveSeriesImportHints.analyzeContextPatch === 'object'
? effectiveSeriesImportHints.analyzeContextPatch
: {}),
metadataProvider: 'tmdb',
metadataKind: String(containerAnalyzeContext?.metadataKind || containerSelectedMetadata?.metadataKind || 'series').trim().toLowerCase() || 'series',
seriesLookupHint: {
...(containerAnalyzeContext?.seriesLookupHint && typeof containerAnalyzeContext.seriesLookupHint === 'object'
? containerAnalyzeContext.seriesLookupHint
: {}),
query: mergedTitle,
seasonNumber: containerSeasonNumber,
...(discNumberHint ? { discNumber: discNumberHint } : {})
},
seriesAnalysis: {
...(containerAnalyzeContext?.seriesAnalysis && typeof containerAnalyzeContext.seriesAnalysis === 'object'
? containerAnalyzeContext.seriesAnalysis
: {}),
summary: {
...(containerAnalyzeContext?.seriesAnalysis?.summary && typeof containerAnalyzeContext.seriesAnalysis.summary === 'object'
? containerAnalyzeContext.seriesAnalysis.summary
: {}),
seriesLike: true,
confidence: containerAnalyzeContext?.seriesAnalysis?.summary?.confidence || 'high'
}
}
}
};
}
}
}
const sourcePosterCandidate = this.getPreferredPosterCandidateForImport(sourceJobContext, null);
const recoveredCdEncodePlan = cdRecovery ? this.buildRecoveredCdEncodePlan(cdRecovery) : null;
const orphanImportInfo = this.buildOrphanRawImportMakemkvInfo({
@@ -5083,12 +4975,13 @@ class HistoryService {
requestedRawPath: absRawPath,
sourceFolderJobId: metadata.folderJobId || null,
mediaProfile: effectiveDetectedMediaType,
existingInfo: sourceJobContext?.makemkvInfo || null,
// RAW-Import soll wie "Disk analysieren" starten:
// keine geerbte Serien-/Metadatenzuordnung vor dem eigentlichen Analyse-Scan.
existingInfo: cdRecovery ? (sourceJobContext?.makemkvInfo || null) : null,
recovery: cdRecovery,
selectedMetadata: effectiveSeriesImportHints?.selectedMetadata || null,
analyzeContextPatch: effectiveSeriesImportHints?.analyzeContextPatch || null
selectedMetadata: null,
analyzeContextPatch: null
});
const inferredSeriesContainerId = normalizeJobIdValue(inferredSeriesContainer?.id);
const recoveredPosterUrl = orphanPosterUrl
|| (thumbnailService.isLocalUrl(sourcePosterCandidate) ? null : sourcePosterCandidate)
|| null;
@@ -5108,11 +5001,7 @@ class HistoryService {
await this.updateJob(created.id, {
...(effectiveDetectedMediaType === 'audiobook' ? { job_kind: 'audiobook', media_type: 'audiobook' } : {}),
...(effectiveDetectedMediaType === 'cd' ? { job_kind: 'cd', media_type: 'cd' } : {}),
...(effectiveDetectedMediaType === 'dvd'
? (inferredSeriesContainerId
? { job_kind: 'dvd_series_child', media_type: 'dvd', parent_job_id: inferredSeriesContainerId }
: { job_kind: 'dvd', media_type: 'dvd' })
: {}),
...(effectiveDetectedMediaType === 'dvd' ? { job_kind: 'dvd', media_type: 'dvd', parent_job_id: null } : {}),
...(effectiveDetectedMediaType === 'bluray' ? { job_kind: 'bluray', media_type: 'bluray' } : {}),
status: 'FINISHED',
last_state: 'FINISHED',
@@ -5191,13 +5080,6 @@ class HistoryService {
`Metadaten aus vorhandenem Job #${sourceJob.id} wiederhergestellt.`
);
}
if (inferredSeriesContainerId) {
await this.appendLog(
created.id,
'SYSTEM',
`Automatisch dem Serien-Container #${inferredSeriesContainerId} zugeordnet.`
);
}
logger.info('job:import-orphan-raw', {
jobId: created.id,