Very very basic start of a exiftool wrapper for description exctraction

This commit is contained in:
Bryan Ashby 2017-05-13 20:59:20 -06:00
parent a1e51c41ee
commit 0b9ca4d565
1 changed files with 47 additions and 0 deletions

47
util/exiftool2desc.js Executable file
View File

@ -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();