Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run CI on pushes and PRs to master #2105

Merged
merged 6 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/nodejs-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Node.js CI
on:
push:
branches: ['master']
pull_request:
branches: ['master']

jobs:

Expand All @@ -10,11 +13,11 @@ jobs:

steps:

- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 22.x

- name: Install production dependencies, check node engine compatibility
run: yarn install --production=true
Expand All @@ -29,7 +32,7 @@ jobs:
run: yarn run build

- name: Upload build
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: build
path: |
Expand All @@ -47,23 +50,23 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x, 22.x]

steps:

- name: 'Checkout the repository'
uses: actions/checkout@v4

- name: Test with Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: yarn install --ignore-engines

- name: Download build
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build

Expand Down
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Node.js CI](https://github.com/Borewit/music-metadata/workflows/Node.js%20CI/badge.svg)
[![Node.js CI](https://github.com/Borewit/music-metadata/actions/workflows/nodejs-ci.yml/badge.svg?branch=master)](https://github.com/Borewit/music-metadata/actions?query=branch%3Amaster)
[![Build status](https://ci.appveyor.com/api/projects/status/tgtqynlon8t99qq5/branch/master?svg=true)](https://ci.appveyor.com/project/Borewit/music-metadata/branch/master)
[![NPM version](https://img.shields.io/npm/v/music-metadata.svg)](https://npmjs.org/package/music-metadata)
[![npm downloads](http://img.shields.io/npm/dm/music-metadata.svg)](https://npmcharts.com/compare/music-metadata,jsmediatags,musicmetadata,node-id3,mp3-parser,id3-parser,wav-file-info?start=600)
Expand All @@ -25,12 +25,12 @@ Supports any common audio and tagging format.
| AAC | ADTS / Advanced Audio Coding | [:link:](https://en.wikipedia.org/wiki/Advanced_Audio_Coding) | <img src="https://svgshare.com/i/UT8.svg" width="40" alt="AAC logo"> |
| 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) | |
| BWF | Broadcast Wave Format | [:link:](https://en.wikipedia.org/wiki/Broadcast_Wave_Format) | |
| BWF | Broadcast Wave Format | [:link:](https://en.wikipedia.org/wiki/Broadcast_Wave_Format) | |
| DSDIFF | Philips DSDIFF | [:link:](https://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://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/a/a2/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) | |
| Matroska | Matroska (EBML), mka, mkv | [:link:](https://wikipedia.org/wiki/Matroska) | <img src="https://upload.wikimedia.org/wikipedia/commons/1/1a/Matroska_2010.svg" width="80" alt="Matroska logo"> |
| Matroska | Matroska (EBML), mka, mkv | [:link:](https://wikipedia.org/wiki/Matroska) | <img src="https://upload.wikimedia.org/wikipedia/commons/1/1a/Matroska_2010.svg" width="80" alt="Matroska logo"> |
| 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 | [:link:](https://wikipedia.org/wiki/MPEG-4) | <img src="https://svgshare.com/i/UU3.svg" width="80" alt="mpeg 4 logo"> |
Expand All @@ -40,7 +40,7 @@ Supports any common audio and tagging format.
| Theora | | [:link:](https://en.wikipedia.org/wiki/Theora) | <img src="https://upload.wikimedia.org/wikipedia/commons/5/57/Theora_logo_2007.svg" width="70" alt="Theora logo"> |
| Vorbis | Vorbis audio compression | [: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 | RIFF WAVE | [:link:](https://wikipedia.org/wiki/WAV) | |
| WebM | webm | [:link:](https://wikipedia.org/wiki/WebM) | <img src="https://upload.wikimedia.org/wikipedia/commons/3/34/WebM_logo.svg" width="80" alt="Matroska logo"> |
| WebM | webm | [:link:](https://wikipedia.org/wiki/WebM) | <img src="https://upload.wikimedia.org/wikipedia/commons/3/34/WebM_logo.svg" width="80" alt="Matroska logo"> |
| WV | WavPack | [:link:](https://wikipedia.org/wiki/WavPack) | <img src="http://www.wavpack.com/wavpacklogo.svg" width="60" alt="WavPack logo"> |
| WMA | Windows Media Audio | [:link:](https://wikipedia.org/wiki/Windows_Media_Audio) | <img src="https://upload.wikimedia.org/wikipedia/commons/7/76/Windows_Media_Player_simplified_logo.svg" width="40" alt="Windows Media logo"> |

Expand Down Expand Up @@ -68,7 +68,7 @@ Support for encoding / format details:
* [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://raw.githubusercontent.com/Borewit/audio-tag-analyzer/master/src/assets/icon/audio-tag-analyzer.svg" width="40">Audio Tag Analyzer](https://audio-tag-analyzer.netlify.com/)
Expand All @@ -83,7 +83,7 @@ Requires Node.js ≥ 14.13.1 engine.

### Browser Support

Although music-metadata is designed to run the node.js. [music-metadata-browser](https://github.com/Borewit/music-metadata-browser) can be used on the browser side.
Although music-metadata is designed to run the node.js. [music-metadata-browser](https://github.com/Borewit/music-metadata-browser) can be used on the browser side.

To avoid Node `fs` dependency inclusion, you may use a sub-module inclusion:
```js
Expand Down Expand Up @@ -193,7 +193,7 @@ import { inspect } from 'util';
#### parseStream function

Parses the provided audio stream for metadata.
It is recommended to provide the corresponding [MIME-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).
It is recommended to provide the corresponding [MIME-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).
An extension (e.g.: `.mp3`), filename or path will also work.
If the MIME-type or filename (via `fileInfo.path`) is not provided, or not understood, music-metadata will try to derive the type from the content.

Expand Down Expand Up @@ -268,9 +268,9 @@ import { inspect } from 'util';
```

#### ratingToStars function

Can be used to convert the normalized rating value to the 0..5 stars, where 0 an undefined rating, 1 the star the lowest rating and 5 the highest rating.

```ts
ratingToStars(rating: number): number
```
Expand Down Expand Up @@ -301,19 +301,19 @@ import { parseFile, selectCover } from 'music-metadata';

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`.

### Metadata result

If the returned promise resolves, the metadata (TypeScript `IAudioMetadata` interface) contains:
* [`metadata.format`](#metadataformat) Audio format information
* [`metadata.common`](#metadatacommon) Is a generic (abstract) way of reading metadata information.
* [`metadata.trackInfo`](#metadatatrackInfo) Is a generic (abstract) way of reading metadata information.
* [`metadata.common`](#metadatacommon) Is a generic (abstract) way of reading metadata information.
* [`metadata.trackInfo`](#metadatatrackInfo) Is a generic (abstract) way of reading metadata information.
* `metadata.native` List of native (original) tags found in the parsed audio file.

#### `metadata.format`

The questionmark `?` indicates the property is optional.
The questionmark `?` indicates the property is optional.

Audio format information. Defined in the TypeScript `IFormat` interface:
* `format.container?: string` Audio encoding format. e.g.: 'flac'
* `format.codec?` Name of the codec (algorithm used for the audio compression)
Expand All @@ -333,11 +333,11 @@ Audio format information. Defined in the TypeScript `IFormat` interface:
#### `metadata.trackInfo`

To support advanced containers like [Matroska](https://wikipedia.org/wiki/Matroska) or [MPEG-4](https://en.wikipedia.org/wiki/MPEG-4), which may contain multiple audio and video tracks, the **experimental** `metadata.trackInfo` has been added,

`metadata.trackInfo` is either `undefined` or has an **array** of [trackInfo](#trackinfo)

##### trackInfo

Audio format information. Defined in the TypeScript `IFormat` interface:
* `trackInfo.type?: TrackType` Track type
* `trackInfo.codecName?: string` Codec name
Expand Down Expand Up @@ -370,7 +370,7 @@ Audio format information. Defined in the TypeScript `IFormat` interface:
* `videoTrack.aspectRatioType?: number`
* `videoTrack.colourSpace?: Buffer`
* `videoTrack.gammaValue?: number`

#### `metadata.common`

[Common tag documentation](doc/common_metadata.md) is automatically generated.
Expand Down Expand Up @@ -436,33 +436,33 @@ img.src = `data:${picture.format};base64,${picture.data.toString('base64')}`;

```js
import { parseFile } from 'music-metadata';

function parseFiles(audioFiles) {

const audioFile = audioFiles.shift();

if (audioFile) {
return parseFile(audioFile).then(metadata => {
// Do great things with the metadata
return parseFiles(audioFiles); // process rest of the files AFTER we are finished
})
}
}

```

2. Use async/await

Use [async/await](https://javascript.info/async-await)

```js
import { parseFile } from 'music-metadata';

// it is required to declare the function 'async' to allow the use of await
async function parseFiles(audioFiles) {

for (const audioFile of audioFiles) {

// await will ensure the metadata parsing is completed before we move on to the next file
const metadata = await parseFile(audioFile);
// Do great things with the metadata
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
# install modules
- yarn install
- yarn install --ignore-engines

build_script:
- yarn run lint
Expand Down
2 changes: 1 addition & 1 deletion lib/matroska/MatroskaParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class MatroskaParser extends BasicParser {

private async readString(e: IHeader): Promise<string> {
const rawString = await this.tokenizer.readToken(new StringType(e.len, 'utf-8'));
return rawString.replace(/\00.*$/g, '');
return rawString.replace(/\x00.*$/g, '');
}

private async readBuffer(e: IHeader): Promise<Buffer> {
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,36 +98,36 @@
"token-types": "^5.0.1"
},
"devDependencies": {
"@types/chai": "^4.3.9",
"@types/chai": "^4.3.16",
"@types/chai-as-promised": "^7.1.8",
"@types/debug": "^4.1.12",
"@types/file-type": "^10.9.1",
"@types/mocha": "^10.0.3",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"c8": "^9.1.0",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"del-cli": "5.1.0",
"@types/mocha": "^10.0.7",
"@types/node": "^20.14.9",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"c8": "^10.1.2",
"chai": "^5.1.1",
"chai-as-promised": "^8.0.0",
"del-cli": "^5.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.5.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-unicorn": "^49.0.0",
"eslint-plugin-unicorn": "^54.0.0",
"mime": "^4.0.3",
"mocha": "^10.2.0",
"mocha": "^10.5.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"remark-cli": "^12.0.0",
"remark-preset-lint-markdown-style-guide": "^5.1.3",
"ts-node": "^10.9.1",
"typescript": "^5.4.5"
"prettier": "^3.3.2",
"remark-cli": "^12.0.1",
"remark-preset-lint-markdown-style-guide": "^6.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.2"
},
"engines": {
"node": "^14.13.1 || >=16.0.0"
"node": ">=16.0.0"
},
"repository": {
"type": "git",
Expand Down
Loading
Loading