webif/var/mongoose/cgi-bin/browse/file.jim
hummypkg 2ab6f7caa2 0.12.0
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1398 2a923420-c742-0410-a762-8d5b09965624
2013-02-09 22:46:15 +00:00

157 lines
3.0 KiB
Plaintext
Executable File

#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require pretty_size
httpheader
set file [cgi_get file]
set type [cgi_get type]
if {$file == 0} exit
file stat $file st
set sz [pretty_size $st(size)]
if {$type eq "ts"} {
require epg.class ts.class
set ts [ts fetch $file]
puts "
<table class=keyval>
<tr>
<th>Title</th>
<td>[$ts get title]</td>
</tr><tr>
<th>Synopsis</th>
<td>[$ts get synopsis]</td>
</tr><tr>
"
if {[$ts flag "Guidance"] > 0} {
puts "
<th>Guidance</th>
<td><img class=va
src=/images/174_1_26_GuidancePolicy.png height=21>
[$ts get guidance]
</td>
</tr><tr>
"
}
puts "
<th>Definition</th>
<td>
"
if {[$ts get definition] eq "HD"} {
puts "<img class=va src=/images/172_1_00_HD.png height=21>"
} else {
puts "<img class=va src=/images/172_1_26_SD.png height=21>"
}
puts "</td>
</tr><tr>
<th>Channel</th>
<td>[epg channelicon [$ts get channel_name] 50 "vertical-align: middle"]
[$ts get channel_num] - [$ts get channel_name]</td>
</tr><tr>
<th>Start Time</th>
<td>"
puts [clock format [$ts get start] -format "%c %Z"]
puts "<font class=also>(Scheduled: [
clock format [$ts get schedstart] -format "%c %Z"])</font>"
puts "</td>
</tr><tr>
<th>End Time</th>
<td>"
puts [clock format [$ts get end] -format "%c %Z"]
puts "<font class=also>(Scheduled: [clock format \
[expr [$ts get schedstart] + [$ts get scheddur]] \
-format "%c %Z"])</font>"
puts "</td>
</tr><tr>
<th>Duration</th>
<td>[$ts duration] minute(s).
<font class=also>(Scheduled: [expr [$ts get scheddur] / 60])
</font></td>
</tr><tr>
<th>Size</th>
<td>$sz</td>
"
lassign [$ts dlnaloc] url
if {$url ne ""} {
puts "</tr><tr><th>DLNA&nbsp;URL</th>
<td><a href=\"$url\">$url</a></td>"
}
puts "
</tr><tr>
<th>Files</th>
<td>
"
set fileset [$ts fileset]
puts -nonewline "<img id=xfileset class=va src=/img/tree/plusonly.png>"
puts -nonewline "[llength $fileset] file"
if {[llength $fileset] != 1} { puts -nonewline "s" }
puts -nonewline " in set."
puts "<div id=fileset class=hidden><ul>"
foreach f $fileset {
puts "<li>[file tail $f] ([pretty_size [file size $f]])</li>"
}
puts "</ul></div>"
puts "</td>
</tr><tr>
<th>Flags</th>
<td>[$ts get flags]
"
if {[$ts get bookmarks]} {
puts " \[Bookmarks: [$ts get bookmarks]\]"
}
puts "</tr>"
puts "</table>"
puts {
<script type=text/javascript>
$('#xfileset').click(function() {
$('#fileset').slideToggle('slow', function() {
if ($('#fileset').is(':visible'))
$('#xfileset').attr('src', '/img/tree/minustop.png');
else
$('#xfileset').attr('src', '/img/tree/plusonly.png');
});
});
</script>
}
exit
}
# Otherwise, for a general file.
puts "
<table class=keyval>
<tr>
<th>File</th>
<td>$file</td>
</tr><tr>
<th>Size</th>
<td>$sz</td>
</tr><tr>
<th>Info</th>
<td class=pre id=ffmpeg>
<img src=/img/loading.gif><i>Loading...</i>
</td>
</tr>
</table>
"
set url "/cgi-bin/browse/ffmpeg.jim?file=[cgi_quote_url $file]"
puts { <script type="text/javascript"> }
puts "var url = \"$url\";"
puts {
$('#ffmpeg').load(url);
</script>
}