From ed3ef8c01d733a94647cdd5076574eabebbfb03d Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sun, 21 Mar 2010 03:43:47 +0000 Subject: [PATCH] Fixed call to handbrake, and printout of response Added an ignore on 'lost+found' directories in the Source Lister, since by default only root has access to this dir, which was causing permission denied errors. --- HandBrakeCluster/Rips/Source.class.php | 26 +++++++++++--------- HandBrakeCluster/Rips/SourceLister.class.php | 4 +-- templates/browse/source-details.tpl | 4 +-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/HandBrakeCluster/Rips/Source.class.php b/HandBrakeCluster/Rips/Source.class.php index 2a56e39..7652788 100644 --- a/HandBrakeCluster/Rips/Source.class.php +++ b/HandBrakeCluster/Rips/Source.class.php @@ -15,14 +15,18 @@ class HandBrakeCluster_Rips_Source { $source_shell = escapeshellarg($this->source); $handbrake_cmd = "HandBrakeCLI -i {$source_shell} -t 0"; - $handbrake_pid = popen($handbrake_cmd, 'r'); - $handbrake_output = fread($handbrake_pid, 1024); - while (!feof($handbrake_pid)) { - $handbrake_output = fread($handbrake_pid, 1024); - } - pclose($handbrake_pid); - - + $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 $lines = explode("\n", $handbrake_output); foreach ($lines as $line) { @@ -31,13 +35,13 @@ class HandBrakeCluster_Rips_Source { continue; } - $this->output .= $line; + $this->output .= $line . "\n"; } } public function output() { - return $output; + return $this->output; } }; -?> \ No newline at end of file +?> diff --git a/HandBrakeCluster/Rips/SourceLister.class.php b/HandBrakeCluster/Rips/SourceLister.class.php index e448025..cc9cb86 100644 --- a/HandBrakeCluster/Rips/SourceLister.class.php +++ b/HandBrakeCluster/Rips/SourceLister.class.php @@ -23,7 +23,7 @@ class HandBrakeCluster_Rips_SourceLister { $dir = dir(array_shift($scan_directories)); while (($entry = $dir->read()) !== false) { - if ($entry == '.' || $entry == '..') { + if ($entry == '.' || $entry == '..' || $entry == 'lost+found') { continue; } @@ -53,4 +53,4 @@ class HandBrakeCluster_Rips_SourceLister { }; -?> \ No newline at end of file +?> diff --git a/templates/browse/source-details.tpl b/templates/browse/source-details.tpl index cb9295e..e15c012 100644 --- a/templates/browse/source-details.tpl +++ b/templates/browse/source-details.tpl @@ -16,7 +16,7 @@ Output - {$output|escape:"html"} +
{$output|escape:"html"}
@@ -24,4 +24,4 @@

This is not a valid source.

-{/if} \ No newline at end of file +{/if}