Updated DVD Source to use ForegroundTask
DVD Source code was previously using proc_open to manually run HandBrake. This has been replaced using the ForegroundTask class to simplify the code.
This commit is contained in:
@@ -48,7 +48,8 @@ class HandBrakeCluster_Rips_Source {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$config = HandBrakeCluster_Main::instance()->config();
|
$config = HandBrakeCluster_Main::instance()->config();
|
||||||
$real_source_basedir = realpath($config->get('rips.source_dir'));
|
$source_basedir = $config->get('rips.source_dir');
|
||||||
|
$real_source_basedir = realpath($source_basedir);
|
||||||
if (substr($real_source_filename, 0, strlen($real_source_basedir)) != $real_source_basedir) {
|
if (substr($real_source_filename, 0, strlen($real_source_basedir)) != $real_source_basedir) {
|
||||||
throw new HandBrakeCluster_Exception_InvalidSourceDirectory($source_filename);
|
throw new HandBrakeCluster_Exception_InvalidSourceDirectory($source_filename);
|
||||||
}
|
}
|
||||||
@@ -59,21 +60,10 @@ class HandBrakeCluster_Rips_Source {
|
|||||||
protected function scan() {
|
protected function scan() {
|
||||||
$source_shell = escapeshellarg($this->source);
|
$source_shell = escapeshellarg($this->source);
|
||||||
$handbrake_cmd = "HandBrakeCLI -i {$source_shell} -t 0";
|
$handbrake_cmd = "HandBrakeCLI -i {$source_shell} -t 0";
|
||||||
|
list($retval, $handbrake_output, $handbrake_error) = HandBrakeCluster_ForegroundTask::execute($handbrake_cmd);
|
||||||
$handbrake_pid = proc_open($handbrake_cmd, array(
|
|
||||||
0 => array("pipe", "r"),
|
|
||||||
1 => array("pipe", "w"),
|
|
||||||
2 => array("pipe", "w")
|
|
||||||
), $pipes);
|
|
||||||
|
|
||||||
$handbrake_output = stream_get_contents($pipes[2]);
|
|
||||||
fclose($pipes[0]);
|
|
||||||
fclose($pipes[1]);
|
|
||||||
fclose($pipes[2]);
|
|
||||||
proc_close($handbrake_pid);
|
|
||||||
|
|
||||||
// Process the output
|
// Process the output
|
||||||
$lines = explode("\n", $handbrake_output);
|
$lines = explode("\n", $handbrake_error);
|
||||||
$title = null;
|
$title = null;
|
||||||
$mode = self::PM_TITLE;
|
$mode = self::PM_TITLE;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user