music-metadata
Advanced tools
Comparing version 0.6.0 to 0.6.1
'use strict'; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var equal = require("deep-equal"); | ||
@@ -8,0 +13,0 @@ var strtok = require("strtok2"); |
@@ -123,3 +123,3 @@ "use strict"; | ||
var res = {}; | ||
for (var i = 0; i < entries.length; i += 2) { | ||
for (var i = 0; i + 1 < entries.length; i += 2) { | ||
var names = entries[i + 1].split(','); | ||
@@ -126,0 +126,0 @@ res[entries[i]] = res.hasOwnProperty(entries[i]) ? res[entries[i]].concat(names) : names; |
@@ -46,3 +46,3 @@ import { HeaderType } from './tagmap'; | ||
mixer?: string[]; | ||
label?: string[]; | ||
label?: string; | ||
grouping?: string[]; | ||
@@ -58,3 +58,3 @@ subtitle?: string[]; | ||
media?: string; | ||
catalognumber?: string[]; | ||
catalognumber?: string; | ||
show?: string; | ||
@@ -132,5 +132,3 @@ showsort?: string; | ||
} | ||
export interface ICallbackType { | ||
(error?: Error, result?: IResult): void; | ||
} | ||
export declare type ICallbackType = (error?: Error, result?: IResult) => void; | ||
export interface IOptions { | ||
@@ -143,5 +141,3 @@ path?: string; | ||
export interface IFileSize { | ||
fileSize?: ({ | ||
(size: number): void; | ||
}); | ||
fileSize?: (size: number) => void; | ||
} | ||
@@ -148,0 +144,0 @@ /** |
@@ -74,5 +74,13 @@ /* jshint maxlen: 300 */ | ||
var self = this; | ||
// ToDo: expose warnings to API | ||
var warning = []; | ||
function tagCallback(headerType, tag, value) { | ||
if (value === null) | ||
if (value === null) { | ||
warning.push('tag ' + tag + ' is null'); | ||
return; | ||
} | ||
if (value === '') { | ||
warning.push('tag ' + tag + ' is empty'); | ||
return; | ||
} | ||
if (headerType === 'format') { | ||
@@ -130,24 +138,24 @@ metadata.format[tag] = value; | ||
} | ||
function done(exception) { | ||
function done(err) { | ||
isDone = true; | ||
istream.removeListener('close', onClose); | ||
/** | ||
* If MusicBrainz defined artists, the artist may be a single combined field, | ||
* otherwise artist may contain multiple artists. | ||
*/ | ||
if (metadata.common.artists && metadata.common.artists.length > 0) { | ||
metadata.common.artist = metadata.common.artist[0]; | ||
} | ||
else { | ||
if (metadata.common.artist) { | ||
metadata.common.artists = metadata.common.artist; | ||
if (metadata.common.artist.length > 1) { | ||
delete metadata.common.artist; | ||
if (!err) { | ||
/** | ||
* If MusicBrainz defined artists, the artist may be a single combined field, | ||
* otherwise artist may contain multiple artists. | ||
*/ | ||
if (metadata.common.artists && metadata.common.artists.length > 0) { | ||
metadata.common.artist = metadata.common.artist[0]; | ||
} | ||
else { | ||
if (metadata.common.artist) { | ||
metadata.common.artists = metadata.common.artist; | ||
if (metadata.common.artist.length > 1) { | ||
delete metadata.common.artist; | ||
} | ||
else { | ||
metadata.common.artist = metadata.common.artist[0]; | ||
} | ||
} | ||
else { | ||
metadata.common.artist = metadata.common.artist[0]; | ||
} | ||
} | ||
} | ||
if (!exception) { | ||
// We only emit aliased events once the 'done' event has been raised, | ||
@@ -163,3 +171,3 @@ // this is because an alias like 'artist' could have values split | ||
if (callback) { | ||
callback(exception, metadata); | ||
callback(err, metadata); | ||
} | ||
@@ -166,0 +174,0 @@ return strtok.DONE; |
@@ -112,2 +112,3 @@ 'use strict'; | ||
}; | ||
; | ||
var ApeParser = (function () { | ||
@@ -114,0 +115,0 @@ function ApeParser() { |
@@ -46,2 +46,4 @@ 'use strict'; | ||
this.version = MpegFrameHeader.VersionID[this.versionIndex]; | ||
if (this.version === null) | ||
throw new Error('Invalid MPEG Audio version'); | ||
this.channelMode = MpegFrameHeader.ChannelMode[this.channelModeIndex]; | ||
@@ -199,3 +201,10 @@ this.samplingRate = this.calcSamplingRate(); | ||
this.state = State.mpegSearchSync1; | ||
strtok.parse(stream, function (v, cb) { return _this.strParse(v, cb); }); | ||
strtok.parse(stream, function (v, cb) { | ||
try { | ||
return _this.strParse(v, cb); | ||
} | ||
catch (error) { | ||
return done(error); | ||
} | ||
}); | ||
}; | ||
@@ -202,0 +211,0 @@ MpegParser.prototype.end = function (callback, done) { |
@@ -74,5 +74,13 @@ /* jshint maxlen: 300 */ | ||
var self = this; | ||
// ToDo: expose warnings to API | ||
var warning = []; | ||
function tagCallback(headerType, tag, value) { | ||
if (value === null) | ||
if (value === null) { | ||
warning.push('tag ' + tag + ' is null'); | ||
return; | ||
} | ||
if (value === '') { | ||
warning.push('tag ' + tag + ' is empty'); | ||
return; | ||
} | ||
if (headerType === 'format') { | ||
@@ -130,24 +138,24 @@ metadata.format[tag] = value; | ||
} | ||
function done(exception) { | ||
function done(err) { | ||
isDone = true; | ||
istream.removeListener('close', onClose); | ||
/** | ||
* If MusicBrainz defined artists, the artist may be a single combined field, | ||
* otherwise artist may contain multiple artists. | ||
*/ | ||
if (metadata.common.artists && metadata.common.artists.length > 0) { | ||
metadata.common.artist = metadata.common.artist[0]; | ||
} | ||
else { | ||
if (metadata.common.artist) { | ||
metadata.common.artists = metadata.common.artist; | ||
if (metadata.common.artist.length > 1) { | ||
delete metadata.common.artist; | ||
if (!err) { | ||
/** | ||
* If MusicBrainz defined artists, the artist may be a single combined field, | ||
* otherwise artist may contain multiple artists. | ||
*/ | ||
if (metadata.common.artists && metadata.common.artists.length > 0) { | ||
metadata.common.artist = metadata.common.artist[0]; | ||
} | ||
else { | ||
if (metadata.common.artist) { | ||
metadata.common.artists = metadata.common.artist; | ||
if (metadata.common.artist.length > 1) { | ||
delete metadata.common.artist; | ||
} | ||
else { | ||
metadata.common.artist = metadata.common.artist[0]; | ||
} | ||
} | ||
else { | ||
metadata.common.artist = metadata.common.artist[0]; | ||
} | ||
} | ||
} | ||
if (!exception) { | ||
// We only emit aliased events once the 'done' event has been raised, | ||
@@ -163,3 +171,3 @@ // this is because an alias like 'artist' could have values split | ||
if (callback) { | ||
callback(exception, metadata); | ||
callback(err, metadata); | ||
} | ||
@@ -166,0 +174,0 @@ return strtok.DONE; |
@@ -46,2 +46,4 @@ 'use strict'; | ||
this.version = MpegFrameHeader.VersionID[this.versionIndex]; | ||
if (this.version === null) | ||
throw new Error('Invalid MPEG Audio version'); | ||
this.channelMode = MpegFrameHeader.ChannelMode[this.channelModeIndex]; | ||
@@ -199,3 +201,10 @@ this.samplingRate = this.calcSamplingRate(); | ||
this.state = State.mpegSearchSync1; | ||
strtok.parse(stream, function (v, cb) { return _this.strParse(v, cb); }); | ||
strtok.parse(stream, function (v, cb) { | ||
try { | ||
return _this.strParse(v, cb); | ||
} | ||
catch (error) { | ||
return done(error); | ||
} | ||
}); | ||
}; | ||
@@ -202,0 +211,0 @@ MpegParser.prototype.end = function (callback, done) { |
{ | ||
"name": "music-metadata", | ||
"description": "Streaming music metadata parser for node and the browser.", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"author": { | ||
@@ -64,3 +64,3 @@ "name": "Borewit", | ||
"testling": "^1.7.1", | ||
"tslint": "^4.1.1", | ||
"tslint": "^4.4.2", | ||
"typings": "2.0.0", | ||
@@ -67,0 +67,0 @@ "typescript": "^2.0.3" |
@@ -57,3 +57,3 @@ [![Build Status][travis-image]][travis-url] [![NPM version][npm-image]][npm-url] [![npm downloads][npm-downloads-image]][npm-url] | ||
import * as fs from 'fs' | ||
import * as mm from '..' | ||
import * as mm from 'music-metadata' | ||
import * as util from 'util' | ||
@@ -210,4 +210,5 @@ | ||
```javascript | ||
mm(fs.createReadStream('sample.mp3'), { duration: true }, function (err, metadata) { | ||
var audioStream = fs.createReadStream('sample.mp3'); | ||
mm(audioStream, { duration: true }, function (err, metadata) { | ||
audioStream.close(); | ||
}); | ||
@@ -218,4 +219,4 @@ ``` | ||
```javascript | ||
mm(fs.createReadStream('sample.mp3'), { duration: true, fileSize: 26838 }, function (err, metadata) { | ||
mm.parseStream(noFileStream, { duration: true, fileSize: 26838 }, function (err, metadata) { | ||
noFileStream.close(); | ||
}); | ||
@@ -243,3 +244,3 @@ ``` | ||
[travis-url]: https://travis-ci.org/profile/Borewit/music-metadata | ||
[travis-url]: https://travis-ci.org/Borewit/music-metadata | ||
[travis-image]: https://travis-ci.org/Borewit/music-metadata.svg?branch=master |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16313
243
1106860