From 9b0ed4677d88dd73f2a1799a8b9d9b7901757343 Mon Sep 17 00:00:00 2001 From: PickleRick Date: Sat, 19 Sep 2026 20:01:20 +0200 Subject: [PATCH] fix: update extractChaptersXml to save XML file next to original source and reflect changes in documentation --- .../utility/extractChaptersXml/1.0.0/index.js | 9 ++++++--- README.md | 2 +- docs/integration-guide.md | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/LocalFlowPlugins/utility/extractChaptersXml/1.0.0/index.js b/LocalFlowPlugins/utility/extractChaptersXml/1.0.0/index.js index d896b56..bda443b 100644 --- a/LocalFlowPlugins/utility/extractChaptersXml/1.0.0/index.js +++ b/LocalFlowPlugins/utility/extractChaptersXml/1.0.0/index.js @@ -8,7 +8,7 @@ const fs = require('fs'); const details = () => ({ name: 'Extract Chapters to XML', description: - 'Extracts MKV chapter markers to an XML file in workDir using mkvextract. ' + 'Extracts MKV chapter markers to an XML file next to the original source using mkvextract. ' + 'Stores the output path in args.variables.chaptersXmlPath. ' + 'Safe to run even if the source has no chapters.', style: { borderColor: '#9C27B0' }, @@ -28,8 +28,11 @@ const plugin = async (args) => { const { jobLog, inputFileObj, variables, workDir, updateWorker } = args; const inputFile = inputFileObj._id; - const baseName = path.basename(inputFile, path.extname(inputFile)); - const xmlPath = path.join(workDir, `${baseName}_chapters.xml`); + // Keep sidecar files in the library when a prior plugin copied the media to workDir. + const originalFile = variables.originalLibraryFile || inputFile; + const targetDir = variables.originalLibraryDir || path.dirname(originalFile); + const baseName = path.basename(originalFile, path.extname(originalFile)); + const xmlPath = path.join(targetDir, `${baseName}_chapters.xml`); jobLog(`[extractChaptersXml] Source: ${inputFile}\n`); jobLog(`[extractChaptersXml] Output: ${xmlPath}\n`); diff --git a/README.md b/README.md index eea3c81..1c438db 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ Manually forces `isAnimation=true` and `x265Tune=animation` when a file was not **Category**: `utility` · **Step**: before transcode -Runs `mkvextract` to dump chapter markers to an XML file in `workDir`. Stores the path in `variables.chaptersXmlPath` for downstream use. Safe to run even when the source has no chapters (mkvextract exit 1 is treated as "no chapters"). +Runs `mkvextract` to dump chapter markers to an XML file **next to the original source file**. Stores the path in `variables.chaptersXmlPath` for downstream use. Safe to run even when the source has no chapters (mkvextract exit 1 is treated as "no chapters"). **No inputs required.** diff --git a/docs/integration-guide.md b/docs/integration-guide.md index 92d8f91..a8786e3 100644 --- a/docs/integration-guide.md +++ b/docs/integration-guide.md @@ -198,6 +198,7 @@ Per ogni file sorgente `/media/toshiba/Radarr/Film (2023)/Film (2023).mkv`: ├── Film (2023).eng.srt ← estratto da extractSubtitlesAndOcr ├── Film (2023).ita.forced.srt ← (se traccia forced presente) ├── Film (2023).eng.sdh.srt ← (se traccia SDH presente) + ├── Film (2023)_chapters.xml ← estratto da extractChaptersXml └── Film (2023).ita.dts ← backup (solo se codec DTS) o Film (2023).ita.thd ← backup (solo se codec TrueHD) ```