diff --git a/src/common/GenericTagTypes.ts b/src/common/GenericTagTypes.ts index 4e138d4b3..cb091e0e4 100644 --- a/src/common/GenericTagTypes.ts +++ b/src/common/GenericTagTypes.ts @@ -1,4 +1,4 @@ -export type TagType = 'vorbis' | 'ID3v1.1' | 'ID3v2.2' | 'ID3v2.3' | 'ID3v2.4' | 'APEv2' | 'asf' | 'iTunes MP4'; +export type TagType = 'vorbis' | 'ID3v1.1' | 'ID3v2.2' | 'ID3v2.3' | 'ID3v2.4' | 'APEv2' | 'asf' | 'iTunes MP4' | 'exif'; export type CommonTag = 'track' @@ -99,7 +99,7 @@ export type CommonTag = 'replaygain_track_gain' | 'replaygain_track_peak'; -export const TagPriority = ['APEv2', 'vorbis', 'ID3v2.4', 'ID3v2.3', 'ID3v2.2', 'asf', 'iTunes MP4', 'ID3v1.1']; +export const TagPriority = ['APEv2', 'vorbis', 'ID3v2.4', 'ID3v2.3', 'ID3v2.2', 'exif', 'asf', 'iTunes MP4', 'ID3v1.1']; export interface INativeTagMap { [index: string]: CommonTag; diff --git a/src/index.ts b/src/index.ts index df458d562..1d8a17624 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,6 +11,7 @@ import {APEv2TagMapper} from "./apev2/APEv2TagMapper"; import {ID3v22TagMapper} from "./id3v2/ID3v22TagMapper"; import {ID3v1TagMapper} from "./id3v1/ID3v1TagMap"; import {AsfTagMapper} from "./asf/AsfTagMapper"; +import {RiffInfoTagMapper} from "./riff/RiffInfoTagMap"; export interface IPicture { format: string, @@ -259,7 +260,8 @@ export class CombinedTagMapper { new MP4TagMapper(), new VorbisTagMapper(), new APEv2TagMapper(), - new AsfTagMapper() + new AsfTagMapper(), + new RiffInfoTagMapper() ].forEach(mapper => { this.registerTagMapper(mapper); }); diff --git a/src/riff/RiffInfoTagMap.ts b/src/riff/RiffInfoTagMap.ts index 5a36d0a3a..5f4297b6b 100644 --- a/src/riff/RiffInfoTagMap.ts +++ b/src/riff/RiffInfoTagMap.ts @@ -1,13 +1,33 @@ import {INativeTagMap} from "../common/GenericTagTypes"; +import {CommonTagMapper} from "../common/GenericTagMapper"; /** * RIFF Info Tags; part of the EXIF 2.3 * Ref: http://owl.phy.queensu.ca/~phil/exiftool/TagNames/RIFF.html#Info */ -export const RiffInfoTagMap: INativeTagMap = { +export const riffInfoTagMap: INativeTagMap = { IART: 'artist', // Artist ICRD: 'date', // DateCreated INAM: 'title', // Title + TITL: 'title', IPRD: 'album', // Product - ITRK: 'track' + ITRK: 'track', + COMM: 'comment', // Comments + ICMT: 'comment', // Country + ICNT: 'releasecountry', + GNRE: 'genre', // Genre + IWRI: 'writer', // WrittenBy + RATE: '_rating', + YEAR: 'year', + ISFT: 'encodedby', // Software + CODE: 'encodedby', // EncodedBy + TURL: 'website' // URL + // ITCH: 'technician' //Technician }; + +export class RiffInfoTagMapper extends CommonTagMapper { + + public constructor() { + super(['exif'], riffInfoTagMap); + } +} diff --git a/test/test_riff.ts b/test/test_riff.ts index 61b6174eb..664f920f5 100644 --- a/test/test_riff.ts +++ b/test/test_riff.ts @@ -57,6 +57,35 @@ describe("Extract metadata from RIFF (Resource Interchange File Format)", () => }); }); + // Issue https://github.com/Borewit/music-metadata/issues/75 + it("should map RIFF tags to common", () => { + + const filePath = path.join(__dirname, "samples", "issue_83.wav"); + + return mm.parseFile(filePath, {duration: true, native: true}).then(metadata => { + + const format = metadata.format; + assert.deepEqual(format.dataformat, "WAVE"); + assert.deepEqual(format.bitsPerSample, 24); + assert.deepEqual(format.sampleRate, 48000); + assert.deepEqual(format.numberOfSamples, 29762); + assert.deepEqual(format.duration, 0.6200416666666667); + assert.deepEqual(format.tagTypes, [ 'exif' ]); + + const exif = mm.orderTags(metadata.native.exif); + assert.deepEqual(exif.IART, ["FUCK ZORRO"]); + assert.deepEqual(exif.ICRD, ["2018-04-25T18:00:33-05:00"]); + assert.deepEqual(exif.ISFT, ["Adobe Audition CC 2018.1 (Macintosh)"]); + + const common = metadata.common; + assert.deepEqual(common.artists, ["FUCK ZORRO"]); + assert.deepEqual(common.date, "2018-04-25T18:00:33-05:00"); + assert.deepEqual(common.year, 2018); + assert.deepEqual(common.encodedby, "Adobe Audition CC 2018.1 (Macintosh)"); + + }); + }); + }); });