Ability to scan single archive (e.g. compressed .pdf) -> extract useful description

This commit is contained in:
Bryan Ashby 2017-05-21 11:45:50 -06:00
parent 019596d709
commit d0e2d41c00
5 changed files with 176 additions and 83 deletions

View file

@ -19,6 +19,11 @@ const FILETYPE_HANDLERS = {};
[ 'PNG', 'JPEG', 'GIF', 'WEBP', 'XCF' ].forEach(ext => FILETYPE_HANDLERS[ext] = imageFile);
function audioFile(metadata) {
// nothing if we don't know at least the author or title
if(!metadata.author && !metadata.title) {
return;
}
let desc = `${metadata.artist||'Unknown Artist'} - ${metadata.title||'Unknown'} (`;
if(metadata.year) {
desc += `${metadata.year}, `;
@ -28,6 +33,11 @@ function audioFile(metadata) {
}
function documentFile(metadata) {
// nothing if we don't know at least the author or title
if(!metadata.author && !metadata.title) {
return;
}
let desc = `${metadata.author||'Unknown Author'} - ${metadata.title||'Unknown'}`;
const created = moment(metadata.createdate);
if(created.isValid()) {
@ -86,7 +96,12 @@ function main() {
return -1;
}
console.info(handler(metadata));
const info = handler(metadata);
if(!info) {
return -1;
}
console.info(info);
return 0;
});
});