Refine MP4 metadata writes and add resilient XMP cleanup#37
Merged
ChrisAdamsdevelopment merged 1 commit intoMay 20, 2026
Merged
Conversation
Reviewer's GuideAdjusts MP4/QuickTime metadata writing to use explicit ItemList/QuickTime/Keys tags instead of generic tags and introduces a safer, two-phase XMP cleanup that preserves or reapplies descriptive metadata while keeping existing diagnostics intact. Sequence diagram for new two phase XMP cleanup in processMediaFilesequenceDiagram
participant P as processMediaFile
participant E as exiftool
P->>E: write(outputPath, metaToWrite, -overwrite_original)
P->>E: read(outputPath)
P->>P: buildMetadataSnapshot(tags_after_write)
P->>E: write(outputPath, {}, -XMP:all= -XMP:XMPToolkit= -overwrite_original)
P->>E: read(outputPath)
P->>P: buildMetadataSnapshot(afterXmpCleanupTags)
P->>P: hasDescriptiveMetadata(snapshot_after_cleanup)
alt preservedAfterXmpCleanup
P->>P: afterXmpCleanupSnapshot = snapshot_after_cleanup
else strippedAfterXmpCleanup
P->>E: write(outputPath, metaToWrite, -overwrite_original)
P->>E: write(outputPath, {}, -XMP-dc:all= -XMP-pdf:all= -XMP-tiff:all= -XMP-xmpDM:all= -XMP-x:XMPToolkit= -overwrite_original)
P->>E: read(outputPath)
P->>P: buildMetadataSnapshot(finalXmpCleanupTags)
P->>P: afterXmpCleanupSnapshot = snapshot_final
end
Flow diagram for updated MP4 metadata tag mapping in buildMetaToWriteflowchart TD
A[buildMetaToWrite<br/>inputs: platform, metadata<br/>derives: safeTitle, safeArtist,<br/>safeProducer, copyright,<br/>tagsArray, safeGenre,<br/>safeDescription, safeComment]
A --> B[Set title tags<br/>ItemList:Title = safeTitle<br/>QuickTime:Title = safeTitle<br/>Keys:Title = safeTitle<br/>Keys:DisplayName = safeTitle]
A --> C{safeArtist?}
C -->|yes| D[Set artist tags<br/>ItemList:Artist = safeArtist<br/>QuickTime:Artist = safeArtist<br/>ItemList:Author = safeArtist<br/>ItemList:AlbumArtist = safeArtist<br/>Keys:Artist = safeArtist<br/>Keys:Author = safeArtist]
A --> E{safeProducer?}
E -->|yes| F[Set producer tags<br/>ItemList:Producer = safeProducer<br/>Keys:Producer = safeProducer]
A --> G{copyright?}
G -->|yes| H[Set copyright tags<br/>ItemList:Copyright = copyright<br/>QuickTime:Copyright = copyright<br/>Keys:Copyright = copyright]
A --> I{tagsArray length > 0?}
I -->|yes| J[Set keyword tags<br/>ItemList:Keyword = tagsArray<br/>Keys:Keywords = tagsArray]
A --> K{safeGenre?}
K -->|yes| L[Set genre tags<br/>ItemList:Genre = safeGenre<br/>QuickTime:Genre = safeGenre<br/>Keys:Genre = safeGenre]
A --> M{platform-specific description/comment?}
M -->|YouTube/General safeDescription| N[Set description/comment<br/>ItemList:Description or Comment<br/>QuickTime:Description/Comment<br/>Keys:Description/Comment]
M -->|Spotify safeDescription| O[Set description<br/>ItemList:Description<br/>QuickTime:Description<br/>Keys:Description]
N --> P[Return metaToWrite<br/>with only ItemList/QuickTime/Keys tags]
O --> P
L --> P
J --> P
H --> P
F --> P
D --> P
B --> P
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ItemListandKeysdescriptive fields.Description
buildMetaToWriteinserver/processor.jsto remove unqualified/generic writes and switch to explicitItemList:*,QuickTime:*(kept), andKeys:*writes for title/artist/producer/copyright/genre/keywords/description/comment.Title,Artist,Author,AlbumArtist,Producer,Copyright,Genre,Keywords,Description, andCommentand added targetedKeys:/ItemList:equivalents (for exampleKeys:Title,Keys:DisplayName,Keys:Artist,ItemList:Author,ItemList:AlbumArtist,Keys:Producer,Keys:Keywords,Keys:Description, etc.).-XMP:all=then verifies descriptive metadata persistence and, if stripped, re-applies the metadata and runs a targeted fallback cleanup (-XMP-dc:all=,-XMP-pdf:all=,-XMP-tiff:all=,-XMP-xmpDM:all=,-XMP-x:XMPToolkit=) soItemList/Keysare not removed.runId, per-stage SHA-256 hashes,deepSnapshotsByStage, andmetadataPersistenceStagelogic.Testing
node --check server/processor.js, which completed successfully.buildMetaToWriteto confirm no assignments remain for unqualified generic tags (nometaToWrite.Title,metaToWrite.Artist,metaToWrite.Producer,metaToWrite.Copyright,metaToWrite.Genre,metaToWrite.Keywords,metaToWrite.Description, ormetaToWrite.Comment).buildMetaToWrite, but the environment lacks theexiftool-vendoredmodule so that dynamic import test could not run; this does not affect the static change or syntax validation.ItemList/Keysmappings for the Sobelo/Triple7 example remain present inbuildMetaToWriteand the XMP cleanup branch will preserve or reapply them as needed during processing.Codex Task
Summary by Sourcery
Refine MP4/QuickTime metadata writes to target ItemList/Keys tags explicitly and introduce a safer XMP cleanup sequence that preserves or restores descriptive metadata while maintaining existing diagnostics.
Bug Fixes:
Enhancements: