10
my $file = "/etc/mythtv/mythexport/mythexport_settings.cfg";
11
my ($script,$content) = "";
12
my $template = HTML::Template->new(filename => 'template/template.tmpl');
14
# if we have a valid config
15
if(-e $file && -s $file > 207){
16
my $cfg = new Config::Simple();
17
$cfg->read($file) || die $cfg->error();
19
$script = "<script type=\"text/javascript\">//<![CDATA[
20
function changeBlock(){
21
var url = \"setup_edit.cgi?block=\" + document.getElementById(\"block\").value;
22
window.location = url;
24
function deleteConfig(){
25
document.getElementById(\"delete\").value = 1;
26
document.forms[0].submit();
31
my $block = param("block");
33
my $test = $cfg->as_string();
35
$test =~ s/^(.*?)\[//;
36
$test =~ s/\](.*?)\[/,/g;
37
$test =~ s/\](.*?)$//;
39
my @blocks = split(",", $test);
45
$content = "<form id=\"form\" action=\"save_setup.cgi\" method=\"post\"><p>
46
Choose a configuration to Edit: <select id=\"block\" name=\"block\" onchange=\"javascript:changeBlock();\">";
49
$content .= "<option value=\"$_\"";
51
$content .= " selected=\"selected\"";
53
$content .= ">$_</option>";
56
my $sizeX = $cfg->param("$block.sizeX") unless ref $cfg->param("$block.sizeX") eq 'ARRAY';
57
my $sizeY = $cfg->param("$block.sizeY") unless ref $cfg->param("$block.sizeY") eq 'ARRAY';
58
my $audioBR = $cfg->param("$block.audioBR") unless ref $cfg->param("$block.audioBR") eq 'ARRAY';
59
my $videoBR = $cfg->param("$block.videoBR") unless ref $cfg->param("$block.videoBR") eq 'ARRAY';
60
my $device = $cfg->param("$block.device") unless ref $cfg->param("$block.device") eq 'ARRAY';
61
my $aspect = $cfg->param("$block.aspect") unless ref $cfg->param("$block.aspect") eq 'ARRAY';
62
my $codec = $cfg->param("$block.codec") unless ref $cfg->param("$block.codec") eq 'ARRAY';
63
my $deinterlace = $cfg->param("$block.deinterlace") unless ref $cfg->param("$block.deinterlace") eq 'ARRAY';
64
my $deletePeriod = $cfg->param("$block.deletePeriod") unless ref $cfg->param("$block.deletePeriod") eq 'ARRAY';
65
my $podcastName = $cfg->param("$block.podcastName") unless ref $cfg->param("$block.podcastName") eq 'ARRAY';
66
my $removeCommercials = $cfg->param("$block.removeCommercials") unless ref $cfg->param("$block.removeCommercials") eq 'ARRAY';
67
my $audioChannels = $cfg->param("$block.audioChannels") unless ref $cfg->param("$block.audioChannels") eq 'ARRAY';
68
my $threads = $cfg->param("$block.threads") unless ref $cfg->param("$block.threads") eq 'ARRAY';
69
my $extension = $cfg->param("$block.extension") unless ref $cfg->param("$block.extension") eq 'ARRAY';
70
my $ffmpegArgs = $cfg->param("$block.ffmpegArgs") unless ref $cfg->param("$block.ffmpegArgs") eq 'ARRAY';
72
$content .= "</select> <span class=\"red\">*</span><br /><br />
73
<input type=\"hidden\" id=\"delete\" name=\"delete\" value=\"0\" />
74
<input type=\"hidden\" id=\"device\" name=\"device\" value=\"$device\" />
75
Title: $block<input type=\"hidden\" id=\"title\" name=\"title\" value=\"$block\" /> <span class=\"red\">*</span><br />";
77
if($device eq "custom"){
78
$content .= "FFmpeg Arguments: <input type=\"text\" id=\"args\" name=\"args\" value=\"$ffmpegArgs\" /> <span class=\"red\">*</span><br />
79
File Extension: <input type=\"text\" id=\"extension\" name=\"extension\" value=\"$extension\" /><br />";
81
elsif($device eq "mp3"){
82
$content .= "Audio Bitrate: <input type=\"text\" id=\"audioBR\" name=\"audioBR\" value=\"$audioBR\" /> <span class=\"red\">*</span><br />";
84
elsif($device eq "symlink"){
85
$content .= "Symlinks will be created and linked to your original recordings.";
88
$content .= "Size: <input type=\"text\" id=\"sizeX\" name=\"sizeX\" value=\"$sizeX\" /> <span class=\"red\">*</span> X
89
<input type=\"text\" id=\"sizeY\" name=\"sizeY\" value=\"$sizeY\" /> <span class=\"red\">*</span><br />
90
Aspect: <input type=\"text\" id=\"aspect\" name=\"aspect\" value=\"$aspect\" /> <span class=\"red\">*</span><br />
91
Audio Bitrate: <input type=\"text\" id=\"audioBR\" name=\"audioBR\" value=\"$audioBR\" /> <span class=\"red\">*</span><br />
92
Video Bitrate: <input type=\"text\" id=\"videoBR\" name=\"videoBR\" value=\"$videoBR\" /> <span class=\"red\">*</span><br />
93
Codec: <select id=\"codec\" name=\"codec\">
94
<option value=\"none\">None</option>
95
<option value=\"mpeg4\"";
96
if ($codec eq "mpeg4"){
97
$content .= " selected=\"selected\"";
99
$content .= ">mpeg4</option>
100
<option value=\"xvid\"";
101
if ($codec eq "xvid"){
102
$content .= " selected=\"selected\"";
104
$content .= ">xvid</option>";
105
if($device ne "psp"){
106
$content .= "<option value=\"h264\"";
107
if ($codec eq "h264"){
108
$content .= " selected=\"selected\"";
110
$content .= ">h.264</option>";
112
$content .= "<option value=\"mp3\"";
113
if ($codec eq "mp3"){
114
$content .= " selected=\"selected\"";
116
$content .= ">mp3</option>
117
</select> <span class=\"red\">*</span><br />
118
Delete Period: <input type=\"text\" id=\"deletePeriod\" name=\"deletePeriod\" value=\"$deletePeriod\" /><br />
119
Podcast Name: <input type=\"text\" id=\"podcastName\" name=\"podcastName\" value=\"$podcastName\" /><br />
120
Deinterlace: <input type=\"checkbox\" id=\"deinterlace\" name=\"deinterlace\" value=\"1\" ";
121
if ($deinterlace == 1){
122
$content .= "checked=\"checked\" ";
124
$content .= "/><br />
125
Remove Commercials: <input type=\"checkbox\" id=\"removeCommercials\" name=\"removeCommercials\" value=\"1\" ";
126
if ($removeCommercials == 1){
127
$content .= "checked=\"checked\" ";
129
$content .= "/><br /><br />
130
- Addition Tweaks -<br /><br />
131
Audio Channels: <input type=\"text\" id=\"audioChannels\" name=\"audioChannels\" value=\"$audioChannels\" /> * May help with dvb recordings<br />
132
Muti-threading: <input type=\"checkbox\" id=\"threads\" name=\"threads\" value=\"1\" ";
134
$content .= "checked=\"checked\" ";
136
$content .= "/><br />";
139
$content .= "<br /> <span class=\"red\">* Are required</span><br /><input type=\"submit\" id=\"submitButton\" name=\"submitButton\" value=\"Submit\" />
140
<input type=\"button\" id=\"deleteButton\" name=\"deleteButton\" value=\"Delete\" onclick=\"javascript:deleteConfig();\" />
144
$content = "<p>Missing or Invalid configuration file, please create one.</p>";
147
$template->param(SCRIPT => $script);
148
$template->param(CONTENT => $content);
149
$template->param(LOCATION => "setup");
151
print generateContentType(), $template->output;