Last active
June 13, 2018 08:13
-
-
Save KonradIT/6610ef17417ce51d6c6e3df11bea935e to your computer and use it in GitHub Desktop.
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
var fs = require('fs'); | |
var walkPath = './'; | |
var GoProTagger = require('./gopro-tagging'); | |
var walk = function (dir, done) { | |
fs.readdir(dir, function (error, list) { | |
if (error) { | |
return done(error); | |
} | |
var i = 0; | |
(function next () { | |
var file = list[i++]; | |
if (!file) { | |
return done(null); | |
} | |
file = dir + '/' + file; | |
fs.stat(file, function (error, stat) { | |
if (stat && stat.isDirectory()) { | |
walk(file, function (error) { | |
next(); | |
}); | |
} else { | |
if(file.endsWith("MP4")){ | |
GoProTagger.getTag(file, function(hilights, err){ | |
if(hilights.length>0){ | |
console.log("Reading file: ") | |
console.log(file); | |
console.log('This video has ' + hilights.length + ' HiLight tag(s)'); | |
for(var i = 0;i < hilights.length;i++) { | |
console.log('HiLight ' + i + ' @ ' + hilights[i] + ' millisecond'); | |
} | |
fs.rename(file, "tagged-"+file.replace(".//",""), function(err) { | |
if ( err ) console.log('ERROR: ' + err); | |
}); | |
} | |
}); | |
} | |
next(); | |
} | |
}); | |
})(); | |
}); | |
}; | |
process.argv.forEach(function (val, index, array) { | |
if (val.indexOf('source') !== -1) { | |
walkPath = val.split('=')[1]; | |
} | |
}); | |
console.log('processing...'); | |
walk(walkPath, function(error) { | |
if (error) { | |
throw error; | |
} else { | |
console.log('finished.'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment