0.13.1 DVD Series rc1
This commit is contained in:
@@ -739,6 +739,47 @@ function resolveSeriesDiscNumber(job) {
|
||||
);
|
||||
}
|
||||
|
||||
function isSeriesBatchEpisodeChildJob(job) {
|
||||
const plan = job?.encodePlan && typeof job.encodePlan === 'object'
|
||||
? job.encodePlan
|
||||
: null;
|
||||
if (!plan) {
|
||||
return false;
|
||||
}
|
||||
if (Boolean(plan?.seriesBatchChild) || Boolean(plan?.seriesBatchVirtualEpisode)) {
|
||||
return true;
|
||||
}
|
||||
const hasParent = normalizePositiveInteger(plan?.seriesBatchParentJobId) !== null;
|
||||
const hasEpisodeMarker = normalizePositiveInteger(plan?.seriesBatchTitleId) !== null
|
||||
|| normalizePositiveInteger(plan?.seriesBatchChildIndex) !== null
|
||||
|| normalizePositiveInteger(plan?.seriesBatchChildCount) !== null;
|
||||
return hasParent && hasEpisodeMarker;
|
||||
}
|
||||
|
||||
function buildSeriesContainerDiskChildren(children = []) {
|
||||
const rows = Array.isArray(children) ? children : [];
|
||||
const diskCandidates = rows.filter((child) => !isSeriesBatchEpisodeChildJob(child));
|
||||
const byDisc = new Map();
|
||||
const withoutDisc = [];
|
||||
|
||||
for (const child of [...diskCandidates].sort((a, b) => Number(b?.id || 0) - Number(a?.id || 0))) {
|
||||
const discNumber = resolveSeriesDiscNumber(child);
|
||||
if (discNumber !== null) {
|
||||
if (!byDisc.has(discNumber)) {
|
||||
byDisc.set(discNumber, child);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
withoutDisc.push(child);
|
||||
}
|
||||
|
||||
const withDisc = Array.from(byDisc.entries())
|
||||
.sort((left, right) => left[0] - right[0])
|
||||
.map(([, child]) => child);
|
||||
const withoutDiscSorted = withoutDisc.sort(compareSeriesChildJobsByDisc);
|
||||
return [...withDisc, ...withoutDiscSorted];
|
||||
}
|
||||
|
||||
function compareSeriesChildJobsByDisc(leftJob, rightJob) {
|
||||
const leftDisc = resolveSeriesDiscNumber(leftJob);
|
||||
const rightDisc = resolveSeriesDiscNumber(rightJob);
|
||||
@@ -1128,10 +1169,14 @@ export default function JobDetailDialog({
|
||||
const metadataDetails = resolveMetadataDetailsForDisplay(job, omdbInfo);
|
||||
const seriesDiscNumber = isDvdSeries ? resolveSeriesDiscNumber(job) : null;
|
||||
const seriesDiscLabel = seriesDiscNumber ? `Disk ${seriesDiscNumber}` : 'Disk unbekannt';
|
||||
const childJobs = Array.isArray(job?.children)
|
||||
? [...job.children].sort(compareSeriesChildJobsByDisc)
|
||||
: [];
|
||||
const isSeriesContainer = isDvdSeries && String(job?.job_kind || '').trim().toLowerCase() === 'dvd_series_container';
|
||||
const childJobs = Array.isArray(job?.children)
|
||||
? (
|
||||
isSeriesContainer
|
||||
? buildSeriesContainerDiskChildren(job.children)
|
||||
: [...job.children].sort(compareSeriesChildJobsByDisc)
|
||||
)
|
||||
: [];
|
||||
const seriesChildSummary = job?.seriesChildSummary || null;
|
||||
const seriesBackupSummary = isSeriesContainer ? seriesChildSummary?.backup : null;
|
||||
const seriesEncodeSummary = isSeriesContainer ? seriesChildSummary?.encode : null;
|
||||
|
||||
@@ -33,6 +33,7 @@ export default function MetadataSelectionDialog({
|
||||
const [extraResults, setExtraResults] = useState([]);
|
||||
const [searchBusy, setSearchBusy] = useState(false);
|
||||
const [searchError, setSearchError] = useState('');
|
||||
const [submitError, setSubmitError] = useState('');
|
||||
const [seasonFilter, setSeasonFilter] = useState('');
|
||||
const [discValidationError, setDiscValidationError] = useState('');
|
||||
const metadataProvider = String(context?.metadataProvider || 'omdb').trim().toLowerCase() || 'omdb';
|
||||
@@ -56,20 +57,17 @@ export default function MetadataSelectionDialog({
|
||||
const defaultTitle = selectedMetadata.title || context?.detectedTitle || '';
|
||||
const defaultYear = selectedMetadata.year ? String(selectedMetadata.year) : '';
|
||||
const defaultImdb = selectedMetadata.imdbId || '';
|
||||
const hintedDiscNumber = selectedMetadata.discNumber || context?.seriesLookupHint?.discNumber || null;
|
||||
const defaultDiscNumber = Number(hintedDiscNumber || 0) > 0
|
||||
? String(Math.trunc(Number(hintedDiscNumber || 0)))
|
||||
: '';
|
||||
|
||||
setSelected(null);
|
||||
setQuery(defaultTitle);
|
||||
setManualTitle(defaultTitle);
|
||||
setManualYear(defaultYear);
|
||||
setManualImdb(defaultImdb);
|
||||
setManualDiscNumber(defaultDiscNumber);
|
||||
setManualDiscNumber('');
|
||||
setExtraResults([]);
|
||||
setSearchBusy(false);
|
||||
setSearchError('');
|
||||
setSubmitError('');
|
||||
setSeasonFilter('');
|
||||
setDiscValidationError('');
|
||||
}, [visible, context]);
|
||||
@@ -83,6 +81,12 @@ export default function MetadataSelectionDialog({
|
||||
}
|
||||
}, [discValidationError, requiresDiscNumber, hasValidDiscNumber]);
|
||||
|
||||
useEffect(() => {
|
||||
if (submitError) {
|
||||
setSubmitError('');
|
||||
}
|
||||
}, [manualDiscNumber, seasonFilter, selected]);
|
||||
|
||||
const rows = useMemo(() => {
|
||||
const base = Array.isArray(context?.metadataCandidates)
|
||||
? context.metadataCandidates
|
||||
@@ -166,6 +170,8 @@ export default function MetadataSelectionDialog({
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
setDiscValidationError('');
|
||||
setSubmitError('');
|
||||
if (requiresDiscNumber && !hasValidDiscNumber) {
|
||||
setDiscValidationError('Disk-Nummer ist Pflicht und muss eine ganze Zahl >= 1 sein.');
|
||||
return;
|
||||
@@ -201,7 +207,18 @@ export default function MetadataSelectionDialog({
|
||||
...(effectiveDiscNumber ? { discNumber: effectiveDiscNumber } : {})
|
||||
};
|
||||
|
||||
await onSubmit(payload);
|
||||
try {
|
||||
await onSubmit(payload);
|
||||
} catch (error) {
|
||||
const details = Array.isArray(error?.details) ? error.details : [];
|
||||
const hasDuplicateDiscError = details.some((detail) => String(detail?.code || '').trim().toUpperCase() === 'SERIES_DISC_ALREADY_EXISTS');
|
||||
const message = String(error?.message || 'Metadaten konnten nicht uebernommen werden.').trim() || 'Metadaten konnten nicht uebernommen werden.';
|
||||
if (hasDuplicateDiscError) {
|
||||
setSubmitError(message);
|
||||
return;
|
||||
}
|
||||
setSubmitError(message);
|
||||
}
|
||||
};
|
||||
|
||||
const handleHideRequest = () => {
|
||||
@@ -262,6 +279,7 @@ export default function MetadataSelectionDialog({
|
||||
</div>
|
||||
{searchError ? <small className="error-text">{searchError}</small> : null}
|
||||
{discValidationError ? <small className="error-text">{discValidationError}</small> : null}
|
||||
{submitError ? <small className="error-text">{submitError}</small> : null}
|
||||
|
||||
<div className="table-scroll-wrap table-scroll-medium">
|
||||
<DataTable
|
||||
|
||||
@@ -485,6 +485,77 @@ function normalizePositiveInt(value) {
|
||||
return Math.trunc(parsed);
|
||||
}
|
||||
|
||||
function normalizeEpisodeReference(entry = {}) {
|
||||
const source = entry && typeof entry === 'object' ? entry : {};
|
||||
const episodeId = normalizePositiveInt(source?.episodeId ?? source?.id ?? null);
|
||||
const episodeNumber = normalizePositiveInt(source?.episodeNumber ?? source?.number ?? null);
|
||||
const seasonNumber = normalizePositiveInt(source?.seasonNumber ?? source?.season ?? null);
|
||||
if (!episodeId && !episodeNumber) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
episodeId,
|
||||
episodeNumber,
|
||||
seasonNumber
|
||||
};
|
||||
}
|
||||
|
||||
function buildEpisodeReferenceKey(entry = {}) {
|
||||
const normalized = normalizeEpisodeReference(entry);
|
||||
if (!normalized) {
|
||||
return null;
|
||||
}
|
||||
if (normalized.episodeId) {
|
||||
return `id:${normalized.episodeId}`;
|
||||
}
|
||||
if (normalized.seasonNumber && normalized.episodeNumber) {
|
||||
return `se:${normalized.seasonNumber}:${normalized.episodeNumber}`;
|
||||
}
|
||||
return normalized.episodeNumber ? `ep:${normalized.episodeNumber}` : null;
|
||||
}
|
||||
|
||||
function isSeriesBatchEpisodePlan(plan = null) {
|
||||
const source = plan && typeof plan === 'object' ? plan : {};
|
||||
if (Boolean(source?.seriesBatchChild) || Boolean(source?.seriesBatchVirtualEpisode)) {
|
||||
return true;
|
||||
}
|
||||
const parentJobId = normalizePositiveInt(source?.seriesBatchParentJobId);
|
||||
const childIndex = normalizePositiveInt(source?.seriesBatchChildIndex);
|
||||
const childCount = normalizePositiveInt(source?.seriesBatchChildCount);
|
||||
const titleId = normalizeTitleId(source?.seriesBatchTitleId);
|
||||
return Boolean(parentJobId && (childIndex || childCount || titleId));
|
||||
}
|
||||
|
||||
function collectEpisodeReferencesFromPlan(plan = null) {
|
||||
const source = plan && typeof plan === 'object' ? plan : {};
|
||||
const refs = [];
|
||||
const assignments = source?.episodeAssignments && typeof source.episodeAssignments === 'object'
|
||||
? Object.values(source.episodeAssignments)
|
||||
: [];
|
||||
for (const assignment of assignments) {
|
||||
const normalized = normalizeEpisodeReference(assignment);
|
||||
if (normalized) {
|
||||
refs.push(normalized);
|
||||
}
|
||||
}
|
||||
|
||||
const titles = Array.isArray(source?.titles) ? source.titles : [];
|
||||
for (const title of titles) {
|
||||
if (!Boolean(title?.selectedForEncode) && !Boolean(title?.encodeInput)) {
|
||||
continue;
|
||||
}
|
||||
const normalized = normalizeEpisodeReference({
|
||||
episodeId: title?.episodeId,
|
||||
episodeNumber: title?.episodeNumber,
|
||||
seasonNumber: title?.seasonNumber
|
||||
});
|
||||
if (normalized) {
|
||||
refs.push(normalized);
|
||||
}
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
||||
function normalizeSeriesLanguage(value) {
|
||||
const raw = String(value || '').trim();
|
||||
if (!raw) {
|
||||
@@ -730,6 +801,7 @@ export default function PipelineStatusCard({
|
||||
const [trackSelectionByTitle, setTrackSelectionByTitle] = useState({});
|
||||
const [episodeAssignmentsByTitle, setEpisodeAssignmentsByTitle] = useState({});
|
||||
const [selectedEpisodeFillStart, setSelectedEpisodeFillStart] = useState(null);
|
||||
const [containerUsedEpisodeKeys, setContainerUsedEpisodeKeys] = useState([]);
|
||||
const [settingsMap, setSettingsMap] = useState({});
|
||||
const [presetDisplayMap, setPresetDisplayMap] = useState({});
|
||||
const [scriptCatalog, setScriptCatalog] = useState([]);
|
||||
@@ -748,7 +820,7 @@ export default function PipelineStatusCard({
|
||||
const converterConfigSaveTimeoutRef = useRef(null);
|
||||
const selectedMetadataEpisodes = useMemo(() => {
|
||||
const rows = Array.isArray(selectedMetadata?.episodes) ? selectedMetadata.episodes : [];
|
||||
return rows
|
||||
const normalizedRows = rows
|
||||
.map((item) => {
|
||||
const episodeId = Number(item?.id || 0);
|
||||
const episodeNumber = Number(item?.number ?? item?.episodeNumber ?? 0);
|
||||
@@ -777,7 +849,15 @@ export default function PipelineStatusCard({
|
||||
const bId = Number.isFinite(b.episodeId) ? b.episodeId : Number.MAX_SAFE_INTEGER;
|
||||
return aId - bId;
|
||||
});
|
||||
}, [selectedMetadata?.episodes]);
|
||||
if (!Array.isArray(containerUsedEpisodeKeys) || containerUsedEpisodeKeys.length === 0) {
|
||||
return normalizedRows;
|
||||
}
|
||||
const usedKeySet = new Set(containerUsedEpisodeKeys);
|
||||
return normalizedRows.filter((episode) => {
|
||||
const key = buildEpisodeReferenceKey(episode);
|
||||
return !key || !usedKeySet.has(key);
|
||||
});
|
||||
}, [selectedMetadata?.episodes, containerUsedEpisodeKeys]);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
@@ -1333,6 +1413,102 @@ export default function PipelineStatusCard({
|
||||
const metadataProvider = String(selectedMetadata?.metadataProvider || '').trim().toLowerCase();
|
||||
return hasSeasonNumber || hasEpisodeList || metadataProvider === 'tmdb' || metadataProvider === 'themoviedb';
|
||||
}, [jobMediaProfile, selectedMetadata?.seasonNumber, selectedMetadata?.episodes, selectedMetadata?.metadataProvider]);
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
|
||||
const loadContainerUsedEpisodes = async () => {
|
||||
if (!isSeriesDvdReview || !retryJobId) {
|
||||
if (!cancelled) {
|
||||
setContainerUsedEpisodeKeys([]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const currentResponse = await api.getJob(retryJobId, { lite: true, forceRefresh: true });
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
const currentJob = currentResponse?.job && typeof currentResponse.job === 'object'
|
||||
? currentResponse.job
|
||||
: null;
|
||||
const currentJobId = normalizeJobId(currentJob?.id || retryJobId);
|
||||
const normalizedCurrentKind = String(currentJob?.job_kind || '').trim().toLowerCase();
|
||||
const containerJobId = normalizedCurrentKind === 'dvd_series_container'
|
||||
? normalizeJobId(currentJob?.id)
|
||||
: normalizeJobId(currentJob?.parent_job_id);
|
||||
|
||||
if (!containerJobId) {
|
||||
if (!cancelled) {
|
||||
setContainerUsedEpisodeKeys([]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const containerResponse = await api.getJob(containerJobId, { lite: true, forceRefresh: true });
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
const containerJob = containerResponse?.job && typeof containerResponse.job === 'object'
|
||||
? containerResponse.job
|
||||
: null;
|
||||
const children = Array.isArray(containerJob?.children) ? containerJob.children : [];
|
||||
const usedKeys = new Set();
|
||||
|
||||
for (const child of children) {
|
||||
const childId = normalizeJobId(child?.id);
|
||||
if (currentJobId && childId && currentJobId === childId) {
|
||||
continue;
|
||||
}
|
||||
if (isSeriesBatchEpisodePlan(child?.encodePlan)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const refs = collectEpisodeReferencesFromPlan(child?.encodePlan);
|
||||
for (const ref of refs) {
|
||||
const key = buildEpisodeReferenceKey(ref);
|
||||
if (key) {
|
||||
usedKeys.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
const batchEpisodes = Array.isArray(child?.handbrakeInfo?.seriesBatch?.episodes)
|
||||
? child.handbrakeInfo.seriesBatch.episodes
|
||||
: [];
|
||||
for (const episode of batchEpisodes) {
|
||||
const key = buildEpisodeReferenceKey({
|
||||
episodeId: episode?.episodeId,
|
||||
episodeNumber: episode?.episodeNumber,
|
||||
seasonNumber: episode?.seasonNumber
|
||||
});
|
||||
if (key) {
|
||||
usedKeys.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!cancelled) {
|
||||
setContainerUsedEpisodeKeys(Array.from(usedKeys));
|
||||
}
|
||||
} catch (_error) {
|
||||
if (!cancelled) {
|
||||
setContainerUsedEpisodeKeys([]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void loadContainerUsedEpisodes();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [
|
||||
isSeriesDvdReview,
|
||||
retryJobId,
|
||||
mediaInfoReview?.generatedAt,
|
||||
mediaInfoReview?.reviewConfirmedAt,
|
||||
selectedMetadata?.tmdbId,
|
||||
selectedMetadata?.seasonNumber
|
||||
]);
|
||||
const seriesBatchContext = useMemo(() => {
|
||||
const raw = pipeline?.context?.seriesBatch;
|
||||
if (!raw || typeof raw !== 'object') {
|
||||
|
||||
@@ -1344,8 +1344,8 @@ export default function RipperPage({
|
||||
imdbId: job?.imdb_id || null,
|
||||
poster: job?.poster_url || null,
|
||||
metadataProvider: context?.metadataProvider || 'omdb',
|
||||
seasonNumber: context?.seriesLookupHint?.seasonNumber || null,
|
||||
discNumber: context?.seriesLookupHint?.discNumber || null
|
||||
seasonNumber: null,
|
||||
discNumber: null
|
||||
};
|
||||
return {
|
||||
...context,
|
||||
@@ -1379,8 +1379,8 @@ export default function RipperPage({
|
||||
imdbId: null,
|
||||
poster: null,
|
||||
metadataProvider: currentContext?.metadataProvider || 'omdb',
|
||||
seasonNumber: currentContext?.seriesLookupHint?.seasonNumber || null,
|
||||
discNumber: currentContext?.seriesLookupHint?.discNumber || null
|
||||
seasonNumber: null,
|
||||
discNumber: null
|
||||
},
|
||||
metadataProvider: currentContext?.metadataProvider || currentContext?.selectedMetadata?.metadataProvider || 'omdb',
|
||||
metadataCandidates: Array.isArray(currentContext?.metadataCandidates) ? currentContext.metadataCandidates : [],
|
||||
@@ -2202,7 +2202,8 @@ export default function RipperPage({
|
||||
return response.results || [];
|
||||
};
|
||||
|
||||
const doSelectMetadata = async (payload) => {
|
||||
const doSelectMetadata = async (payload, options = {}) => {
|
||||
const suppressErrorToast = Boolean(options?.suppressErrorToast);
|
||||
setBusy(true);
|
||||
try {
|
||||
if (metadataDialogReassignMode) {
|
||||
@@ -2216,6 +2217,9 @@ export default function RipperPage({
|
||||
setMetadataDialogContext(null);
|
||||
setMetadataDialogReassignMode(false);
|
||||
} catch (error) {
|
||||
if (suppressErrorToast) {
|
||||
throw error;
|
||||
}
|
||||
showError(error);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
@@ -2223,17 +2227,27 @@ export default function RipperPage({
|
||||
};
|
||||
|
||||
const handleMetadataSubmit = async (payload) => {
|
||||
const payloadProvider = String(payload?.metadataProvider || '').trim().toLowerCase();
|
||||
const currentJobMediaProfile = String(effectiveMetadataDialogContext?.mediaProfile || '').trim().toLowerCase();
|
||||
const isSeriesDvdPayload = payloadProvider === 'tmdb' && currentJobMediaProfile === 'dvd';
|
||||
|
||||
if (metadataDialogReassignMode) {
|
||||
await doSelectMetadata(payload);
|
||||
return;
|
||||
}
|
||||
|
||||
// Serien-DVDs laufen ohne Film-Duplikatdialog weiter; die Disk-Pruefung
|
||||
// erfolgt serverseitig gegen den vorhandenen Staffel-Container.
|
||||
if (isSeriesDvdPayload) {
|
||||
await doSelectMetadata(payload, { suppressErrorToast: true });
|
||||
return;
|
||||
}
|
||||
|
||||
// Duplikatprüfung: nur bei OMDB-Auswahl mit imdbId sinnvoll
|
||||
const searchTitle = payload.title || '';
|
||||
const searchImdbId = payload.imdbId || null;
|
||||
if (searchTitle) {
|
||||
try {
|
||||
const currentJobMediaProfile = String(effectiveMetadataDialogContext?.mediaProfile || '').trim().toLowerCase();
|
||||
const historyResponse = await api.getJobs({ search: searchTitle, limit: 50, lite: true });
|
||||
const historyJobs = Array.isArray(historyResponse?.jobs) ? historyResponse.jobs : [];
|
||||
const duplicate = historyJobs.find((job) => {
|
||||
|
||||
Reference in New Issue
Block a user