예제 #1
0
    if (!($id && $php_input)) {
        $err = 'Mash id and data required';
    }
}
if (!$err) {
    // check to make sure JSON data is parsable
    if (!($request = @json_decode($php_input, TRUE))) {
        $err = 'Could not parse JSON payload';
    }
}
if (!$err) {
    // make sure label was set
    $label = $request['label'];
    if (!$label) {
        $err = 'Could not determine mash label';
    }
}
if (!$err) {
    // save mash xml to local file
    $err = data_save_mash($request, auth_userid(), $config);
}
if ($err) {
    $response['error'] = $err;
} else {
    $response['ok'] = 1;
}
$json = json_encode($response);
print $json . "\n\n";
if (!empty($log_responses)) {
    log_file($json, $config);
}
    $id = empty($request['id']) ? '' : $request['id'];
    if (!$id) {
        $err = 'Parameter id required';
    }
}
if (!$err) {
    // grab mash data from input or file
    $uid = auth_userid();
    if (empty($request['label'])) {
        $mash = data_mash($id, $uid, $config);
        if (!$mash) {
            $err = 'Could not find mash ' . $id;
        }
    } else {
        // assume we were sent a complete mash payload requiring saving
        $err = data_save_mash($request, $uid, $config);
        $mash = $request;
    }
}
if (!$err) {
    // post export transcode job
    $result = api_export(array('id' => $id, 'mash' => $mash), array('include_progress' => 1), $config);
    if (!empty($result['error'])) {
        $err = $result['error'];
    } else {
        $response['job'] = $result['id'];
    }
}
if ($err) {
    $response['error'] = $err;
} else {