mirror of
https://github.com/chrisbenincasa/tunarr
synced 2026-04-21 21:37:40 +00:00
29 lines
716 B
TypeScript
29 lines
716 B
TypeScript
import { parseWebStream } from 'music-metadata';
|
|
import { createReadStream } from 'node:fs';
|
|
import { Readable } from 'node:stream';
|
|
import { inspect } from 'node:util';
|
|
import yargs from 'yargs';
|
|
import { hideBin } from 'yargs/helpers';
|
|
|
|
const args = yargs()
|
|
.command('$0 <file>', 'Print metadata')
|
|
.positional('file', {
|
|
demandOption: true,
|
|
type: 'string',
|
|
})
|
|
.option('full', {
|
|
boolean: true,
|
|
default: false,
|
|
})
|
|
.help()
|
|
.parseSync(hideBin(process.argv));
|
|
|
|
const parsedTrackMetadata = await parseWebStream(
|
|
Readable.toWeb(createReadStream(args.file)),
|
|
);
|
|
|
|
if (args.full) {
|
|
console.log(inspect(parsedTrackMetadata, false, null, true));
|
|
} else {
|
|
console.log(parsedTrackMetadata);
|
|
}
|