View Single Post
  #159  
Old 19.08.2017, 07:04
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,545
Default

Quote:
Originally Posted by facecat View Post
... 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)
        }
    }
}
Reply With Quote