fix?: undefined tags

Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
This commit is contained in:
2026-02-22 18:23:29 +01:00
parent d9013772ef
commit f97fb957dc
2 changed files with 10 additions and 7 deletions

View File

@@ -92,7 +92,7 @@ export function createListener(
function serializeStreams(streams: Vector<Raw<Stream>>) {
return vectorToArray(streams).map((stream) => ({
...stream,
tags: dictionaryVectorToRecord(stream.tags),
tags: (stream && stream.tags) ? dictionaryVectorToRecord(stream.tags) : {},
}));
}
@@ -109,16 +109,19 @@ export function createListener(
const rawInfo = get_file_info(`/work/${fileName}`);
// Safety check on rawInfo itself
if (!rawInfo) throw new Error("FFprobe failed to return file info");
return {
streams: serializeStreams(rawInfo.streams),
chapters: vectorToArray(rawInfo.chapters).map((chapter) => ({
chapters: rawInfo.chapters ? vectorToArray(rawInfo.chapters).map((chapter) => ({
...chapter,
tags: dictionaryVectorToRecord(chapter.tags),
})),
tags: chapter.tags ? dictionaryVectorToRecord(chapter.tags) : {},
})) : [],
format: {
...rawInfo.format,
tags: dictionaryVectorToRecord(rawInfo.format.tags),
},
tags: (rawInfo.format && rawInfo.format.tags) ? dictionaryVectorToRecord(rawInfo.format.tags) : {},
}
};
} finally {
// Cleanup mount.