Renamed the codebase to RippingCluster
Since the new design is engine agnostic, removed HandBrake from the class names.
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_ClientLogEntry extends HandBrakeCluster_LogEntry {
|
||||
|
||||
public static function initialise() {
|
||||
parent::$table_name = 'client_log';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
HandBrakeCluster_ClientLogEntry::initialise();
|
||||
|
||||
?>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Exception extends Exception {};
|
||||
|
||||
class HandBrakeCluster_Exception_DatabaseException extends HandBrakeCluster_Exception {};
|
||||
class HandBrakeCluster_Exception_DatabaseConfigMissing extends HandBrakeCluster_Exception_DatabaseException {};
|
||||
class HandBrakeCluster_Exception_DatabaseConnectFailed extends HandBrakeCluster_Exception_DatabaseException {};
|
||||
class HandBrakeCluster_Exception_NoDatabaseConnection extends HandBrakeCluster_Exception_DatabaseException {};
|
||||
class HandBrakeCluster_Exception_DatabaseQueryFailed extends HandBrakeCluster_Exception_DatabaseException {};
|
||||
class HandBrakeCluster_Exception_ResultCountMismatch extends HandBrakeCluster_Exception_DatabaseException {};
|
||||
|
||||
class HandBrakeCluster_Exception_ConfigException extends HandBrakeCluster_Exception {};
|
||||
class HandBrakeCluster_Exception_UnknownSetting extends HandBrakeCluster_Exception_ConfigException {};
|
||||
|
||||
class HandBrakeCluster_Exception_TemplateException extends HandBrakeCluster_Exception {};
|
||||
class HandBrakeCluster_Exception_AbortEntirePage extends HandBrakeCluster_Exception_TemplateException {};
|
||||
class HandBrakeCluster_Exception_Unauthorized extends HandBrakeCluster_Exception_TemplateException {};
|
||||
class HandBrakeCluster_Exception_FileNotFound extends HandBrakeCluster_Exception_TemplateException {};
|
||||
class HandBrakeCluster_Exception_InvalidParameters extends HandBrakeCluster_Exception_TemplateException {};
|
||||
|
||||
class HandBrakeCluster_Exception_InvalidSourceDirectory extends HandBrakeCluster_Exception {};
|
||||
|
||||
class HandBrakeCluster_Exception_CacheException extends HandBrakeCluster_Exception {};
|
||||
class HandBrakeCluster_Exception_InvalidCacheDir extends HandBrakeCluster_Exception_CacheException {};
|
||||
class HandBrakeCluster_Exception_CacheObjectNotFound extends HandBrakeCluster_Exception_CacheException {};
|
||||
|
||||
class HandBrakeCluster_Exception_LogicException extends HandBrakeCluster_Exception {};
|
||||
class HandBrakeCluster_Exception_JobNotRunning extends HandBrakeCluster_Exception_LogicException {};
|
||||
|
||||
?>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_WorkerLogEntry extends HandBrakeCluster_LogEntry {
|
||||
|
||||
public static function initialise() {
|
||||
parent::$table_name = 'worker_log';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
HandBrakeCluster_WorkerLogEntry::initialise();
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_BackgroundTask {
|
||||
class RippingCluster_BackgroundTask {
|
||||
|
||||
protected function __construct() {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Cache {
|
||||
class RippingCluster_Cache {
|
||||
|
||||
protected $config;
|
||||
protected $cache_dir;
|
||||
|
||||
public function __construct(HandBrakeCluster_Config $config) {
|
||||
public function __construct(RippingCluster_Config $config) {
|
||||
$this->config = $config;
|
||||
$this->cache_dir = $config->get('cache.base_dir');
|
||||
|
||||
if (is_dir($this->cache_dir)) {
|
||||
if ( ! is_writeable($this->cache_dir)) {
|
||||
throw new HandBrakeCluster_Exception_InvalidCacheDir();
|
||||
throw new RippingCluster_Exception_InvalidCacheDir();
|
||||
}
|
||||
} else {
|
||||
if ( ! HandBrakeCluster_Main::mkdir_recursive($this->cache_dir)) {
|
||||
throw new HandBrakeCluster_Exception_InvalidCacheDir();
|
||||
if ( ! RippingCluster_Main::mkdir_recursive($this->cache_dir)) {
|
||||
throw new RippingCluster_Exception_InvalidCacheDir();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class HandBrakeCluster_Cache {
|
||||
$cache_filename = $this->cacheFilename($source_filename);
|
||||
|
||||
if (!$this->exists($source_filename)) {
|
||||
throw new HandBrakeCluster_Exception_CacheObjectNotFound($source_filename);
|
||||
throw new RippingCluster_Exception_CacheObjectNotFound($source_filename);
|
||||
}
|
||||
|
||||
return file_get_contents($cache_filename);
|
||||
13
lib/RippingCluster/ClientLogEntry.class.php
Normal file
13
lib/RippingCluster/ClientLogEntry.class.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class RippingCluster_ClientLogEntry extends RippingCluster_LogEntry {
|
||||
|
||||
public static function initialise() {
|
||||
parent::$table_name = 'client_log';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
RippingCluster_ClientLogEntry::initialise();
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Config {
|
||||
class RippingCluster_Config {
|
||||
|
||||
private $dbconfig;
|
||||
private $database;
|
||||
@@ -20,20 +20,20 @@ class HandBrakeCluster_Config {
|
||||
|
||||
public function getDatabase($key) {
|
||||
if (!isset($this->databaseConfig[$key])) {
|
||||
throw new HandBrakeCluster_Exception_DatabaseConfigMissing($key);
|
||||
throw new RippingCluster_Exception_DatabaseConfigMissing($key);
|
||||
}
|
||||
|
||||
return $this->databaseConfig[$key];
|
||||
}
|
||||
|
||||
public function setDatabase(HandBrakeCluster_Database $database) {
|
||||
public function setDatabase(RippingCluster_Database $database) {
|
||||
$this->database = $database;
|
||||
$this->preload();
|
||||
}
|
||||
|
||||
public function preload() {
|
||||
if (!$this->database) {
|
||||
throw new HandBrakeCluster_Exception_NoDatabaseConnection();
|
||||
throw new RippingCluster_Exception_NoDatabaseConnection();
|
||||
}
|
||||
|
||||
$this->settings = $this->database->selectAssoc('SELECT name,value FROM settings', 'name', 'value');
|
||||
@@ -45,7 +45,7 @@ class HandBrakeCluster_Config {
|
||||
|
||||
public function get($key) {
|
||||
if (!isset($this->settings[$key])) {
|
||||
throw new HandBrakeCluster_Exception_UnknownSetting($key);
|
||||
throw new RippingCluster_Exception_UnknownSetting($key);
|
||||
}
|
||||
|
||||
return $this->settings[$key];
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Database {
|
||||
class RippingCluster_Database {
|
||||
|
||||
private $config;
|
||||
private $dbh;
|
||||
@@ -12,7 +12,7 @@ class HandBrakeCluster_Database {
|
||||
|
||||
private $prepared_statements = array();
|
||||
|
||||
public function __construct(HandBrakeCluster_Config $config) {
|
||||
public function __construct(RippingCluster_Config $config) {
|
||||
$this->config = $config;
|
||||
|
||||
$this->hostname = $this->config->getDatabase('hostname');
|
||||
@@ -23,7 +23,7 @@ class HandBrakeCluster_Database {
|
||||
try {
|
||||
$this->dbh = new PDO("mysql:host={$this->hostname};dbname={$this->dbname}", $this->username, $this->password);
|
||||
} catch (PDOException $e) {
|
||||
throw new HandBrakeCluster_Exception_DatabaseConnectionFailed($e->getMessage());
|
||||
throw new RippingCluster_Exception_DatabaseConnectionFailed($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class HandBrakeCluster_Database {
|
||||
$result = $stmt->execute();
|
||||
if (!$result) {
|
||||
list($code, $dummy, $message) = $stmt->errorInfo();
|
||||
throw new HandBrakeCluster_Exception_DatabaseQueryFailed($message, $code);
|
||||
throw new RippingCluster_Exception_DatabaseQueryFailed($message, $code);
|
||||
}
|
||||
|
||||
return $stmt->fetchAll();
|
||||
@@ -73,7 +73,7 @@ class HandBrakeCluster_Database {
|
||||
public function selectOne($sql, $bind_params = null) {
|
||||
$rows = $this->selectList($sql, $bind_params);
|
||||
if (count($rows) != 1) {
|
||||
throw new HandBrakeCluster_Exception_ResultCountMismatch(count($rows));
|
||||
throw new RippingCluster_Exception_ResultCountMismatch(count($rows));
|
||||
}
|
||||
|
||||
return $rows[0];
|
||||
@@ -95,7 +95,7 @@ class HandBrakeCluster_Database {
|
||||
$result = $stmt->execute();
|
||||
if (!$result) {
|
||||
list($code, $dummy, $message) = $stmt->errorInfo();
|
||||
throw new HandBrakeCluster_Exception_DatabaseQueryFailed($message, $code);
|
||||
throw new RippingCluster_Exception_DatabaseQueryFailed($message, $code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class HandBrakeCluster_Database {
|
||||
$result = $stmt->execute();
|
||||
if (!$result) {
|
||||
list($code, $dummy, $message) = $stmt->errorInfo();
|
||||
throw new HandBrakeCluster_Exception_DatabaseQueryFailed($message, $code);
|
||||
throw new RippingCluster_Exception_DatabaseQueryFailed($message, $code);
|
||||
}
|
||||
}
|
||||
|
||||
30
lib/RippingCluster/Exceptions.class.php
Normal file
30
lib/RippingCluster/Exceptions.class.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
class RippingCluster_Exception extends Exception {};
|
||||
|
||||
class RippingCluster_Exception_DatabaseException extends RippingCluster_Exception {};
|
||||
class RippingCluster_Exception_DatabaseConfigMissing extends RippingCluster_Exception_DatabaseException {};
|
||||
class RippingCluster_Exception_DatabaseConnectFailed extends RippingCluster_Exception_DatabaseException {};
|
||||
class RippingCluster_Exception_NoDatabaseConnection extends RippingCluster_Exception_DatabaseException {};
|
||||
class RippingCluster_Exception_DatabaseQueryFailed extends RippingCluster_Exception_DatabaseException {};
|
||||
class RippingCluster_Exception_ResultCountMismatch extends RippingCluster_Exception_DatabaseException {};
|
||||
|
||||
class RippingCluster_Exception_ConfigException extends RippingCluster_Exception {};
|
||||
class RippingCluster_Exception_UnknownSetting extends RippingCluster_Exception_ConfigException {};
|
||||
|
||||
class RippingCluster_Exception_TemplateException extends RippingCluster_Exception {};
|
||||
class RippingCluster_Exception_AbortEntirePage extends RippingCluster_Exception_TemplateException {};
|
||||
class RippingCluster_Exception_Unauthorized extends RippingCluster_Exception_TemplateException {};
|
||||
class RippingCluster_Exception_FileNotFound extends RippingCluster_Exception_TemplateException {};
|
||||
class RippingCluster_Exception_InvalidParameters extends RippingCluster_Exception_TemplateException {};
|
||||
|
||||
class RippingCluster_Exception_InvalidSourceDirectory extends RippingCluster_Exception {};
|
||||
|
||||
class RippingCluster_Exception_CacheException extends RippingCluster_Exception {};
|
||||
class RippingCluster_Exception_InvalidCacheDir extends RippingCluster_Exception_CacheException {};
|
||||
class RippingCluster_Exception_CacheObjectNotFound extends RippingCluster_Exception_CacheException {};
|
||||
|
||||
class RippingCluster_Exception_LogicException extends RippingCluster_Exception {};
|
||||
class RippingCluster_Exception_JobNotRunning extends RippingCluster_Exception_LogicException {};
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_ForegroundTask {
|
||||
class RippingCluster_ForegroundTask {
|
||||
|
||||
const PIPE_STDIN = 0;
|
||||
const PIPE_STDOUT = 1;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Job {
|
||||
class RippingCluster_Job {
|
||||
|
||||
protected $source;
|
||||
|
||||
@@ -51,8 +51,8 @@ class HandBrakeCluster_Job {
|
||||
}
|
||||
|
||||
public static function fromDatabaseRow($row) {
|
||||
return new HandBrakeCluster_Job(
|
||||
HandBrakeCluster_Rips_Source::load($row['source'], false),
|
||||
return new RippingCluster_Job(
|
||||
RippingCluster_Rips_Source::load($row['source'], false),
|
||||
$row['id'],
|
||||
$row['name'],
|
||||
$row['source'],
|
||||
@@ -76,16 +76,16 @@ class HandBrakeCluster_Job {
|
||||
* @todo Implement cache of previously loaded jobs
|
||||
*
|
||||
* @param int $id
|
||||
* @return HandBrakeCluster_Job
|
||||
* @return RippingCluster_Job
|
||||
*/
|
||||
public static function fromId($id) {
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
|
||||
if (isset(self::$cache[$id])) {
|
||||
return self::$cache[$id];
|
||||
}
|
||||
|
||||
$job = HandBrakeCluster_Job::fromDatabaseRow(
|
||||
$job = RippingCluster_Job::fromDatabaseRow(
|
||||
$database->selectOne('SELECT * FROM jobs WHERE id=:id', array(
|
||||
array('name' => 'id', 'value' => $id, 'type' => PDO::PARAM_INT)
|
||||
)
|
||||
@@ -100,7 +100,7 @@ class HandBrakeCluster_Job {
|
||||
public static function all() {
|
||||
$jobs = array();
|
||||
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
foreach ($database->selectList('SELECT * FROM jobs WHERE id > 0') as $row) {
|
||||
$job = self::fromDatabaseRow($row);
|
||||
|
||||
@@ -113,7 +113,7 @@ class HandBrakeCluster_Job {
|
||||
|
||||
public static function allWithStatus($status, $limit = null) {
|
||||
$jobs = array();
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
|
||||
$params = array(
|
||||
array('name' => 'status', 'value' => $status, 'type' => PDO::PARAM_INT),
|
||||
@@ -133,17 +133,17 @@ class HandBrakeCluster_Job {
|
||||
}
|
||||
|
||||
public static function fromPostRequest($source_id, $global_options, $titles) {
|
||||
$source = HandBrakeCluster_Rips_Source::loadEncoded(HandBrakeCluster_Main::issetelse($source_id, HandBrakeCluster_Exception_InvalidParameters));
|
||||
$source = RippingCluster_Rips_Source::loadEncoded(RippingCluster_Main::issetelse($source_id, RippingCluster_Exception_InvalidParameters));
|
||||
|
||||
$jobs = array();
|
||||
foreach ($titles as $title => $details) {
|
||||
if (HandBrakeCluster_Main::issetelse($details['queue'])) {
|
||||
HandBrakeCluster_Main::issetelse($details['output_filename'], HandBrakeCluster_Exception_InvalidParameters);
|
||||
if (RippingCluster_Main::issetelse($details['queue'])) {
|
||||
RippingCluster_Main::issetelse($details['output_filename'], RippingCluster_Exception_InvalidParameters);
|
||||
|
||||
$job = new HandBrakeCluster_Job(
|
||||
$job = new RippingCluster_Job(
|
||||
$source,
|
||||
null,
|
||||
HandBrakeCluster_Main::issetelse($details['name'], 'unnamed job'),
|
||||
RippingCluster_Main::issetelse($details['name'], 'unnamed job'),
|
||||
$source->filename(),
|
||||
$global_options['output-directory'] . DIRECTORY_SEPARATOR . $details['output_filename'],
|
||||
$title,
|
||||
@@ -152,11 +152,11 @@ class HandBrakeCluster_Job {
|
||||
$global_options['video-width'],
|
||||
$global_options['video-height'],
|
||||
$global_options['quantizer'],
|
||||
HandBrakeCluster_Main::issetelse($details['deinterlace'], 2),
|
||||
implode(',', HandBrakeCluster_Main::issetelse($details['audio'], array())),
|
||||
RippingCluster_Main::issetelse($details['deinterlace'], 2),
|
||||
implode(',', RippingCluster_Main::issetelse($details['audio'], array())),
|
||||
implode(',', array_pad(array(), count($details['audio']), 'ac3')), // @todo Make this configurable
|
||||
implode(',', array_pad(array(), count($details['audio']), 'Unknown')), // @todo Make this configurable
|
||||
implode(',', HandBrakeCluster_Main::issetelse($details['subtitles'], array()))
|
||||
implode(',', RippingCluster_Main::issetelse($details['subtitles'], array()))
|
||||
);
|
||||
$job->create();
|
||||
|
||||
@@ -168,7 +168,7 @@ class HandBrakeCluster_Job {
|
||||
}
|
||||
|
||||
protected function create() {
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
$database->insert(
|
||||
'INSERT INTO jobs
|
||||
(id,name,source,destination,title,format,video_codec,video_width,video_height,quantizer,deinterlace,audio_tracks,audio_codecs,audio_names,subtitle_tracks)
|
||||
@@ -192,11 +192,11 @@ class HandBrakeCluster_Job {
|
||||
);
|
||||
|
||||
$this->id = $database->lastInsertId();
|
||||
$status = HandBrakeCluster_JobStatus::updateStatusForJob($this, HandBrakeCluster_JobStatus::CREATED);
|
||||
$status = RippingCluster_JobStatus::updateStatusForJob($this, RippingCluster_JobStatus::CREATED);
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
$database->update(
|
||||
'DELETE FROM jobs WHERE id=:job_id LIMIT 1',
|
||||
array(
|
||||
@@ -208,7 +208,7 @@ class HandBrakeCluster_Job {
|
||||
}
|
||||
|
||||
public function queue($gearman) {
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$main = RippingCluster_Main::instance();
|
||||
$config = $main->config();
|
||||
$log = $main->log();
|
||||
$log->info('Starting job', $this->id);
|
||||
@@ -235,22 +235,22 @@ class HandBrakeCluster_Job {
|
||||
$task = $gearman->addTask('handbrake_rip', serialize($rip_options), $config->get('rips.context'), $this->id);
|
||||
if ($task) {
|
||||
$log->debug("Queued job", $this->id);
|
||||
$this->updateStatus(HandBrakeCluster_JobStatus::QUEUED);
|
||||
$this->updateStatus(RippingCluster_JobStatus::QUEUED);
|
||||
} else {
|
||||
$log->warning("Failed to queue job", $this->id);
|
||||
$this->updateStatus(HandBrakeCluster_JobStatus::FAILED);
|
||||
$this->updateStatus(RippingCluster_JobStatus::FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadStatuses() {
|
||||
if ($this->statuses == null) {
|
||||
$this->statuses = HandBrakeCluster_JobStatus::allForJob($this);
|
||||
$this->statuses = RippingCluster_JobStatus::allForJob($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HandBrakeCluster_JobStatus
|
||||
* @return RippingCluster_JobStatus
|
||||
*/
|
||||
public function currentStatus() {
|
||||
$this->loadStatuses();
|
||||
@@ -258,13 +258,13 @@ class HandBrakeCluster_Job {
|
||||
}
|
||||
|
||||
public function updateStatus($new_status, $rip_progress = null) {
|
||||
return HandBrakeCluster_JobStatus::updateStatusForJob($this, $new_status, $rip_progress);
|
||||
return RippingCluster_JobStatus::updateStatusForJob($this, $new_status, $rip_progress);
|
||||
}
|
||||
|
||||
public function calculateETA() {
|
||||
$current_status = $this->currentStatus();
|
||||
if ($current_status->status() != HandBrakeCluster_JobStatus::RUNNING) {
|
||||
throw new HandBrakeCluster_Exception_JobNotRunning();
|
||||
if ($current_status->status() != RippingCluster_JobStatus::RUNNING) {
|
||||
throw new RippingCluster_Exception_JobNotRunning();
|
||||
}
|
||||
|
||||
$running_time = $current_status->mtime() - $current_status->ctime();
|
||||
@@ -298,7 +298,7 @@ class HandBrakeCluster_Job {
|
||||
}
|
||||
|
||||
public static function runAllJobs() {
|
||||
HandBrakeCluster_BackgroundTask::run('/usr/bin/php run-jobs.php');
|
||||
RippingCluster_BackgroundTask::run('/usr/bin/php run-jobs.php');
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_JobStatus {
|
||||
class RippingCluster_JobStatus {
|
||||
|
||||
const CREATED = 0;
|
||||
const QUEUED = 1;
|
||||
@@ -33,7 +33,7 @@ class HandBrakeCluster_JobStatus {
|
||||
}
|
||||
|
||||
public static function fromDatabaseRow($row) {
|
||||
return new HandBrakeCluster_JobStatus(
|
||||
return new RippingCluster_JobStatus(
|
||||
$row['id'],
|
||||
$row['job_id'],
|
||||
$row['status'],
|
||||
@@ -45,7 +45,7 @@ class HandBrakeCluster_JobStatus {
|
||||
|
||||
public static function updateStatusForJob($job, $status, $rip_progress = null) {
|
||||
$ctime = $mtime = time();
|
||||
$status = new HandBrakeCluster_JobStatus(null, $job->id(), $status, $ctime, $mtime, $rip_progress);
|
||||
$status = new RippingCluster_JobStatus(null, $job->id(), $status, $ctime, $mtime, $rip_progress);
|
||||
$status->create();
|
||||
|
||||
return $status;
|
||||
@@ -57,21 +57,21 @@ class HandBrakeCluster_JobStatus {
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public static function allForJob(HandBrakeCluster_Job $job) {
|
||||
public static function allForJob(RippingCluster_Job $job) {
|
||||
$statuses = array();
|
||||
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
foreach ($database->selectList('SELECT * FROM job_status WHERE job_id=:job_id ORDER BY mtime ASC', array(
|
||||
array('name' => 'job_id', 'value' => $job->id(), 'type' => PDO::PARAM_INT),
|
||||
)) as $row) {
|
||||
$statuses[] = HandBrakeCluster_JobStatus::fromDatabaseRow($row);
|
||||
$statuses[] = RippingCluster_JobStatus::fromDatabaseRow($row);
|
||||
}
|
||||
|
||||
return $statuses;
|
||||
}
|
||||
|
||||
protected function create() {
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
$database->insert(
|
||||
'INSERT INTO job_status
|
||||
(id, job_id, status, ctime, mtime, rip_progress)
|
||||
@@ -89,7 +89,7 @@ class HandBrakeCluster_JobStatus {
|
||||
}
|
||||
|
||||
public function save() {
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
$database->update(
|
||||
'UPDATE job_status SET
|
||||
job_id=:job_id, status=:status, ctime=:ctime, mtime=:mtime, rip_progress=:rip_progress
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Log {
|
||||
class RippingCluster_Log {
|
||||
|
||||
private static $hostname = '';
|
||||
|
||||
@@ -8,7 +8,7 @@ class HandBrakeCluster_Log {
|
||||
private $config;
|
||||
private $table;
|
||||
|
||||
public function __construct(HandBrakeCluster_Database $database, HandBrakeCluster_Config $config, $table) {
|
||||
public function __construct(RippingCluster_Database $database, RippingCluster_Config $config, $table) {
|
||||
$this->database = $database;
|
||||
$this->config = $config;
|
||||
$this->table = $table;
|
||||
@@ -56,6 +56,6 @@ class HandBrakeCluster_Log {
|
||||
|
||||
}
|
||||
|
||||
HandBrakeCluster_Log::initialise();
|
||||
RippingCluster_Log::initialise();
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
abstract class HandBrakeCluster_LogEntry {
|
||||
abstract class RippingCluster_LogEntry {
|
||||
|
||||
protected static $table_name = "";
|
||||
|
||||
@@ -27,7 +27,7 @@ abstract class HandBrakeCluster_LogEntry {
|
||||
}
|
||||
|
||||
public static function fromDatabaseRow($row) {
|
||||
return new HandBrakeCluster_ClientLogEntry(
|
||||
return new RippingCluster_ClientLogEntry(
|
||||
$row['id'],
|
||||
$row['job_id'],
|
||||
$row['level'],
|
||||
@@ -41,8 +41,8 @@ abstract class HandBrakeCluster_LogEntry {
|
||||
}
|
||||
|
||||
public static function fromId($id) {
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
return HandBrakeCluster_ClientLogEntry::fromDatabaseRow(
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
return RippingCluster_ClientLogEntry::fromDatabaseRow(
|
||||
$database->selectOne('SELECT * FROM '.self::$table_name.' WHERE id=:id', array(
|
||||
array('name' => 'id', 'value' => $id, 'type' => PDO::PARAM_INT)
|
||||
)
|
||||
@@ -53,7 +53,7 @@ abstract class HandBrakeCluster_LogEntry {
|
||||
public static function recent($limit = 100) {
|
||||
$entries = array();
|
||||
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
foreach ($database->selectList('SELECT * FROM '.self::$table_name.' ORDER BY ctime DESC LIMIT :limit', array(
|
||||
array('name' => 'limit', 'value' => $limit, 'type' => PDO::PARAM_INT)
|
||||
)) as $row) {
|
||||
@@ -66,7 +66,7 @@ abstract class HandBrakeCluster_LogEntry {
|
||||
public static function recentForJob($job_id, $limit = 100) {
|
||||
$entries = array();
|
||||
|
||||
$database = HandBrakeCluster_Main::instance()->database();
|
||||
$database = RippingCluster_Main::instance()->database();
|
||||
foreach ($database->selectList('SELECT * FROM '.self::$table_name.' WHERE job_id=:job_id ORDER BY ctime DESC LIMIT :limit', array(
|
||||
array('name' => 'job_id', 'value' => $job_id, 'type' => PDO::PARAM_INT),
|
||||
array('name' => 'limit', 'value' => $limit, 'type' => PDO::PARAM_INT)
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'smarty/Smarty.class.php';
|
||||
|
||||
class HandBrakeCluster_Main {
|
||||
class RippingCluster_Main {
|
||||
|
||||
private static $instance;
|
||||
|
||||
@@ -30,13 +30,13 @@ class HandBrakeCluster_Main {
|
||||
}
|
||||
}
|
||||
|
||||
$this->config = new HandBrakeCluster_Config(HandBrakeCluster_DBConfig);
|
||||
$this->database = new HandBrakeCluster_Database($this->config);
|
||||
$this->config = new RippingCluster_Config(RippingCluster_DBConfig);
|
||||
$this->database = new RippingCluster_Database($this->config);
|
||||
$this->config->setDatabase($this->database);
|
||||
|
||||
$this->log = new HandBrakeCluster_Log($this->database, $this->config, $log_table);
|
||||
$this->request = new HandBrakeCluster_RequestParser($request_string);
|
||||
$this->cache = new HandBrakeCluster_Cache($this->config);
|
||||
$this->log = new RippingCluster_Log($this->database, $this->config, $log_table);
|
||||
$this->request = new RippingCluster_RequestParser($request_string);
|
||||
$this->cache = new RippingCluster_Cache($this->config);
|
||||
|
||||
$this->smarty = new Smarty();
|
||||
$this->smarty->template_dir = './templates';
|
||||
@@ -44,7 +44,7 @@ class HandBrakeCluster_Main {
|
||||
$this->smarty->cache_dir = './tmp/cache';
|
||||
$this->smarty->config_fir = './config';
|
||||
|
||||
$this->smarty->register_modifier('formatDuration', array('HandBrakeCluster_Main', 'formatDuration'));
|
||||
$this->smarty->register_modifier('formatDuration', array('RippingCluster_Main', 'formatDuration'));
|
||||
|
||||
$this->smarty->assign('version', '0.1');
|
||||
|
||||
@@ -55,11 +55,11 @@ class HandBrakeCluster_Main {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HandBrakeCluster_Main
|
||||
* @return RippingCluster_Main
|
||||
*/
|
||||
public static function instance() {
|
||||
if (!self::$instance) {
|
||||
self::$instance = new HandBrakeCluster_Main();
|
||||
self::$instance = new RippingCluster_Main();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
@@ -71,7 +71,7 @@ class HandBrakeCluster_Main {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HandBrakeCluster_Config
|
||||
* @return RippingCluster_Config
|
||||
*/
|
||||
public function config() {
|
||||
return $this->config;
|
||||
@@ -79,7 +79,7 @@ class HandBrakeCluster_Main {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HandBrakeCluster_Database
|
||||
* @return RippingCluster_Database
|
||||
*/
|
||||
public function database() {
|
||||
return $this->database;
|
||||
@@ -87,7 +87,7 @@ class HandBrakeCluster_Main {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HandBrakeCluster_Log
|
||||
* @return RippingCluster_Log
|
||||
*/
|
||||
public function log() {
|
||||
return $this->log;
|
||||
@@ -95,7 +95,7 @@ class HandBrakeCluster_Main {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HandBrakeCluster_RequestParser
|
||||
* @return RippingCluster_RequestParser
|
||||
*/
|
||||
public function request() {
|
||||
return $this->request;
|
||||
@@ -103,7 +103,7 @@ class HandBrakeCluster_Main {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HandBrakeCluster_Cache
|
||||
* @return RippingCluster_Cache
|
||||
*/
|
||||
public function cache() {
|
||||
return $this->cache;
|
||||
@@ -122,7 +122,7 @@ class HandBrakeCluster_Main {
|
||||
}
|
||||
|
||||
public static function initialise() {
|
||||
spl_autoload_register(array('HandBrakeCluster_Main','autoload'));
|
||||
spl_autoload_register(array('RippingCluster_Main','autoload'));
|
||||
}
|
||||
|
||||
public static function autoload($classname) {
|
||||
@@ -132,18 +132,18 @@ class HandBrakeCluster_Main {
|
||||
}
|
||||
|
||||
// Ensure the class to load begins with our prefix
|
||||
if (!preg_match('/^HandBrakeCluster_/', $classname)) {
|
||||
if (!preg_match('/^RippingCluster_/', $classname)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Special case: All exceptions are stored in the same file
|
||||
if (preg_match('/^HandBrakeCluster_Exception/', $classname)) {
|
||||
require_once(HandBrakeCluster_Lib . 'HandBrakeCluster/Exceptions.class.php');
|
||||
if (preg_match('/^RippingCluster_Exception/', $classname)) {
|
||||
require_once(RippingCluster_Lib . 'RippingCluster/Exceptions.class.php');
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace any underscores with directory separators
|
||||
$filename = HandBrakeCluster_Lib . preg_replace('/_/', '/', $classname);
|
||||
$filename = RippingCluster_Lib . preg_replace('/_/', '/', $classname);
|
||||
|
||||
// Tack on the class file suffix
|
||||
$filename .= '.class.php';
|
||||
@@ -174,7 +174,7 @@ class HandBrakeCluster_Main {
|
||||
return $var;
|
||||
}
|
||||
|
||||
if (is_string($default) && preg_match('/^HandBrakeCluster_Exception/', $default) && class_exists($default) && is_subclass_of($default, HandBrakeCluster_Exception)) {
|
||||
if (is_string($default) && preg_match('/^RippingCluster_Exception/', $default) && class_exists($default) && is_subclass_of($default, RippingCluster_Exception)) {
|
||||
throw new $default();
|
||||
}
|
||||
|
||||
@@ -210,6 +210,6 @@ class HandBrakeCluster_Main {
|
||||
|
||||
}
|
||||
|
||||
HandBrakeCluster_Main::initialise();
|
||||
RippingCluster_Main::initialise();
|
||||
|
||||
?>
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Page {
|
||||
class RippingCluster_Page {
|
||||
|
||||
private $smarty;
|
||||
private $request;
|
||||
|
||||
private $page;
|
||||
|
||||
public function __construct(Smarty $smarty, HandBrakeCluster_RequestParser $request) {
|
||||
public function __construct(Smarty $smarty, RippingCluster_RequestParser $request) {
|
||||
$this->smarty = $smarty;
|
||||
$this->request = $request;
|
||||
$this->page = $request->page();
|
||||
@@ -27,11 +27,11 @@ class HandBrakeCluster_Page {
|
||||
|
||||
try {
|
||||
$this->render($template_filename, $code_filename, $template_variables);
|
||||
} catch (HandBrakeCluster_Exception_AbortEntirePage $e) {
|
||||
} catch (RippingCluster_Exception_AbortEntirePage $e) {
|
||||
return false;
|
||||
} catch (HandBrakeCluster_Exception_FileNotFound $e) {
|
||||
} catch (RippingCluster_Exception_FileNotFound $e) {
|
||||
$this->render('errors/404.tpl', 'errors/404.php');
|
||||
} catch (HandBrakeCluster_Exception $e) {
|
||||
} catch (RippingCluster_Exception $e) {
|
||||
$this->render('errors/unhandled-exception.tpl', 'errors/unhandled-exception.php', array(
|
||||
'exception' => $e,
|
||||
));
|
||||
@@ -42,7 +42,7 @@ class HandBrakeCluster_Page {
|
||||
|
||||
protected function render($template_filename, $code_filename = null, $template_variables = array()) {
|
||||
if ( ! $this->smarty->template_exists($template_filename)) {
|
||||
throw new HandBrakeCluster_Exception_FileNotFound($template_filename);
|
||||
throw new RippingCluster_Exception_FileNotFound($template_filename);
|
||||
}
|
||||
|
||||
// Copy all the template variables into the namespace for this function,
|
||||
@@ -62,11 +62,11 @@ class HandBrakeCluster_Page {
|
||||
}
|
||||
|
||||
public static function redirect($relative_url) {
|
||||
$absolute_url = HandBrakeCluster_Main::instance()->absoluteUrl($relative_url);
|
||||
$absolute_url = RippingCluster_Main::instance()->absoluteUrl($relative_url);
|
||||
|
||||
header("Location: $absolute_url");
|
||||
|
||||
throw new HandBrakeCluster_Exception_AbortEntirePage();
|
||||
throw new RippingCluster_Exception_AbortEntirePage();
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
abstract class HandBrakeCluster_PluginFactory {
|
||||
abstract class RippingCluster_PluginFactory {
|
||||
|
||||
static protected $validPlugins;
|
||||
|
||||
@@ -13,7 +13,7 @@ abstract class HandBrakeCluster_PluginFactory {
|
||||
protected static function findPlugins($directory) {
|
||||
$plugins = array();
|
||||
|
||||
$iterator = new HandBrakeCluster_Utility_ClassFilesIterator(new HandBrakeCluster_Utility_VisibleFilesIterator(new DirectoryIterator(HandBrakeCluster_Lib . $directory)));
|
||||
$iterator = new RippingCluster_Utility_ClassFilesIterator(new RippingCluster_Utility_VisibleFilesIterator(new DirectoryIterator(RippingCluster_Lib . $directory)));
|
||||
|
||||
foreach ($iterator as /** @var SplFileInfo */ $file) {
|
||||
$plugin = preg_replace('/.class.php$/', '', $file->getFilename());
|
||||
@@ -33,7 +33,7 @@ abstract class HandBrakeCluster_PluginFactory {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! in_array('HandBrakeCluster_Worker_IPlugin', class_implements($fullClassname))) {
|
||||
if ( ! in_array('RippingCluster_Worker_IPlugin', class_implements($fullClassname))) {
|
||||
echo "$plugin does not implement the necessary interfaces\n";
|
||||
continue;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_RequestParser {
|
||||
class RippingCluster_RequestParser {
|
||||
|
||||
private $request_string;
|
||||
private $page = array();
|
||||
@@ -81,7 +81,7 @@ class HandBrakeCluster_RequestParser {
|
||||
return $this->vars[$key];
|
||||
}
|
||||
|
||||
if (is_string($default) && preg_match('/^HandBrakeCluster_Exception/', $default) && class_exists($default) && is_subclass_of($default, HandBrakeCluster_Exception)) {
|
||||
if (is_string($default) && preg_match('/^RippingCluster_Exception/', $default) && class_exists($default) && is_subclass_of($default, RippingCluster_Exception)) {
|
||||
throw new $default();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Rips_Source {
|
||||
class RippingCluster_Rips_Source {
|
||||
|
||||
const PM_TITLE = 0;
|
||||
const PM_CHAPTER = 1;
|
||||
@@ -18,7 +18,7 @@ class HandBrakeCluster_Rips_Source {
|
||||
$this->scan();
|
||||
}
|
||||
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$main = RippingCluster_Main::instance();
|
||||
$cache = $main->cache();
|
||||
$config = $main->config();
|
||||
|
||||
@@ -28,12 +28,12 @@ class HandBrakeCluster_Rips_Source {
|
||||
}
|
||||
|
||||
public static function load($source_filename, $scan_dir = true, $use_cache = true) {
|
||||
$cache = HandBrakeCluster_Main::instance()->cache();
|
||||
$cache = RippingCluster_Main::instance()->cache();
|
||||
|
||||
if ($use_cache && $cache->exists($source_filename)) {
|
||||
return unserialize($cache->fetch($source_filename));
|
||||
} else {
|
||||
return new HandBrakeCluster_Rips_Source($source_filename, $scan_dir, $use_cache);
|
||||
return new RippingCluster_Rips_Source($source_filename, $scan_dir, $use_cache);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,14 +44,14 @@ class HandBrakeCluster_Rips_Source {
|
||||
// Ensure the source is a valid directory, and lies below the configured source_dir
|
||||
$real_source_filename = realpath($source_filename);
|
||||
if (!is_dir($source_filename)) {
|
||||
throw new HandBrakeCluster_Exception_InvalidSourceDirectory($source_filename);
|
||||
throw new RippingCluster_Exception_InvalidSourceDirectory($source_filename);
|
||||
}
|
||||
|
||||
$config = HandBrakeCluster_Main::instance()->config();
|
||||
$config = RippingCluster_Main::instance()->config();
|
||||
$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) {
|
||||
throw new HandBrakeCluster_Exception_InvalidSourceDirectory($source_filename);
|
||||
throw new RippingCluster_Exception_InvalidSourceDirectory($source_filename);
|
||||
}
|
||||
|
||||
return self::load($source_filename, $scan_dir, $use_cache);
|
||||
@@ -60,7 +60,7 @@ class HandBrakeCluster_Rips_Source {
|
||||
protected function scan() {
|
||||
$source_shell = escapeshellarg($this->source);
|
||||
$handbrake_cmd = "HandBrakeCLI -i {$source_shell} -t 0";
|
||||
list($retval, $handbrake_output, $handbrake_error) = HandBrakeCluster_ForegroundTask::execute($handbrake_cmd);
|
||||
list($retval, $handbrake_output, $handbrake_error) = RippingCluster_ForegroundTask::execute($handbrake_cmd);
|
||||
|
||||
// Process the output
|
||||
$lines = explode("\n", $handbrake_error);
|
||||
@@ -81,7 +81,7 @@ class HandBrakeCluster_Rips_Source {
|
||||
}
|
||||
|
||||
$mode = self::PM_TITLE;
|
||||
$title = new HandBrakeCluster_Rips_SourceTitle($matches['id']);
|
||||
$title = new RippingCluster_Rips_SourceTitle($matches['id']);
|
||||
} break;
|
||||
|
||||
case $title && preg_match('/^ \+ chapters:$/', $line): {
|
||||
@@ -123,7 +123,7 @@ class HandBrakeCluster_Rips_Source {
|
||||
|
||||
case $title && $mode == self::PM_AUDIO && preg_match('/^ \+ (?P<id>\d+), (?P<name>.+) \((?P<format>.+)\) \((?P<channels>(.+ ch|Dolby Surround))\) \((?P<language>.+)\), (?P<samplerate>\d+)Hz, (?P<bitrate>\d+)bps$/', $line, $matches): {
|
||||
$title->addAudioTrack(
|
||||
new HandBrakeCluster_Rips_SourceAudioTrack(
|
||||
new RippingCluster_Rips_SourceAudioTrack(
|
||||
$matches['id'], $matches['name'], $matches['format'], $matches['channels'],
|
||||
$matches['language'], $matches['samplerate'], $matches['bitrate']
|
||||
)
|
||||
@@ -132,7 +132,7 @@ class HandBrakeCluster_Rips_Source {
|
||||
|
||||
case $title && $mode == self::PM_SUBTITLE && preg_match('/^ \+ (?P<id>\d+), (?P<name>.+) \((?P<language>.+)\) \((?P<format>.+)\)$/', $line, $matches): {
|
||||
$title->addSubtitleTrack(
|
||||
new HandBrakeCluster_Rips_SourceSubtitleTrack(
|
||||
new RippingCluster_Rips_SourceSubtitleTrack(
|
||||
$matches['id'], $matches['name'], $matches['language'], $matches['format']
|
||||
)
|
||||
);
|
||||
@@ -154,7 +154,7 @@ class HandBrakeCluster_Rips_Source {
|
||||
}
|
||||
|
||||
public static function isCached($source_filename) {
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$main = RippingCluster_Main::instance();
|
||||
$cache = $main->cache();
|
||||
$config = $main->config();
|
||||
|
||||
@@ -165,7 +165,7 @@ class HandBrakeCluster_Rips_Source {
|
||||
return str_replace("/", "-", base64_encode($filename));
|
||||
}
|
||||
|
||||
public function addTitle(HandBrakeCluster_Rips_SourceTitle $title) {
|
||||
public function addTitle(RippingCluster_Rips_SourceTitle $title) {
|
||||
$this->titles[] = $title;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Rips_SourceAudioTrack {
|
||||
class RippingCluster_Rips_SourceAudioTrack {
|
||||
|
||||
protected $id;
|
||||
protected $name;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Rips_SourceLister {
|
||||
class RippingCluster_Rips_SourceLister {
|
||||
|
||||
protected $base_directory;
|
||||
protected $sources = array();
|
||||
@@ -13,12 +13,12 @@ class HandBrakeCluster_Rips_SourceLister {
|
||||
|
||||
public function scan() {
|
||||
if (!is_dir($this->base_directory)) {
|
||||
throw new HandBrakeCluster_Exception_InvalidSourceDirectory($this->base_directory);
|
||||
throw new RippingCluster_Exception_InvalidSourceDirectory($this->base_directory);
|
||||
}
|
||||
|
||||
$iterator = new HandBrakeCluster_Utility_DvdDirectoryIterator(new HandBrakeCluster_Utility_VisibleFilesIterator(new DirectoryIterator($this->base_directory)));
|
||||
$iterator = new RippingCluster_Utility_DvdDirectoryIterator(new RippingCluster_Utility_VisibleFilesIterator(new DirectoryIterator($this->base_directory)));
|
||||
foreach ($iterator as /** @var SplFileInfo */ $source_vts) {
|
||||
$this->sources[] = HandBrakeCluster_Rips_Source::load($source_vts->getPathname(), false);
|
||||
$this->sources[] = RippingCluster_Rips_Source::load($source_vts->getPathname(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Rips_SourceSubtitleTrack {
|
||||
class RippingCluster_Rips_SourceSubtitleTrack {
|
||||
|
||||
protected $id;
|
||||
protected $name;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Rips_SourceTitle {
|
||||
class RippingCluster_Rips_SourceTitle {
|
||||
|
||||
protected $id;
|
||||
//protected $vts;
|
||||
@@ -106,7 +106,7 @@ class HandBrakeCluster_Rips_SourceTitle {
|
||||
return $this->audio;
|
||||
}
|
||||
|
||||
public function addAudioTrack(HandBrakeCluster_Rips_SourceAudioTrack $audio_track) {
|
||||
public function addAudioTrack(RippingCluster_Rips_SourceAudioTrack $audio_track) {
|
||||
$this->audio[] = $audio_track;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class HandBrakeCluster_Rips_SourceTitle {
|
||||
return $this->subtitles;
|
||||
}
|
||||
|
||||
public function addSubtitleTrack(HandBrakeCluster_Rips_SourceSubtitleTrack $subtitle_track) {
|
||||
public function addSubtitleTrack(RippingCluster_Rips_SourceSubtitleTrack $subtitle_track) {
|
||||
$this->subtitles[] = $subtitle_track;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Utility_ClassFilesIterator extends FilterIterator {
|
||||
class RippingCluster_Utility_ClassFilesIterator extends FilterIterator {
|
||||
public function accept() {
|
||||
return preg_match('/.class.php$/i', $this->current()->getFilename());
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Utility_DvdDirectoryIterator extends FilterIterator {
|
||||
class RippingCluster_Utility_DvdDirectoryIterator extends FilterIterator {
|
||||
public function accept() {
|
||||
return is_dir($this->current()->getPathname() . DIRECTORY_SEPARATOR . 'VIDEO_TS');
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Utility_VisibleFilesIterator extends FilterIterator {
|
||||
class RippingCluster_Utility_VisibleFilesIterator extends FilterIterator {
|
||||
public function accept() {
|
||||
return !(substr($this->current()->getFilename(), 0, 1) == '.');
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Worker {
|
||||
class RippingCluster_Worker {
|
||||
|
||||
protected $gearman;
|
||||
|
||||
@@ -14,17 +14,17 @@ class HandBrakeCluster_Worker {
|
||||
return;
|
||||
}
|
||||
|
||||
$config = HandBrakeCluster_Main::instance()->config();
|
||||
$config = RippingCluster_Main::instance()->config();
|
||||
|
||||
$this->gearman = new GearmanWorker();
|
||||
$this->gearman->addServers($config->get('rips.job_servers'));
|
||||
|
||||
// Load all the plugin classes
|
||||
echo "Loading Plugins\n";
|
||||
HandBrakeCluster_Worker_PluginFactory::scan();
|
||||
foreach (HandBrakeCluster_Worker_PluginFactory::getValidPlugins() as $plugin) {
|
||||
RippingCluster_Worker_PluginFactory::scan();
|
||||
foreach (RippingCluster_Worker_PluginFactory::getValidPlugins() as $plugin) {
|
||||
echo "Grabbing worker functions provided by {$plugin}\n";
|
||||
$workerFunctions = HandBrakeCluster_Worker_PluginFactory::getPluginWorkerFunctions($plugin);
|
||||
$workerFunctions = RippingCluster_Worker_PluginFactory::getPluginWorkerFunctions($plugin);
|
||||
|
||||
foreach ($workerFunctions as $function => $callback) {
|
||||
echo "Adding {$plugin}::{$callback[1]} as {$function}\n";
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
interface HandBrakeCluster_Worker_IPlugin {
|
||||
interface RippingCluster_Worker_IPlugin {
|
||||
|
||||
public static function workerFunctions();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Worker_Plugin_HandBrake implements HandBrakeCluster_Worker_IPlugin {
|
||||
class RippingCluster_Worker_Plugin_HandBrake implements RippingCluster_Worker_IPlugin {
|
||||
|
||||
const DEINTERLACE_ALWAYS = 1;
|
||||
const DEINTERLACE_SELECTIVELY = 2;
|
||||
@@ -39,7 +39,7 @@ class HandBrakeCluster_Worker_Plugin_HandBrake implements HandBrakeCluster_Worke
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$config = HandBrakeCluster_Main::instance()->config();
|
||||
$config = RippingCluster_Main::instance()->config();
|
||||
|
||||
$handbrake_cmd_raw = array(
|
||||
'-n', $config->get('rips.nice'),
|
||||
@@ -65,7 +65,7 @@ class HandBrakeCluster_Worker_Plugin_HandBrake implements HandBrakeCluster_Worke
|
||||
}
|
||||
$handbrake_cmd = join(' ', $handbrake_cmd);
|
||||
|
||||
return HandBrakeCluster_ForegroundTask::execute($handbrake_cmd, null, null, null, array($this, 'callbackStdout'), array($this, 'callbackStderr'), $this);
|
||||
return RippingCluster_ForegroundTask::execute($handbrake_cmd, null, null, null, array($this, 'callbackStdout'), array($this, 'callbackStderr'), $this);
|
||||
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class HandBrakeCluster_Worker_Plugin_HandBrake implements HandBrakeCluster_Worke
|
||||
$line = $lines[0];
|
||||
$this->stdout = $lines[1];
|
||||
|
||||
$log = HandBrakeCluster_Main::instance()->log();
|
||||
$log = RippingCluster_Main::instance()->log();
|
||||
$log->info($line);
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ class HandBrakeCluster_Worker_Plugin_HandBrake implements HandBrakeCluster_Worke
|
||||
$numerator = 100 * $matches[1];
|
||||
$this->job->sendStatus($numerator, 100);
|
||||
} else {
|
||||
$log = HandBrakeCluster_Main::instance()->log();
|
||||
$log = RippingCluster_Main::instance()->log();
|
||||
$log->debug($line);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
class HandBrakeCluster_Worker_PluginFactory extends HandBrakeCluster_PluginFactory {
|
||||
class RippingCluster_Worker_PluginFactory extends RippingCluster_PluginFactory {
|
||||
|
||||
const PLUGIN_DIR = 'HandBrakeCluster/Worker/Plugin/';
|
||||
const PREFIX = 'HandBrakeCluster_Worker_Plugin_';
|
||||
const PLUGIN_DIR = 'RippingCluster/Worker/Plugin/';
|
||||
const PREFIX = 'RippingCluster_Worker_Plugin_';
|
||||
|
||||
public static function init() {
|
||||
|
||||
13
lib/RippingCluster/WorkerLogEntry.class.php
Normal file
13
lib/RippingCluster/WorkerLogEntry.class.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class RippingCluster_WorkerLogEntry extends RippingCluster_LogEntry {
|
||||
|
||||
public static function initialise() {
|
||||
parent::$table_name = 'worker_log';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
RippingCluster_WorkerLogEntry::initialise();
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user