Added setup-rip page to configure new rip task
Added method to Source to identify the longest title in a source
This commit is contained in:
@@ -154,6 +154,27 @@ class HandBrakeCluster_Rips_Source {
|
|||||||
$this->titles[] = $title;
|
$this->titles[] = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function longestTitle() {
|
||||||
|
$longest_title = null;
|
||||||
|
$maximum_duration = 0;
|
||||||
|
|
||||||
|
if ( ! $this->titles) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->titles as $title) {
|
||||||
|
$duration = $title->durationInSeconds();
|
||||||
|
if ($duration > $maximum_duration) {
|
||||||
|
$longest_title = $title;
|
||||||
|
$maximum_duration = $duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $longest_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function output() {
|
public function output() {
|
||||||
return $this->output;
|
return $this->output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ class HandBrakeCluster_Rips_SourceTitle {
|
|||||||
return $this->duration;
|
return $this->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function durationInSeconds() {
|
||||||
|
$time = explode(":", $this->duration);
|
||||||
|
return ($time[0] * 3600) + ($time[1] * 60) + $time[2];
|
||||||
|
}
|
||||||
|
|
||||||
public function setDuration($duration) {
|
public function setDuration($duration) {
|
||||||
$this->duration = $duration;
|
$this->duration = $duration;
|
||||||
}
|
}
|
||||||
|
|||||||
40
pages/rips/setup-rip.php
Normal file
40
pages/rips/setup-rip.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$main = HandBrakeCluster_Main::instance();
|
||||||
|
$req = $main->request();
|
||||||
|
$config = $main->config();
|
||||||
|
|
||||||
|
// Grab the name of this source
|
||||||
|
$source_id;
|
||||||
|
if ($req->get('submit')) {
|
||||||
|
$this->smarty->assign('rips_submitted', true);
|
||||||
|
$source_id = HandBrakeCluster_Main::issetelse($_POST['id'], HandBrakeCluster_Exception_InvalidParameters);
|
||||||
|
|
||||||
|
$this->smarty->assign('rips', HandBrakeCluster_Main::issetelse($_POST['rips'], HandBrakeCluster_Exception_InvalidParameters));
|
||||||
|
} else {
|
||||||
|
$this->smarty->assign('rips_submitted', false);
|
||||||
|
$source_id = $req->get('id', HandBrakeCluster_Exception_InvalidParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
$source_path = base64_decode(str_replace('-', '/', $source_id));
|
||||||
|
$real_source_path = realpath($source_path);
|
||||||
|
|
||||||
|
// Ensure the source is a valid directory, and lies below the configured source_dir
|
||||||
|
if (!is_dir($source_path)) {
|
||||||
|
throw new HandBrakeCluster_Exception_InvalidParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
$real_source_dir = realpath($config->get('rips.source_dir'));
|
||||||
|
if (substr($real_source_path, 0, strlen($real_source_dir)) != $real_source_dir) {
|
||||||
|
throw new HandBrakeCluster_Exception_InvalidParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
$source = HandBrakeCluster_Rips_Source::load($source_path);
|
||||||
|
|
||||||
|
$this->smarty->assign('source_path_encoded', $source_id);
|
||||||
|
$this->smarty->assign('source_path', $source_path);
|
||||||
|
$this->smarty->assign('source', $source);
|
||||||
|
$this->smarty->assign('titles', $source->titles());
|
||||||
|
$this->smarty->assign('longest_title', $source->longestTitle());
|
||||||
|
|
||||||
|
?>
|
||||||
77
templates/rips/setup-rip.tpl
Normal file
77
templates/rips/setup-rip.tpl
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<h2>Setup Rips</h2>
|
||||||
|
|
||||||
|
{if $rips_submitted}
|
||||||
|
<p>
|
||||||
|
Processing rips now...
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<pre>{$rips|var_dump}</pre>
|
||||||
|
{else}
|
||||||
|
<form name="setup-rips" id="setup-rips" action="{$base_uri}rips/setup-rip/submit/" method="post">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Configure titles to rip</legend>
|
||||||
|
|
||||||
|
<input type="hidden" name="id" value="{$source_path_encoded}" />
|
||||||
|
|
||||||
|
<input type="submit" name="submit" value="Queue rips" />
|
||||||
|
|
||||||
|
<div id="available-titles">
|
||||||
|
{foreach from=$titles item=title}
|
||||||
|
<h3><a href="#">Title {$title->id()} (Duration: {$title->duration()}, Chapters: {$title->chapterCount()})</a></h3>
|
||||||
|
<div id="rips-{$title->id()}">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Configure title rip options</legend>
|
||||||
|
|
||||||
|
<input type="checkbox" id="rip-title-{$title->id()}" name="rips[{$title->id()}][queue]" value="1" />
|
||||||
|
<label for="rip-title-{$title->id()}">Rip this title</label>
|
||||||
|
|
||||||
|
<input type="checkbox" id="rip-chapters-{$title->id()}" name="rips[{$title->id()}][include-chapters]" value="{$title->id()}" checked="checked" />
|
||||||
|
<label for="rip-title-{$title->id()}">Include chapter markers</label>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<label for="rip-audio-{$title->id()}">Audio tracks</label>
|
||||||
|
<select id="rip-audio-{$title->id()}" name="rips[{$title->id()}][audio][]" size="5" multiple="multiple">
|
||||||
|
{foreach from=$title->audioTracks() item=audio}
|
||||||
|
<option value="{$audio->id()}">{$audio->name()} - {$audio->channels()} ch ({$audio->language()}) </option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="rip-subtitle-{$title->id()}">Subtitle tracks</label>
|
||||||
|
<select id="rip-subtitle-{$title->id()}" name="rips[{$title->id()}][subtitles][]" size="5" multiple="multiple">
|
||||||
|
{foreach from=$title->subtitleTracks() item=subtitle}
|
||||||
|
<option value="{$subtitle->id()}">{$subtitle->language()}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<label for="rips-output-{$title->id()}">Output filename</label>
|
||||||
|
<input type="text" id="rips-output-{$title->id()}" name="rips[{$title->id()}][output_filename]" value="" />
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<select id="rip-deinterlace-{$title->id()}" name="rips[{$title->id()}][deinterlace]">
|
||||||
|
<option value="0">Don't deinterlace</option>
|
||||||
|
<option value="1">Do deinterlace</option>
|
||||||
|
<option value="2" selected="selected">Selectively deinterlace</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
{/foreach}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" name="submit" value="Queue rips" />
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{literal}
|
||||||
|
<script language="javascript">
|
||||||
|
$(function() {
|
||||||
|
$("#available-titles").accordion();
|
||||||
|
$("input:submit").button();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{/literal}
|
||||||
|
{/if}
|
||||||
Reference in New Issue
Block a user