PlymouthFury1958
PlymouthFury1958

Reputation: 3

Failed to Parse Error - What's wrong?

This is the line with the "Failed to Parse Error" -> var label = package.getComment() && package.getComment() : 'N/A'

The rest of the code... var script = '/home/paulomacedo/jd2/JD_HOME/jdownloader-postprocess.sh'

var path = package.getDownloadFolder() 
var name = package.getName() 
var label = package.getComment() && package.getComment() : 'N/A' 
var links = package.getDownloadLinks() ? package.getDownloadLinks() : []

function isReallyFinished() {
    for (var i = 0; i < links.length; i++) {
        if (links[i].getArchive() != null && links[i].getExtractionStatus() != "SUCCESSFUL" || !package.isFinished()) {
            return false
        }
    }
    return true
}

if (isReallyFinished()) {
    var command = [script, path, name, label, 'PACKAGE_FINISHED']
    log(command)
    log(callSync(command))
}

Upvotes: 0

Views: 6357

Answers (1)

Andreas Louv
Andreas Louv

Reputation: 47137

The error is here:

var label = package.getComment() && package.getComment() : 'N/A' 
//                                                       ^

You properly want to use a ternary operator:

var label = package.getComment() ? package.getComment() : 'N/A' 

Or a && b || c:

var label = package.getComment() && package.getComment() || 'N/A' 

Upvotes: 1

Related Questions