Quote:
Originally Posted by facecat
... get the duration of a file and move it into a specific folder ...
|
Code:
// Move media files based on duration
// Trigger: "A Download Stopped"
if (link.isFinished()) {
var file = getPath(link.getDownloadPath());
var fileTypes = ["mkv", "mp4", "avi", "mp3", "m4a", "ogg", "opus"]; // <- Set media file types
if (fileTypes.indexOf(file.getExtension()) > -1) {
var cutoff = 60; // <- Set cutoff duration (in minutes)
var big = "c:/downloads/big"; // <- Set folder
var small = "c:/downloads/small"; // <- Set folder
var ffprobe = "c:/apps/ffmpeg/bin/ffprobe.exe"; // <- Set path to ffprobe (Can also use the binary found in 'JD\tools' folder)
var duration = JSON.parse(callSync(ffprobe, "-v", "-8", "-show_entries", "format", "-of", "json", file)).format.duration;
if (duration < cutoff * 60) {
file.moveTo(small);
} else {
file.moveTo(big)
}
}
}