2011-06-14 11:48:55 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
2011-06-16 03:10:41 +00:00
|
|
|
source /mod/var/mongoose/lib/ts.class
|
2011-06-14 11:48:55 +00:00
|
|
|
|
|
|
|
puts "Content-Type: text/html"
|
|
|
|
puts ""
|
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
set ignore {nts thm hmt hmi}
|
|
|
|
set standard {avi mpg wmv mkv}
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
#set _cgi(tsfile) "/media/My Video/Family Guy/2.19._Excellence_in_Broadcasting.ts"
|
|
|
|
#set _cgi(action) "lock"
|
|
|
|
#set env(REQUEST_URI) ''
|
|
|
|
|
|
|
|
proc tsfile {file bfile} {{i 0}} {
|
|
|
|
set ts [ts fetch $file]
|
|
|
|
puts "
|
|
|
|
<div class=\"va tsfile\" id=[incr i]>
|
|
|
|
<a class=ts file=\"$file\" href=#>
|
|
|
|
<img class=va border=0 width=45
|
|
|
|
src=/images/741_1_10_Video_Title.png>
|
|
|
|
$bfile
|
|
|
|
</a>
|
|
|
|
"
|
|
|
|
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>"
|
|
|
|
}
|
|
|
|
if {[$ts flag "Locked"] > 0} {
|
|
|
|
puts "<img class=va src=/images/178_1_00_Icon_Lock.png
|
|
|
|
height=21>"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
puts "
|
|
|
|
<a class=tsopt file=\"$file\" href=#>
|
|
|
|
<img class=\"opt va\" border=0 width=45 did=$i
|
|
|
|
src=/images/181_1_00_Help5_OPT_Plus.png>
|
|
|
|
</a>
|
|
|
|
<div class=\"results blood\" style=\"margin: 0 0 0 5em\"></div>
|
|
|
|
</div>
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
|
|
proc genfile {file bfile} {
|
|
|
|
puts "
|
|
|
|
<div class=va>
|
|
|
|
<a href=#>
|
|
|
|
<img class=va border=0 width=45 style=\"padding: 0.3em 0\"
|
|
|
|
src=/images/743_4_10_Video_Xvid_File.png>
|
|
|
|
$bfile
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
|
|
proc directory {file bfile} {
|
|
|
|
puts "<div class=va>"
|
|
|
|
puts "<a href=$::env(REQUEST_URI)?dir=[cgi_quote_url $file]>"
|
|
|
|
puts "<img border=0 class=va src=/images/711_1_09_Media_Folder.png>"
|
|
|
|
puts "$bfile</a></div>"
|
|
|
|
}
|
|
|
|
|
|
|
|
proc entry {file} {
|
|
|
|
set bfile [lindex [split $file /] end]
|
|
|
|
if {[string index $bfile 0] == "\025"} {
|
|
|
|
set bfile [string range $bfile 1 end]
|
|
|
|
}
|
|
|
|
if [file isdirectory "$file"] {
|
|
|
|
directory $file $bfile
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
regexp -- {\.([^.]+)$} "$file" allmatch ext
|
|
|
|
if {$ext eq "ts"} {
|
|
|
|
tsfile $file $bfile
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if {$ext in $::ignore} { continue }
|
|
|
|
if {$ext in $::standard} {
|
|
|
|
genfile $file $bfile
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
2011-06-14 11:48:55 +00:00
|
|
|
|
|
|
|
if {[dict exists $_cgi tsfile]} {
|
|
|
|
set file [dict get $_cgi tsfile]
|
2011-06-16 03:10:41 +00:00
|
|
|
set ts [ts fetch $file]
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
if {[dict exists $_cgi action]} {
|
|
|
|
switch [dict get $_cgi action] {
|
|
|
|
entry {
|
|
|
|
entry $file
|
|
|
|
}
|
|
|
|
delete {
|
|
|
|
if {[$ts delete]} {
|
|
|
|
puts "Successfully deleted $file."
|
|
|
|
} else {
|
|
|
|
puts "Problem deleting $file, [$ts get error]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lock {
|
|
|
|
set action lock
|
|
|
|
if {[$ts flag "Locked"]} { set action unlock }
|
|
|
|
if {[$ts $action]} {
|
|
|
|
puts "Successfully [set action]ed $file."
|
|
|
|
} else {
|
|
|
|
puts "Problem [set action]ing $file,
|
|
|
|
[$ts get error]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
2011-06-16 03:10:41 +00:00
|
|
|
|
|
|
|
source /mod/var/mongoose/lib/epg.class
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
puts "
|
|
|
|
<table class=keyval>
|
|
|
|
<tr>
|
|
|
|
<th>Title</th>
|
2011-06-16 03:10:41 +00:00
|
|
|
<td>[$ts get title]</td>
|
2011-06-14 11:48:55 +00:00
|
|
|
</tr><tr>
|
|
|
|
<th>Synopsis</th>
|
2011-06-16 03:10:41 +00:00
|
|
|
<td>[$ts get synopsis]</td>
|
2011-06-14 11:48:55 +00:00
|
|
|
</tr><tr>
|
|
|
|
<th>Definition</th>
|
2011-06-16 03:10:41 +00:00
|
|
|
<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>
|
2011-06-14 11:48:55 +00:00
|
|
|
</tr><tr>
|
|
|
|
<th>Channel</th>
|
2011-06-16 03:10:41 +00:00
|
|
|
<td>[epg channelicon [$ts get channel_name] 50 "vertical-align: middle"]
|
|
|
|
[$ts get channel_num] - [$ts get channel_name]</td>
|
2011-06-14 11:48:55 +00:00
|
|
|
</tr><tr>
|
|
|
|
<th>Start Time</th>
|
|
|
|
<td>"
|
2011-06-16 03:10:41 +00:00
|
|
|
puts [clock format [$ts get start] -format "%c %Z"]
|
2011-06-14 11:48:55 +00:00
|
|
|
puts "</td>
|
|
|
|
</tr><tr>
|
|
|
|
<th>End Time</th>
|
|
|
|
<td>"
|
2011-06-16 03:10:41 +00:00
|
|
|
puts [clock format [$ts get end] -format "%c %Z"]
|
2011-06-14 11:48:55 +00:00
|
|
|
puts "</td>
|
|
|
|
</tr><tr>
|
|
|
|
<th>Duration</th>
|
2011-06-16 03:10:41 +00:00
|
|
|
<td>[$ts duration] minute(s).</td>
|
2011-06-14 11:48:55 +00:00
|
|
|
</tr><tr>
|
|
|
|
<th>Size</th>
|
2011-06-16 03:10:41 +00:00
|
|
|
<td>[$ts size] MiB</td>
|
2011-06-14 11:48:55 +00:00
|
|
|
</tr><tr>
|
|
|
|
<th>Flags</th>
|
2011-06-16 03:10:41 +00:00
|
|
|
<td>[$ts get flags]</td>
|
2011-06-14 11:48:55 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
"
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[dict exists $_cgi dir]} {
|
|
|
|
set dir [dict get $_cgi dir]
|
|
|
|
} else {
|
|
|
|
set dir "/media/My Video"
|
|
|
|
}
|
|
|
|
|
|
|
|
source /mod/var/mongoose/html/lib/header.jim
|
|
|
|
|
|
|
|
puts {
|
2011-06-16 03:10:41 +00:00
|
|
|
|
|
|
|
<link href=/css/jquery.contextMenu.css rel=stylesheet type=text/css />
|
|
|
|
<script type="text/javascript" src="/js/jquery.contextMenu.js"></script>
|
|
|
|
|
|
|
|
<ul id=optmenu class=contextMenu>
|
|
|
|
<li><a href=#delete>Delete</a></li>
|
|
|
|
<li><a href=#lock>Toggle Lock</a></li>
|
|
|
|
<li><a href=#rename>Rename</a></li>
|
|
|
|
<li><a href=#title>Change Title</a></li>
|
|
|
|
</ul>
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
<div id=dialogue></div>
|
2011-06-16 03:10:41 +00:00
|
|
|
<div id=confirm title="Confirmation Required"></div>
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
<script type=text/javascript>
|
2011-06-16 03:10:41 +00:00
|
|
|
|
|
|
|
var $confirm = $('#confirm').dialog({
|
|
|
|
modal: true, autoOpen: false,
|
|
|
|
height: 160, width: 500,
|
|
|
|
show: 'fade', hide: 'fade',
|
|
|
|
draggable: false, resizable: false
|
|
|
|
});
|
|
|
|
|
|
|
|
var confirm_action = function(action, callback, ts, id) {
|
|
|
|
var bts = ts.replace(/.*\/|\.[^.]*$/g, '');
|
|
|
|
$confirm.dialog('option', 'buttons', {
|
|
|
|
'Yes': function() { $(this).dialog('close');
|
|
|
|
callback(ts, id); },
|
|
|
|
'No': function() {$(this).dialog('close');}
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
});
|
2011-06-16 03:10:41 +00:00
|
|
|
$('#confirm').empty().html(
|
|
|
|
'Are you sure you wish to ' + action + '<br>' +
|
|
|
|
'<i>' + bts + '</i> ?'
|
|
|
|
);
|
|
|
|
$confirm.dialog('open');
|
|
|
|
}
|
|
|
|
|
|
|
|
var delete_callback = function(ts, id) {
|
|
|
|
var el = 'div.tsfile#' + id;
|
|
|
|
var results = el + ' .results';
|
|
|
|
var url = window.location.pathname + '?tsfile=' +
|
|
|
|
encodeURIComponent(ts) + '&action=delete';
|
|
|
|
$(results).load(url, function() {
|
|
|
|
$(el).delay(3000).slideUp(300, function() {
|
|
|
|
$(el).remove();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var lock_callback = function(ts, id) {
|
|
|
|
var el = 'div.tsfile#' + id;
|
|
|
|
var results = el + ' .results';
|
|
|
|
var url = window.location.pathname + '?tsfile=' +
|
|
|
|
encodeURIComponent(ts) + '&action=';
|
|
|
|
|
|
|
|
$(results).load(url + 'lock', function() {
|
|
|
|
$(results).delay(3000).slideUp(150,
|
|
|
|
function() {
|
|
|
|
$(el).load(url + 'entry');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dialogue init
|
|
|
|
var $dialog = $('#dialogue').dialog({
|
|
|
|
title: "Recording Details",
|
|
|
|
modal: false, autoOpen: false,
|
|
|
|
height: 600, width: 700,
|
|
|
|
show: 'scale', hide: 'fade',
|
|
|
|
draggable: true, resizable: true,
|
|
|
|
buttons: { "Close":
|
|
|
|
function() {$(this).dialog('close');}},
|
|
|
|
close: function(e,u) { $('#dialogue').empty().html(
|
|
|
|
'<img src="/img/loading.gif" alt="loading">'); }
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2011-06-14 11:48:55 +00:00
|
|
|
|
|
|
|
$('a.ts').click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var file = $(this).attr('file');
|
|
|
|
var url = window.location.pathname + '?tsfile=' +
|
|
|
|
encodeURIComponent(file);
|
|
|
|
$('#dialogue').load(url);
|
|
|
|
$dialog.dialog('open');
|
|
|
|
});
|
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
$('img.opt').contextMenu(
|
|
|
|
{
|
|
|
|
menu: 'optmenu',
|
|
|
|
leftButton: true,
|
|
|
|
},
|
|
|
|
function (action, el, pos)
|
|
|
|
{
|
|
|
|
var ts = $(el).parent().prevAll('a.ts').last().attr('file');
|
|
|
|
var did = $(el).attr('did');
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case 'delete':
|
|
|
|
confirm_action('delete', delete_callback, ts, did);
|
|
|
|
break;
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
case 'lock':
|
|
|
|
confirm_action('change the lock on', lock_callback, ts, did);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
alert('Unhandled action: ' + action);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
</script>
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
puts { <div style="border: 1px solid grey; padding: 1em"> }
|
2011-06-16 03:10:41 +00:00
|
|
|
|
|
|
|
# Breadcrumb path
|
2011-06-14 11:48:55 +00:00
|
|
|
puts "<h1>"
|
|
|
|
set stub ""
|
|
|
|
foreach part [split $dir /] {
|
|
|
|
if {$stub eq "/"} { set name $part } else { set name "/$part" }
|
|
|
|
append stub $name
|
|
|
|
puts "<a href=$env(REQUEST_URI)?dir=[cgi_quote_url $stub]>$name</a>
|
|
|
|
}
|
|
|
|
puts "</h1>"
|
|
|
|
|
|
|
|
set parent [join [lrange [split $dir /] 0 end-1] /]
|
|
|
|
if {$parent ne ""} {
|
|
|
|
puts "
|
2011-06-16 03:10:41 +00:00
|
|
|
<div class=va>
|
2011-06-14 11:48:55 +00:00
|
|
|
<a href=$env(REQUEST_URI)?dir=[cgi_quote_url $parent]>
|
2011-06-16 03:10:41 +00:00
|
|
|
<img src=/images/711_3_09_Media_Folder_UP.png class=va>
|
2011-06-14 11:48:55 +00:00
|
|
|
\[parent directory\]</a>
|
|
|
|
</div>
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
|
|
regsub -all -- {\/+} "$dir/*" "/" dir
|
|
|
|
|
|
|
|
foreach file [lsort [glob -nocomplain "$dir"]] {
|
2011-06-16 03:10:41 +00:00
|
|
|
entry $file
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
puts "</div>"
|
|
|
|
|
|
|
|
source /mod/var/mongoose/html/lib/footer.jim
|
|
|
|
|