~ubuntu-branches/ubuntu/precise/mythexport/precise

« back to all changes in this revision

Viewing changes to usr/share/mythtv/mythexport/setup_edit.cgi

  • Committer: Bazaar Package Importer
  • Author(s): John Baab
  • Date: 2010-08-13 01:53:54 UTC
  • mfrom: (19 lucid)
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: james.westby@ubuntu.com-20100813015354-pb6w02upqqnegsep
Tags: upstream-2.2.0
ImportĀ upstreamĀ versionĀ 2.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
 
3
 
use strict;
4
 
use CGI qw(:standard);
5
 
use HTML::Template;
6
 
use Config::Simple; 
7
 
 
8
 
require includes;
9
 
 
10
 
my $file = "/etc/mythtv/mythexport/mythexport_settings.cfg";
11
 
my ($script,$content) = "";
12
 
my $template = HTML::Template->new(filename => 'template/template.tmpl');
13
 
 
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();
18
 
 
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;
23
 
    }
24
 
    function deleteConfig(){
25
 
        document.getElementById(\"delete\").value = 1;
26
 
        document.forms[0].submit();
27
 
    }
28
 
    //]]>
29
 
    </script>";
30
 
 
31
 
    my $block = param("block");
32
 
 
33
 
    my $test = $cfg->as_string();
34
 
    $test =~ s/\n//g;
35
 
    $test =~ s/^(.*?)\[//;
36
 
    $test =~ s/\](.*?)\[/,/g;
37
 
    $test =~ s/\](.*?)$//;
38
 
 
39
 
    my @blocks = split(",", $test);
40
 
 
41
 
    if ($block eq ""){
42
 
        $block = @blocks[0];
43
 
    }
44
 
 
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();\">";
47
 
 
48
 
    foreach(@blocks){
49
 
            $content .= "<option value=\"$_\"";
50
 
            if ($_ eq $block){
51
 
                    $content .= " selected=\"selected\"";
52
 
            }
53
 
            $content .= ">$_</option>";
54
 
    }
55
 
 
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';
71
 
 
72
 
    $content .= "</select>&nbsp;<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\" />&nbsp;<span class=\"red\">*</span><br />";
76
 
 
77
 
    if($device eq "custom"){
78
 
            $content .= "FFmpeg Arguments: <input type=\"text\" id=\"args\" name=\"args\" value=\"$ffmpegArgs\" />&nbsp;<span class=\"red\">*</span><br />
79
 
        File Extension: <input type=\"text\" id=\"extension\" name=\"extension\" value=\"$extension\" /><br />";
80
 
    }
81
 
    elsif($device eq "mp3"){
82
 
            $content .= "Audio Bitrate: <input type=\"text\" id=\"audioBR\" name=\"audioBR\" value=\"$audioBR\" />&nbsp;<span class=\"red\">*</span><br />";
83
 
    }
84
 
    elsif($device eq "symlink"){
85
 
            $content .= "Symlinks will be created and linked to your original recordings.";
86
 
    }
87
 
    else{
88
 
            $content .= "Size: <input type=\"text\" id=\"sizeX\" name=\"sizeX\" value=\"$sizeX\" />&nbsp;<span class=\"red\">*</span>&nbsp;X&nbsp;
89
 
            <input type=\"text\" id=\"sizeY\" name=\"sizeY\" value=\"$sizeY\" />&nbsp;<span class=\"red\">*</span><br />
90
 
            Aspect: <input type=\"text\" id=\"aspect\" name=\"aspect\" value=\"$aspect\" />&nbsp;<span class=\"red\">*</span><br />
91
 
            Audio Bitrate: <input type=\"text\" id=\"audioBR\" name=\"audioBR\" value=\"$audioBR\" />&nbsp;<span class=\"red\">*</span><br />
92
 
            Video Bitrate: <input type=\"text\" id=\"videoBR\" name=\"videoBR\" value=\"$videoBR\" />&nbsp;<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\"";
98
 
            }
99
 
            $content .= ">mpeg4</option>
100
 
            <option value=\"xvid\"";
101
 
            if ($codec eq "xvid"){
102
 
                    $content .= " selected=\"selected\"";
103
 
            }
104
 
            $content .= ">xvid</option>";
105
 
            if($device ne "psp"){
106
 
                    $content .= "<option value=\"h264\"";
107
 
                    if ($codec eq "h264"){
108
 
                            $content .= " selected=\"selected\"";
109
 
                    }
110
 
                    $content .= ">h.264</option>";
111
 
            }
112
 
            $content .= "<option value=\"mp3\"";
113
 
            if ($codec eq "mp3"){
114
 
                    $content .= " selected=\"selected\"";
115
 
            }
116
 
            $content .= ">mp3</option>
117
 
            </select>&nbsp;<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\" ";
123
 
            }
124
 
            $content .= "/><br />
125
 
            Remove Commercials: <input type=\"checkbox\" id=\"removeCommercials\" name=\"removeCommercials\" value=\"1\" ";
126
 
            if ($removeCommercials == 1){
127
 
                    $content .= "checked=\"checked\" ";
128
 
            }
129
 
            $content .= "/><br /><br />
130
 
            - Addition Tweaks -<br /><br />
131
 
            Audio Channels: <input type=\"text\" id=\"audioChannels\" name=\"audioChannels\" value=\"$audioChannels\" />&nbsp;* May help with dvb recordings<br />
132
 
            Muti-threading: <input type=\"checkbox\" id=\"threads\" name=\"threads\" value=\"1\" ";
133
 
            if ($threads == 1){
134
 
                    $content .= "checked=\"checked\" ";
135
 
            }
136
 
            $content .= "/><br />";
137
 
    }
138
 
 
139
 
    $content .= "<br />&nbsp;<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();\" />
141
 
    </p></form>";
142
 
}
143
 
else{
144
 
    $content = "<p>Missing or Invalid configuration file, please create one.</p>";
145
 
}
146
 
 
147
 
$template->param(SCRIPT => $script);
148
 
$template->param(CONTENT => $content);
149
 
$template->param(LOCATION => "setup");
150
 
 
151
 
print generateContentType(), $template->output;
152
 
exit(0);