music-metadata
Advanced tools
Comparing version 0.9.8 to 0.9.10
@@ -112,2 +112,5 @@ "use strict"; | ||
break; | ||
case 'gapless':// iTunes gap-less flag | ||
tag.value = tag.value === "1"; // boolean | ||
break; | ||
default: | ||
@@ -114,0 +117,0 @@ } |
@@ -41,3 +41,9 @@ "use strict"; | ||
TSS: 'encodersettings', | ||
WAR: 'website' | ||
WAR: 'website', | ||
'COM:iTunPGAP': 'gapless' | ||
/* ToDo: iTunes tags: | ||
'COM:iTunNORM': , | ||
'COM:iTunSMPB': 'encoder delay', | ||
'COM:iTunes_CDDB_IDs' | ||
*/ | ||
}; | ||
@@ -44,0 +50,0 @@ var ID3v22TagMapper = /** @class */ (function (_super) { |
@@ -30,3 +30,2 @@ "use strict"; | ||
TORY: "originalyear", | ||
"COMM:description": "comment", | ||
TPOS: "disk", | ||
@@ -33,0 +32,0 @@ TCON: "genre", |
@@ -12,2 +12,9 @@ /// <reference types="node" /> | ||
private static readFrameData(buf, frameHeader, majorVer, includeCovers); | ||
/** | ||
* Create a combined tag key, of tag & description | ||
* @param {string} tag e.g.: COM | ||
* @param {string} description e.g. iTunPGAP | ||
* @returns {string} e.g. COM:iTunPGAP | ||
*/ | ||
private static makeDescriptionTagName(tag, description); | ||
private tokenizer; | ||
@@ -14,0 +21,0 @@ private id3Header; |
@@ -102,2 +102,11 @@ "use strict"; | ||
}; | ||
/** | ||
* Create a combined tag key, of tag & description | ||
* @param {string} tag e.g.: COM | ||
* @param {string} description e.g. iTunPGAP | ||
* @returns {string} e.g. COM:iTunPGAP | ||
*/ | ||
ID3v2Parser.makeDescriptionTagName = function (tag, description) { | ||
return tag + (description ? ':' + description : ''); | ||
}; | ||
ID3v2Parser.prototype.parse = function (result, tokenizer, options) { | ||
@@ -151,8 +160,14 @@ var _this = this; | ||
var text = _c[_b]; | ||
_this.tags.push({ id: tag.id + ':' + tag.value.description, value: text }); | ||
_this.tags.push({ id: ID3v2Parser.makeDescriptionTagName(tag.id, tag.value.description), value: text }); | ||
} | ||
} | ||
else if (util_1.isArray(tag.value)) { | ||
else if (tag.id === 'COM') { | ||
for (var _d = 0, _e = tag.value; _d < _e.length; _d++) { | ||
var value = _e[_d]; | ||
_this.tags.push({ id: ID3v2Parser.makeDescriptionTagName(tag.id, value.description), value: value.text }); | ||
} | ||
} | ||
else if (util_1.isArray(tag.value)) { | ||
for (var _f = 0, _g = tag.value; _f < _g.length; _f++) { | ||
var value = _g[_f]; | ||
_this.tags.push({ id: tag.id, value: value }); | ||
@@ -165,4 +180,2 @@ } | ||
} | ||
// End of ID3v2 header | ||
// return new MpegParser(this.tokenizer, this.id3Header.size, this.options && this.options.duration).parse().then((format) => { | ||
}); | ||
@@ -169,0 +182,0 @@ }; |
@@ -84,3 +84,3 @@ /// <reference types="node" /> | ||
encodersettings?: string; | ||
gapless?: string; | ||
gapless?: boolean; | ||
barcode?: number; | ||
@@ -106,5 +106,5 @@ isrc?: string; | ||
peakLevel?: number; | ||
notes: string[]; | ||
originalalbum: string; | ||
originalartist: string; | ||
notes?: string[]; | ||
originalalbum?: string; | ||
originalartist?: string; | ||
discogs_release_id?: number; | ||
@@ -114,7 +114,7 @@ /** | ||
*/ | ||
replaygain_track_gain: string; | ||
replaygain_track_gain?: string; | ||
/** | ||
* Track peak [0..1] | ||
*/ | ||
replaygain_track_peak: number; | ||
replaygain_track_peak?: number; | ||
} | ||
@@ -121,0 +121,0 @@ export interface IFormat { |
{ | ||
"name": "music-metadata", | ||
"description": "Streaming music metadata parser for node and the browser.", | ||
"version": "0.9.8", | ||
"version": "0.9.10", | ||
"author": { | ||
@@ -51,9 +51,11 @@ "name": "Borewit", | ||
"compile-test": "tsc -p test", | ||
"compile": "npm run compile-src && npm run compile-test", | ||
"lint": "tslint 'src/**/*.ts' --exclude 'src/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'", | ||
"compile-doc": "tsc -p doc-gen", | ||
"compile": "npm run compile-src && npm run compile-test && npm run compile-doc", | ||
"lint": "tslint 'src/**/*.ts' --exclude 'src/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts' 'doc-gen/**/*.ts'", | ||
"test": "mocha --require ts-node/register test", | ||
"prepare": "npm run clean && npm run compile", | ||
"prepare": "npm run clean && npm run compile && npm run doc-gen", | ||
"start": "npm-run-all compile lint cover-test", | ||
"cover-test": "nyc npm run test", | ||
"coveralls": "npm run cover-test && nyc report --reporter=text-lcov | coveralls" | ||
"coveralls": "npm run cover-test && nyc report --reporter=text-lcov | coveralls", | ||
"doc-gen": "node doc-gen/gen.js" | ||
}, | ||
@@ -72,3 +74,3 @@ "dependencies": { | ||
"@types/mocha": "^2.2.48", | ||
"@types/node": "^9.4.6", | ||
"@types/node": "^9.4.7", | ||
"chai": "^4.1.2", | ||
@@ -78,5 +80,5 @@ "coveralls": "^3.0.0", | ||
"mime": "^2.2.0", | ||
"mocha": "^5.0.1", | ||
"mocha": "^5.0.4", | ||
"npm-run-all": "^4.1.2", | ||
"nyc": "^11.5.0", | ||
"nyc": "^11.6.0", | ||
"ts-node": "^4.1.0", | ||
@@ -83,0 +85,0 @@ "tslint": "^5.9.1", |
@@ -11,2 +11,5 @@ [![Build Status](https://travis-ci.org/Borewit/music-metadata.svg?branch=master)](https://travis-ci.org/Borewit/music-metadata) | ||
= Document Title | ||
:toc: | ||
## Installation | ||
@@ -46,11 +49,29 @@ Install via [npm](http://npmjs.org): | ||
### Options: | ||
* `duration`: default: `false`, if set to `true`, it will parse the whole media file if required to determine the duration. | ||
* `native`: default: `false`, if set to `true`, it will return native tags in addition to the `common` tags. | ||
* `skipCovers`: default: `false`, if set to `true`, it will not return embedded cover-art (images). | ||
### Import music-metadata: | ||
### Examples | ||
This is how you can import music-metadata in JavaScript, in you code: | ||
```JavaScript | ||
var mm = require('music-metadata'); | ||
``` | ||
##### JavaScript | ||
This is how it's done in TypeScript: | ||
```TypeScript | ||
import * as mm from 'music-metadata'; | ||
``` | ||
### Module Functions: | ||
There are two ways to parse (read) audio tracks: | ||
1) Audio (music) files can be parsed using direct file access using the [parseFile function](#parsefile) | ||
2) Using [Node.js streams](https://nodejs.org/api/stream.html) using the [parseStream function](#parseStream). | ||
Direct file access tends to be a little faster, because it can 'jump' to various parts in the file without being obliged to read intermediate date. | ||
#### parseFile function | ||
Parses the specified file (`filePath`) and returns a promise with the metadata result (`IAudioMetadata`). | ||
`parseFile(filePath: string, opts: IOptions = {}): Promise<IAudioMetadata>` | ||
Javascript example: | ||
```javascript | ||
@@ -70,3 +91,3 @@ var mm = require('music-metadata'); | ||
##### TypeScript | ||
Typescript example: | ||
```TypeScript | ||
@@ -85,10 +106,56 @@ import * as mm from 'music-metadata'; | ||
#### parseStream function | ||
Parses the provided audio stream for metadata. You should specify the corresponding [MIME-type] (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types). | ||
`parseStream(stream: Stream.Readable, mimeType: string, opts: IOptions = {}): Promise<IAudioMetadata>` | ||
Example: | ||
```javascript | ||
mm.parseStream(someReadStream, 'audio/mpeg', { fileSize: 26838 }) | ||
.then( function (metadata) { | ||
console.log(util.inspect(metadata, { showHidden: false, depth: null })); | ||
someReadStream.close(); | ||
}); | ||
``` | ||
### Options: | ||
* `duration`: default: `false`, if set to `true`, it will parse the whole media file if required to determine the duration. | ||
* `native`: default: `false`, if set to `true`, it will return native tags in addition to the `common` tags. | ||
* `skipCovers`: default: `false`, if set to `true`, it will not return embedded cover-art (images). | ||
* `fileSize`: only provide this in combination with `parseStream` function. | ||
Although in most cases duration is included, in some cases it requires `music-metadata` parsing the entire file. | ||
To enforce parsing the entire file if needed you should set `duration` to `true`. | ||
```javascript | ||
mm.parseFile('sample.mp3', {duration: true}) | ||
.then(function (metadata) { | ||
console.log(util.inspect(metadata, { showHidden: false, depth: null })); | ||
}) | ||
``` | ||
### Metadata result: | ||
If the returned promise resolves, the metadata (TypeScript `IAudioMetadata` interface) contains: | ||
* [`format: IFormat`](#format) Audio format information | ||
* `native: INativeTags` List of native (original) tags found in the parsed audio file. If the native option is set to false, this property is not defined. | ||
* [`common: ICommonTagsResult`](doc/common_metadata.md) Is a generic (abstract) way of reading metadata information. | ||
#### Format | ||
Audio format information. Defined in the TypeScript `IFormat` interface: | ||
* `dataformat?: string` Audio encoding format. e.g.: 'flac' | ||
* `tagTypes?: TagType[]` List of tagging formats found in parsed audio file | ||
* `duration?: number` Duration in seconds | ||
* `bitrate?: number` Number bits per second of encoded audio file | ||
* `sampleRate?: number` Sampling rate in Samples per second (S/s) | ||
* `bitsPerSample?: number` Audio bit depth | ||
* `encoder?` Encoder name | ||
* `codecProfile?: string` Codec profile | ||
* `lossless?: boolean` True if lossless, false for lossy encoding | ||
* `numberOfChannels?: number` Number of audio channels | ||
* `numberOfSamples?: number` Number of samples frames, one sample contains all channels. The duration is: numberOfSamples / sampleRate | ||
#### Common | ||
[Common tag documentation](doc/common_metadata.md) is automatically generated. | ||
## Examples | ||
For a live example see [parse MP3 (ID3v2.4 tags) stream with music-metadata](https://runkit.com/borewit/parse-mp3-id3v2-4-tags-stream-with-music-metadata), hosted on RunKit. | ||
@@ -105,4 +172,4 @@ | ||
Licence | ||
----------------- | ||
## Licence | ||
(The MIT License) | ||
@@ -109,0 +176,0 @@ |
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
282771
6857
181