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.
This commit is contained in:
2010-03-21 03:43:47 +00:00
parent 3207c28b5c
commit ed3ef8c01d
3 changed files with 19 additions and 15 deletions

View File

@@ -15,14 +15,18 @@ class HandBrakeCluster_Rips_Source {
$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";
$handbrake_pid = popen($handbrake_cmd, 'r'); $handbrake_pid = proc_open($handbrake_cmd, array(
$handbrake_output = fread($handbrake_pid, 1024); 0 => array("pipe", "r"),
while (!feof($handbrake_pid)) { 1 => array("pipe", "w"),
$handbrake_output = fread($handbrake_pid, 1024); 2 => array("pipe", "w")
} ), $pipes);
pclose($handbrake_pid);
$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_output);
foreach ($lines as $line) { foreach ($lines as $line) {
@@ -31,13 +35,13 @@ class HandBrakeCluster_Rips_Source {
continue; continue;
} }
$this->output .= $line; $this->output .= $line . "\n";
} }
} }
public function output() { public function output() {
return $output; return $this->output;
} }
}; };
?> ?>

View File

@@ -23,7 +23,7 @@ class HandBrakeCluster_Rips_SourceLister {
$dir = dir(array_shift($scan_directories)); $dir = dir(array_shift($scan_directories));
while (($entry = $dir->read()) !== false) { while (($entry = $dir->read()) !== false) {
if ($entry == '.' || $entry == '..') { if ($entry == '.' || $entry == '..' || $entry == 'lost+found') {
continue; continue;
} }
@@ -53,4 +53,4 @@ class HandBrakeCluster_Rips_SourceLister {
}; };
?> ?>

View File

@@ -16,7 +16,7 @@
</tr> </tr>
<tr> <tr>
<th>Output</th> <th>Output</th>
<td>{$output|escape:"html"}</td> <td><pre>{$output|escape:"html"}</pre></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -24,4 +24,4 @@
<p> <p>
<em>This is not a valid source.</em> <em>This is not a valid source.</em>
</p> </p>
{/if} {/if}