-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix examples and update to ECMA version 8.
- Loading branch information
Showing
5 changed files
with
75 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"ecmaVersion": 8, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
const mm = require('../../lib'); // music-metadata | ||
const util = require('util'); | ||
|
||
mm.parseFile('../test/samples/MusicBrainz-multiartist [id3v2.4].V2.mp3') | ||
.then(function (metadata) { | ||
(async () => { | ||
try { | ||
const metadata = await mm.parseFile('../../test/samples/MusicBrainz - Beth Hart - Sinner\'s Prayer [id3v2.3].V2.mp3'); | ||
console.log(util.inspect(metadata, { showHidden: false, depth: null })); | ||
}) | ||
.catch(function (err) { | ||
} catch (error) { | ||
console.err(err.message); | ||
}); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,36 @@ | ||
const walk = require('walk'); | ||
const Walk = require('@root/walk'); | ||
const path = require('path'); | ||
const util = require('util'); | ||
const mm = require('../../lib'); // music-metadata | ||
|
||
const walker = walk.walk('M:\\'); | ||
async function walkFunc(err, pathname, dirent) { | ||
// err is failure to lstat a file or directory | ||
// pathname is relative path, including the file or folder name | ||
// dirent = { name, isDirectory(), isFile(), isSymbolicLink(), ... } | ||
|
||
let filesParsed = 0; | ||
|
||
walker.on('file', function (root, fileStats, next) { | ||
|
||
switch (path.extname(fileStats.name)) { | ||
case '.mp3': | ||
case '.m4a': | ||
case '.wav': | ||
case '.ogg': | ||
case '.flac': | ||
// Queue (asynchronous call) parsing of metadata | ||
const fn = path.join(root, fileStats.name); | ||
mm.parseFile(fn).then(metadata => { | ||
// console.log(util.inspect(metadata, { showHidden: false, depth: null })); | ||
console.log('Parsed %s files, last file: %s', ++filesParsed, fn); | ||
next(); // asynchronous call completed, 'release' next | ||
}).catch(function (err) { | ||
console.error('Error parsing: %s', fn); | ||
console.error(err.message); | ||
next(); | ||
}); | ||
break; | ||
if (dirent.isFile()) { | ||
console.log(`File: ${pathname}`); | ||
switch (path.extname(pathname)) { | ||
case '.mp3': | ||
case '.m4a': | ||
case '.wav': | ||
case '.ogg': | ||
case '.flac': | ||
// Queue (asynchronous call) parsing of metadata | ||
const metadata = await mm.parseFile(pathname); | ||
console.log(util.inspect(metadata, { showHidden: false, depth: null })); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
default: | ||
next(); // Go to next file, no asynchronous call 'queued' | ||
(async () => { | ||
try { | ||
await Walk.walk('M:\\_Classic', walkFunc); | ||
console.log('Done.'); | ||
} catch(err) { | ||
// Oops, something went wrong | ||
console.error(err.message); | ||
} | ||
}); | ||
})(); | ||
|