Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

music-metadata-browser

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

music-metadata-browser - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

64

dist/index.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -31,10 +23,8 @@ const initDebug = require("debug");

*/
function parseReadableStream(stream, contentType, options) {
return __awaiter(this, void 0, void 0, function* () {
const ns = new readable_web_to_node_stream_1.ReadableWeToNodeStream(stream);
const res = yield exports.parseNodeStream(ns, contentType, options);
debug(`Completed parsing from stream bytesRead=${ns.bytesRead} / fileSize=${options && options.fileSize ? options.fileSize : '?'}`);
yield ns.close();
return res;
});
async function parseReadableStream(stream, contentType, options) {
const ns = new readable_web_to_node_stream_1.ReadableWeToNodeStream(stream);
const res = await exports.parseNodeStream(ns, contentType, options);
debug(`Completed parsing from stream bytesRead=${ns.bytesRead} / fileSize=${options && options.fileSize ? options.fileSize : '?'}`);
await ns.close();
return res;
}

@@ -69,27 +59,25 @@ exports.parseReadableStream = parseReadableStream;

*/
function fetchFromUrl(audioTrackUrl, options) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield fetch(audioTrackUrl);
const contentType = response.headers.get('Content-Type');
const headers = [];
response.headers.forEach(header => {
headers.push(header);
});
if (response.ok) {
if (response.body) {
const res = yield this.parseReadableStream(response.body, contentType, options);
debug('Closing HTTP-readable-stream...');
yield response.body.cancel();
debug('HTTP-readable-stream closed.');
return res;
}
else {
// Fall back on Blob
return this.parseBlob(yield response.blob(), options);
}
async function fetchFromUrl(audioTrackUrl, options) {
const response = await fetch(audioTrackUrl);
const contentType = response.headers.get('Content-Type');
const headers = [];
response.headers.forEach(header => {
headers.push(header);
});
if (response.ok) {
if (response.body) {
const res = await this.parseReadableStream(response.body, contentType, options);
debug('Closing HTTP-readable-stream...');
await response.body.cancel();
debug('HTTP-readable-stream closed.');
return res;
}
else {
throw new Error(`HTTP error status=${response.status}: ${response.statusText}`);
// Fall back on Blob
return this.parseBlob(await response.blob(), options);
}
});
}
else {
throw new Error(`HTTP error status=${response.status}: ${response.statusText}`);
}
}

@@ -96,0 +84,0 @@ exports.fetchFromUrl = fetchFromUrl;

{
"name": "music-metadata-browser",
"version": "1.0.0",
"version": "1.1.0",
"description": "Browserifed version of music-metadata",

@@ -64,2 +64,3 @@ "main": "dist/index.js",

"lint": "npm run tslint && npm run eslint",
"test": "karma start",
"karma": "karma start",

@@ -75,5 +76,5 @@ "karma-firefox": "karma start --browsers Firefox",

"devDependencies": {
"@types/jasmine": "^3.3.2",
"@types/node": "^10.12.15",
"coveralls": "^3.0.2",
"@types/jasmine": "^3.3.12",
"@types/node": "^12.0.2",
"coveralls": "^3.0.3",
"del-cli": "^1.1.0",

@@ -94,3 +95,3 @@ "eslint": "^5.16.0",

"stream-http": "^3.0.0",
"ts-loader": "^5.4.4",
"ts-loader": "^6.0.1",
"tslint": "^5.16.0",

@@ -101,6 +102,6 @@ "typescript": "^3.4.5",

"dependencies": {
"assert": "^1.4.1",
"assert": "^2.0.0",
"buffer": "^5.2.1",
"debug": "^4.0.1",
"music-metadata": "^3.8.0",
"music-metadata": "^4.0.0",
"readable-stream": "^3.3.0",

@@ -107,0 +108,0 @@ "readable-web-to-node-stream": "^1.0.0",

@@ -17,4 +17,2 @@ [![Build Status](https://travis-ci.org/Borewit/music-metadata-browser.svg?branch=master)](https://travis-ci.org/Borewit/music-metadata-browser)

* Supports metadata of the following audio and tag types:
### Support for audio file types

@@ -25,12 +23,15 @@

| AIFF / AIFF-C | Audio Interchange File Format | [:link:](https://wikipedia.org/wiki/Audio_Interchange_File_Format) | <img src="https://upload.wikimedia.org/wikipedia/commons/8/84/Apple_Computer_Logo_rainbow.svg" width="40" alt="Apple rainbow logo"> |
| AAC | ADTS / Advanced Audio Coding | [:link:](https://en.wikipedia.org/wiki/Advanced_Audio_Coding) | |
| APE | Monkey's Audio | [:link:](https://wikipedia.org/wiki/Monkey's_Audio) | <img src="https://foreverhits.files.wordpress.com/2015/05/ape_audio.jpg" width="40" alt="Monkey's Audio logo"> |
| ASF | Advanced Systems Format | [:link:](https://wikipedia.org/wiki/Advanced_Systems_Format) | |
| DSDIFF | Philips DSDIFF | [:link:](https://en.wikipedia.org/wiki/Direct_Stream_Digital) | <img src="https://upload.wikimedia.org/wikipedia/commons/b/bc/DSDlogo.svg" width="80" alt="DSD logo"> |
| DSF | Sony's DSD Stream File | [:link:](https://en.wikipedia.org/wiki/Direct_Stream_Digital) | <img src="https://upload.wikimedia.org/wikipedia/commons/b/bc/DSDlogo.svg" width="80" alt="DSD logo"> |
| FLAC | Free Lossless Audio Codec | [:link:](https://wikipedia.org/wiki/FLAC) | <img src="https://upload.wikimedia.org/wikipedia/commons/e/e0/Flac_logo_vector.svg" width="80" alt="FLAC logo"> |
| MP2 | MPEG-1 Audio Layer II | [:link:](https://wikipedia.org/wiki/MPEG-1_Audio_Layer_II) | |
| MP3 | MPEG-1 / MPEG-2 Audio Layer III | [:link:](https://wikipedia.org/wiki/MP3) | <img src="https://upload.wikimedia.org/wikipedia/commons/e/ea/Mp3.svg" width="80" alt="MP3 logo"> |
| MPC | Musepack SV7 | [:link:](https://wikipedia.org/wiki/Musepack) | <img src="https://www.musepack.net/pictures/musepack_logo.png" width="80" alt="musepack logo"> |
| MPEG 4 | mp4, m4a, m4v, aac | [:link:](https://wikipedia.org/wiki/MPEG-4) | <img src="https://svgshare.com/i/8Ss.svg" width="40" alt="AAC logo"> |
| MPC | Musepack SV7 | [:link:](https://wikipedia.org/wiki/Musepack) | <img src="https://www.musepack.net/pictures/musepack_logo.png" width="80" alt="musepack logo"> |
| MPEG 4 | mp4, m4a, m4v | [:link:](https://wikipedia.org/wiki/MPEG-4) | <img src="https://svgshare.com/i/8Ss.svg" width="40" alt="AAC logo"> |
| Ogg / Opus | | [:link:](https://wikipedia.org/wiki/Opus_(audio_format)) | <img src="https://upload.wikimedia.org/wikipedia/commons/0/02/Opus_logo2.svg" width="80" alt="Opus logo"> |
| Ogg / Speex | | [:link:](https://wikipedia.org/wiki/Speex) | <img src="https://upload.wikimedia.org/wikipedia/commons/b/b5/Speex_logo_2006.svg" width="80" alt="Speex logo"> |
| Ogg / Vorbis | | [:link:](https://wikipedia.org/wiki/Ogg_Vorbis) | <img src="https://upload.wikimedia.org/wikipedia/commons/8/8d/Xiph.Org_logo_square.svg" width="70" alt="Vorbis logo"> |
| Ogg / Vorbis | | [:link:](https://wikipedia.org/wiki/Ogg_Vorbis) | <img src="https://upload.wikimedia.org/wikipedia/commons/8/8d/Xiph.Org_logo_square.svg" width="70" alt="Vorbis logo"> |
| WAV | | [:link:](https://wikipedia.org/wiki/WAV) | <img src="https://www.shareicon.net/download/2015/12/08/684232_file.svg" width="60" alt="WAV logo"> |

@@ -42,7 +43,7 @@ | WV | WavPack | [:link:](https://wikipedia.org/wiki/WavPack) | <img src="http://www.wavpack.com/wavpacklogo.svg" width="60" alt="WavPack logo"> |

* [APE](https://en.wikipedia.org/wiki/APE_tag)
* [ASF](https://en.wikipedia.org/wiki/Advanced_Systems_Format)
* EXIF 2.3
* [ID3](https://wikipedia.org/wiki/ID3): ID3v1, ID3v1.1, ID3v2.2, [ID3v2.3](http://id3.org/id3v2.3.0) & [ID3v2.4](http://id3.org/id3v2.4.0-frames)
* [RIFF](https://en.wikipedia.org/wiki/Resource_Interchange_File_Format)/INFO
* [APE](https://en.wikipedia.org/wiki/APE_tag)
* [ASF](https://en.wikipedia.org/wiki/Advanced_Systems_Format)
* EXIF 2.3
* [ID3](https://wikipedia.org/wiki/ID3): ID3v1, ID3v1.1, ID3v2.2, [ID3v2.3](http://id3.org/id3v2.3.0) & [ID3v2.4](http://id3.org/id3v2.4.0-frames)
* [RIFF](https://en.wikipedia.org/wiki/Resource_Interchange_File_Format)/INFO

@@ -54,12 +55,11 @@ Support for [MusicBrainz](https://musicbrainz.org/) tags as written by [Picard](https://picard.musicbrainz.org/).

Support for encoding / format details:
* [Bit rate](https://wikipedia.org/wiki/Bit_rate)
* [Audio bit depth](https://wikipedia.org/wiki/Audio_bit_depth)
* Duration
* encoding profile (e.g. [CBR](https://en.wikipedia.org/wiki/Constant_bitrate), V0, V2)
* [Bit rate](https://wikipedia.org/wiki/Bit_rate)
* [Audio bit depth](https://wikipedia.org/wiki/Audio_bit_depth)
* Duration
* encoding profile (e.g. [CBR](https://en.wikipedia.org/wiki/Constant_bitrate), V0, V2)
## Online demo's
* [<img src="https://gitcdn.xyz/repo/Borewit/audio-tag-analyzer/master/src/assets/icon/audio-tag-analyzer.svg" width="40">Audio Tag Analyzer](https://audio-tag-analyzer.netlify.com/)
* [<img src="https://svgshare.com/i/8uW.svg" width="40"> Webamp](https://webamp.org/)
* [<img src="https://gitcdn.xyz/repo/Borewit/audio-tag-analyzer/master/src/assets/icon/audio-tag-analyzer.svg" width="40">Audio Tag Analyzer](https://audio-tag-analyzer.netlify.com/)
* [<img src="https://svgshare.com/i/8uW.svg" width="40"> Webamp](https://webamp.org/)
### Donation

@@ -82,3 +82,3 @@ Not required, but would be extremely motivating.

Import music-metadata in JavaScript:
Import music-metadata in JavaScript
```JavaScript

@@ -88,3 +88,3 @@ const mm = require('music-metadata-browser');

This is how it's done in TypeScript:
This is how it's done in TypeScript
```TypeScript

@@ -210,9 +210,9 @@ import * as mm from 'music-metadata-browser';

The following (optional) configurations can be passed:
* `duration`: default: `false`, if set to `true`, it will parse the whole media file if required to determine the duration.
* `fileSize`: provide this if parsing from a stream.
* `loadParser: (moduleName: string) => Promise<ITokenParser>;`: default: lazy load using require, allows custom async lazy loading of parser modules. The resolved `ITokenParser` will not be cached.
* `native`: default: `false`, if set to `true`, it will return native tags in addition to the `common` tags.
* `observer: (update: MetadataEvent) => void;`: Will be called after each change to `common` (generic) tag, or `format` properties.
* `skipCovers`: default: `false`, if set to `true`, it will not return embedded cover-art (images).
* `skipPostHeaders? boolean` default: `false`, if set to `true`, it will not search all the entire track for additional headers. Only recommenced to use in combination with streams.
* `duration`: default: `false`, if set to `true`, it will parse the whole media file if required to determine the duration.
* `fileSize`: provide this if parsing from a stream.
* `loadParser: (moduleName: string) => Promise<ITokenParser>;`: default: lazy load using require, allows custom async lazy loading of parser modules. The resolved `ITokenParser` will not be cached.
* `native`: default: `false`, if set to `true`, it will return native tags in addition to the `common` tags.
* `observer: (update: MetadataEvent) => void;`: Will be called after each change to `common` (generic) tag, or `format` properties.
* `skipCovers`: default: `false`, if set to `true`, it will not return embedded cover-art (images).
* `skipPostHeaders? boolean` default: `false`, if set to `true`, it will not search all the entire track for additional headers. Only recommenced to use in combination with streams.

@@ -222,9 +222,9 @@ Although in most cases duration is included, in some cases it requires `music-metadata` parsing the entire file.

### Metadata result:
### 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: 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.

@@ -234,13 +234,13 @@ #### 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
* `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

@@ -247,0 +247,0 @@ #### Common

@@ -10,3 +10,3 @@ {

"experimentalDecorators": true,
"target": "es6",
"target": "ES2017",
"typeRoots": [

@@ -13,0 +13,0 @@ "node_modules/@types"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc