Skip to content

Commit

Permalink
Improve and fix Matroska tag mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Jun 26, 2021
1 parent 8b302a7 commit 92fda77
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/matroska/MatroskaTagMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { CaseInsensitiveTagMap } from '../common/CaseInsensitiveTagMap';
*/
const ebmlTagMap: INativeTagMap = {
'segment:title': 'title',
'album:ARITST': 'albumartist',
'album:ARITSTSORT': 'albumartistsort',
'album:ARTIST': 'albumartist',
'album:ARTISTSORT': 'albumartistsort',
'album:TITLE': 'album',
'album:DATE_RECORDED': 'originaldate',
'album:PART_NUMBER': 'disk',
'album:TOTAL_PARTS': 'totaltracks',
'track:ARTIST': 'artist',
'track:ARTISTSORT' : 'artistsort',
'track:TITLE': 'title',
Expand All @@ -18,6 +20,7 @@ const ebmlTagMap: INativeTagMap = {
'track:MUSICBRAINZ_ALBUMID': 'musicbrainz_albumid',
'track:MUSICBRAINZ_ARTISTID': 'musicbrainz_artistid',
'track:PUBLISHER': 'label',
'edition:TOTAL_PARTS': 'totaldiscs',
picture: 'picture'
};

Expand Down
Binary file added test/samples/matroska/My Baby Boy.webm
Binary file not shown.
21 changes: 20 additions & 1 deletion test/test-file-matroska.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,32 @@ describe('Matroska formats', () => {

const webmPath = path.join(matroskaSamplePath, '02 - Poxfil - Solid Ground (5 sec).opus.webm');

const {format} = await mm.parseFile(webmPath, {duration: false});
const {format, common} = await mm.parseFile(webmPath, {duration: false});

// format chunk information
assert.strictEqual(format.container, 'EBML/webm', 'format.container');
assert.strictEqual(format.codec, 'OPUS', 'format.codec');
assert.approximately(format.duration, 5.006509896, 1 / 100000, 'format.duration');
assert.strictEqual(format.sampleRate, 44100, 'format.sampleRate');

assert.strictEqual(common.title, 'Solid Ground', 'common.title');
assert.strictEqual(common.artist, 'Poxfil', 'common.artist');
assert.deepStrictEqual(common.track, {no: 2, of: 10}, 'common.track');
});

it('should parse "My Baby Boy.webm"', async () => {

const filePath = path.join(matroskaSamplePath, 'My Baby Boy.webm');

const {format, common} = await mm.parseFile(filePath, {duration: true});
assert.strictEqual(format.container, 'EBML/webm', 'format.container');
assert.strictEqual(format.codec, 'OPUS', 'format.codec');

assert.strictEqual(common.title, 'My Baby Boy', 'common.title');
assert.strictEqual(common.artist, 'theAngelcy', 'common.artist');
assert.strictEqual(common.albumartist, 'theAngelcy', 'common.albumartist');
assert.deepStrictEqual(common.track, {no: 2, of: 13}, 'common.track');
assert.deepStrictEqual(common.disk, {no: 1, of: 1}, 'common.disk');
});
});

Expand Down

0 comments on commit 92fda77

Please sign in to comment.