Added Source class to parse HandBrake output

Added a Source class which executes HandBrake -t 0 to list the available titles and streams in a given source.
Added a placeholder on the source-details page to display HandBrake output
This commit is contained in:
2010-03-21 03:21:08 +00:00
parent 5bb99c0f58
commit 3207c28b5c
3 changed files with 56 additions and 6 deletions

View File

@@ -0,0 +1,43 @@
<?php
class HandBrakeCluster_Rips_Source {
protected $source;
protected $output;
public function __construct($source) {
$this->source = $source;
$this->scan();
}
protected function scan() {
$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);
// Process the output
$lines = explode("\n", $handbrake_output);
foreach ($lines as $line) {
// Skip any line that doesn't begin with a + (with optional leading whitespace)
if ( ! preg_match('/\s*\+/', $line)) {
continue;
}
$this->output .= $line;
}
}
public function output() {
return $output;
}
};
?>