From 0b9ca4d565a3a1b73e28599f894118442a9d9826 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 13 May 2017 20:59:20 -0600 Subject: [PATCH] Very very basic start of a exiftool wrapper for description exctraction --- util/exiftool2desc.js | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 util/exiftool2desc.js diff --git a/util/exiftool2desc.js b/util/exiftool2desc.js new file mode 100755 index 00000000..5e744653 --- /dev/null +++ b/util/exiftool2desc.js @@ -0,0 +1,47 @@ +#!/usr/bin/env node + +/* jslint node: true */ +/* eslint-disable no-console */ +'use strict'; + +// :TODO: Make this it's own sep tool/repo + +const exiftool = require('exiftool'); +const fs = require('fs'); + +function main() { + const path = process.argv[2]; + + fs.readFile(path, (err, data) => { + if(err) { + return -1; + } + + exiftool.metadata(data, (err, metadata) => { + if(err) { + return -1; + } + + switch(metadata.fileType) { + case 'AIFF' : + case 'APE' : + case 'FLAC' : + case 'OGG' : + case 'MP3' : + console.log(`${metadata.artist||'Unknown Artist'} - ${metadata.title||'Unknown'} (${metadata.audioBitrate})`); + break; + + case 'PDF' : + console.log(`${metadata.author||'Unknown Author'} - ${metadata.title||'Unknown'}`); + break; + + default : + return -1; + } + + return 0; + }); + }); +} + +return main(); \ No newline at end of file