Measured performance
3.4 ms
Parse a typical album (ERN 4.3, 75 KB)
20–24 MiB/s
Parser throughput on real ERN 4.3
441 ms
Parse a ~10 MB catalog
11.4 ms
Build a 12-track album (ERN 4.3)
Parse time by message size (log scale)
10 KB
0.5 ms
0.5 ms
75 KB
3.4 ms
3.4 ms
330 KB
14 ms
14 ms
10 MB
441 ms
441 ms
Criterion benches on an Apple M1 Pro, release profile. Method and full results
Parse and build in three languages
- Node.js
- Python
- Rust
const fs = require('node:fs');
const { DdexParser } = require('ddex-parser');
const { DdexBuilder } = require('ddex-builder');
// Parse any ERN 3.8.x, 4.2 or 4.3 message
const message = new DdexParser().parseSync(fs.readFileSync('release.xml', 'utf8'));
for (const release of message.releases) {
console.log(release.title, 'by', release.displayArtist, release.releaseDates.map((d) => d.date));
for (const track of release.tracks) {
console.log(` ${track.position}. ${track.title} [${track.isrc}]`);
}
}
// Build ERN 4.3: a required field that is missing fails the build, naming the field
const party = (name, id) => ({ party_name: [{ text: name }], party_id: id });
const request = {
header: {
message_sender: party('Example Label', 'PADPIDA0000000001'),
message_recipient: party('Example DSP', 'PADPIDA0000000002'),
},
version: '4.3',
avs_version_id: '12',
language_and_script_code: 'en',
releases: [{
release_id: 'A1-ABCDE-0000000001-M',
title: [{ text: 'Example Single' }],
artist: 'Example Artist',
label: 'Example Label',
release_type: 'Single',
genre: 'Pop',
parental_warning_type: 'NotExplicit',
tracks: [{
track_id: 'T1',
isrc: 'ZZ0000000001',
title: 'Example Track',
duration: 'PT3M42S',
artist: 'Example Artist',
resource_type: 'MusicalWorkSoundRecording',
parental_warning_type: 'NotExplicit',
}],
}],
};
new DdexBuilder().build(request).then((xml) => console.log(xml));
npm install ddex-parser ddex-builder
from ddex_builder import DdexBuilder
from ddex_parser import DDEXParser
# Parse any ERN 3.8.x, 4.2 or 4.3 message, then analyze it with pandas
with open("release.xml", encoding="utf-8") as f:
message = DDEXParser().parse(f.read())
tracks = message.to_dataframe("tracks")
print(tracks[["track_title", "isrc", "duration", "disc_number"]])
print("total minutes:", tracks["duration"].sum() / 60)
# Build ERN 4.3: a required field that is missing fails the build, naming the field
def party(name, party_id):
return {"party_name": [{"text": name}], "party_id": party_id}
xml = DdexBuilder().build({
"header": {
"message_sender": party("Example Label", "PADPIDA0000000001"),
"message_recipient": party("Example DSP", "PADPIDA0000000002"),
},
"version": "4.3",
"avs_version_id": "12",
"language_and_script_code": "en",
"releases": [{
"release_id": "A1-ABCDE-0000000001-M",
"title": [{"text": "Example Single"}],
"artist": "Example Artist",
"label": "Example Label",
"release_type": "Single",
"genre": "Pop",
"parental_warning_type": "NotExplicit",
"tracks": [{
"track_id": "T1",
"isrc": "ZZ0000000001",
"title": "Example Track",
"duration": "PT3M42S",
"artist": "Example Artist",
"resource_type": "MusicalWorkSoundRecording",
"parental_warning_type": "NotExplicit",
}],
}],
"deals": [],
})
print(xml)
pip install "ddex-parser[pandas]" ddex-builder
use ddex_builder::builder::{LocalizedStringRequest, PartyRequest, ReleaseRequest, TrackRequest};
use ddex_builder::{BuildOptions, BuildRequest, DDEXBuilder};
use ddex_parser::DDEXParser;
use std::io::Cursor;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Parse any ERN 3.8.x, 4.2 or 4.3 message
let message = DDEXParser::new().parse(Cursor::new(std::fs::read("release.xml")?))?;
for release in &message.flat.releases {
println!("{:?} by {:?}", release.default_title, release.display_artist);
for track in &release.tracks {
println!(" {}. {:?} [{:?}]", track.position, track.title, track.isrc);
}
}
// Build ERN 4.3: a required field that is missing fails the build, naming the field
let text = |s: &str| vec![LocalizedStringRequest { text: s.into(), language_code: None }];
let party = |name: &str, id: &str| PartyRequest {
party_name: text(name),
party_id: Some(id.into()),
party_reference: None,
};
let mut request = BuildRequest {
version: "4.3".into(),
avs_version_id: Some("12".into()),
language_and_script_code: Some("en".into()),
releases: vec![ReleaseRequest {
release_id: "A1-ABCDE-0000000001-M".into(),
title: text("Example Single"),
artist: "Example Artist".into(),
label: Some("Example Label".into()),
release_type: Some("Single".into()),
genre: Some("Pop".into()),
parental_warning_type: Some("NotExplicit".into()),
tracks: vec![TrackRequest {
track_id: "T1".into(),
isrc: "ZZ0000000001".into(),
title: "Example Track".into(),
duration: "PT3M42S".into(),
artist: "Example Artist".into(),
resource_type: Some("MusicalWorkSoundRecording".into()),
parental_warning_type: Some("NotExplicit".into()),
..Default::default()
}],
..Default::default()
}],
..Default::default()
};
request.header.message_sender = party("Example Label", "PADPIDA0000000001");
request.header.message_recipient = party("Example DSP", "PADPIDA0000000002");
let result = DDEXBuilder::new().build(request, BuildOptions::default())?;
println!("{}", result.xml);
Ok(())
}
cargo add ddex-parser ddex-builder
What you get in 0.5.0
Pre-1.0: see the known issues and roadmap. Validate messages against the XSDs and business rules with DDEX Workbench.