2011-06-14 11:48:55 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
2011-07-01 22:56:53 +00:00
|
|
|
source /mod/var/mongoose/lib/setup
|
2011-12-06 00:13:41 +00:00
|
|
|
require ts.class pretty_size system.class settings.class
|
2011-06-14 11:48:55 +00:00
|
|
|
|
|
|
|
puts "Content-Type: text/html"
|
|
|
|
puts ""
|
|
|
|
|
2011-11-28 15:24:38 +00:00
|
|
|
set nicesplice [system pkginst nicesplice]
|
|
|
|
|
2011-06-16 23:49:48 +00:00
|
|
|
set ignore {.nts .thm .hmt .hmi}
|
2011-07-07 22:33:19 +00:00
|
|
|
set include {.ts .avi .mpg .mpeg .wmv .mkv .mp3 .mp4 .mov}
|
2011-06-16 03:10:41 +00:00
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
#set env(REQUEST_URI) ''
|
2011-12-05 21:44:30 +00:00
|
|
|
#set _cgi(dir) "/media/My Video/\[Don't Die Young\]"
|
2011-06-16 03:10:41 +00:00
|
|
|
|
2011-12-06 00:13:41 +00:00
|
|
|
if {![dict exists $env QUERY_STRING]} { set env(QUERY_STRING) "root" }
|
|
|
|
|
|
|
|
set order [cgi_get order -]
|
|
|
|
if {$order eq "-"} {
|
|
|
|
set order [[settings new] sortorder]
|
|
|
|
} else {
|
|
|
|
[settings new] sortorder $order
|
|
|
|
}
|
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
proc directory {file bfile} {
|
2011-06-29 23:53:16 +00:00
|
|
|
regsub -all " +" $bfile "" tbfile
|
2011-06-16 03:10:41 +00:00
|
|
|
puts "<div class=va>"
|
2011-06-29 23:53:16 +00:00
|
|
|
puts "<img border=0 class=va id=\"img$tbfile\"
|
|
|
|
src=/images/711_1_09_Media_Folder.png>"
|
2011-12-05 21:44:30 +00:00
|
|
|
puts "<input class=\"fs fsdir\" type=checkbox>"
|
|
|
|
puts "<a href=\"$::env(REQUEST_URI)?dir=[cgi_quote_url $file]\"
|
|
|
|
file=\"$file\">"
|
2011-06-25 20:59:50 +00:00
|
|
|
puts "$bfile</a><span class=filesize id=\"$tbfile\">
|
|
|
|
</span></div>"
|
2011-06-16 03:10:41 +00:00
|
|
|
}
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
proc entry {file} {{i 0}} {
|
|
|
|
set bfile [file tail $file]
|
2011-06-16 03:10:41 +00:00
|
|
|
if {[string index $bfile 0] == "\025"} {
|
|
|
|
set bfile [string range $bfile 1 end]
|
|
|
|
}
|
|
|
|
if [file isdirectory "$file"] {
|
|
|
|
directory $file $bfile
|
|
|
|
continue
|
|
|
|
}
|
2011-06-16 23:49:48 +00:00
|
|
|
set ext [file extension $file]
|
2011-06-22 23:36:30 +00:00
|
|
|
if {$ext in $::ignore || $ext ni $::include} { continue }
|
|
|
|
|
2011-06-25 20:59:50 +00:00
|
|
|
file stat $file st
|
|
|
|
set sz [pretty_size $st(size)]
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
set base [file rootname $file]
|
|
|
|
|
|
|
|
if {$ext eq ".ts" && [file exists "${base}.nts"]} {
|
|
|
|
set type ts
|
2011-06-25 20:59:50 +00:00
|
|
|
set ts [ts fetch $file 1]
|
2011-07-08 20:39:57 +00:00
|
|
|
set img Video_TS
|
2011-06-22 23:36:30 +00:00
|
|
|
} else {
|
|
|
|
set type gen
|
|
|
|
set ts 0
|
2011-07-08 20:39:57 +00:00
|
|
|
set img Video_Other
|
2011-06-16 03:10:41 +00:00
|
|
|
}
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-27 19:57:32 +00:00
|
|
|
set new 0
|
|
|
|
if {$type eq "ts"} {
|
|
|
|
if {[$ts flag "New"] > 0} { set new 1 }
|
|
|
|
} else {
|
|
|
|
if {![file exists "[file rootname $file].hmi"]} { set new 1 }
|
|
|
|
}
|
|
|
|
|
2011-07-08 20:39:57 +00:00
|
|
|
if {$new} { append img _New }
|
|
|
|
|
2011-11-27 23:29:14 +00:00
|
|
|
set fscl "fs"
|
|
|
|
if {$type eq "ts"} {
|
|
|
|
set fscl "fs fsts"
|
|
|
|
}
|
2011-06-27 19:57:32 +00:00
|
|
|
|
|
|
|
puts "
|
2011-11-27 23:29:14 +00:00
|
|
|
<div class=\"va bf\" id=[incr i]>
|
|
|
|
<img class=va border=0 src=/img/$img.png>
|
|
|
|
<input class=\"$fscl\" type=checkbox>
|
|
|
|
<a class=bf file=\"$file\" type=$type href=#>
|
|
|
|
$bfile
|
|
|
|
</a>
|
2011-06-22 23:36:30 +00:00
|
|
|
"
|
|
|
|
|
2011-06-25 20:59:50 +00:00
|
|
|
# Size
|
|
|
|
puts "<span class=filesize> ($sz) </span>"
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
# Icons
|
|
|
|
|
|
|
|
set locked 0
|
2011-11-12 11:12:07 +00:00
|
|
|
set encd 0
|
|
|
|
set odencd 1
|
2011-07-08 20:39:57 +00:00
|
|
|
set def unknown
|
2011-11-03 23:43:17 +00:00
|
|
|
set bx 0
|
2011-06-22 23:36:30 +00:00
|
|
|
if {$type eq "ts"} {
|
|
|
|
# HD / SD
|
|
|
|
if {[$ts get definition] eq "HD"} {
|
2011-07-08 20:39:57 +00:00
|
|
|
set def HD
|
2011-06-22 23:36:30 +00:00
|
|
|
set img "172_1_00_HD"
|
|
|
|
} else {
|
2011-07-08 20:39:57 +00:00
|
|
|
set def SD
|
2011-06-22 23:36:30 +00:00
|
|
|
set img "172_1_26_SD"
|
|
|
|
}
|
|
|
|
puts "<img class=va src=/images/$img.png height=21>"
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
# Locked
|
|
|
|
if {[$ts flag "Locked"] > 0} {
|
|
|
|
set locked 1
|
|
|
|
puts "<img class=va src=/images/178_1_00_Icon_Lock.png
|
|
|
|
height=21>"
|
2011-06-16 03:10:41 +00:00
|
|
|
}
|
2011-06-27 19:57:32 +00:00
|
|
|
|
|
|
|
# Encrypted
|
|
|
|
if {[$ts flag "Encrypted"] > 0} {
|
2011-07-08 20:39:57 +00:00
|
|
|
set encd 1
|
2011-06-27 19:57:32 +00:00
|
|
|
puts "<img class=va
|
|
|
|
src=/images/749_1_26_Video_Encryption.png
|
|
|
|
height=21>"
|
|
|
|
}
|
2011-11-06 16:34:30 +00:00
|
|
|
if {![$ts flag "ODEncrypted"]} {
|
2011-11-04 01:16:07 +00:00
|
|
|
puts "<img class=va src=/img/Decrypted.png height=21>"
|
2011-11-06 16:34:30 +00:00
|
|
|
set odencd 0
|
2011-11-04 00:55:13 +00:00
|
|
|
}
|
2011-06-27 19:57:32 +00:00
|
|
|
|
|
|
|
# Guidance
|
|
|
|
if {[$ts flag "Guidance"] > 0} {
|
|
|
|
puts "<img class=va
|
|
|
|
src=/images/174_1_26_GuidancePolicy.png
|
|
|
|
height=21>"
|
|
|
|
}
|
2011-11-03 23:43:17 +00:00
|
|
|
|
|
|
|
set bx [$ts get bookmarks]
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
2011-06-16 03:10:41 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
# Opt+ button
|
2011-06-16 03:10:41 +00:00
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
puts "
|
2011-06-22 23:36:30 +00:00
|
|
|
<a href=#>
|
|
|
|
<img class=\"opt va\" border=0 width=45 type=$type did=$i
|
2011-11-03 23:43:17 +00:00
|
|
|
locked=$locked encd=$encd def=$def new=$new bx=$bx
|
2011-11-04 00:55:13 +00:00
|
|
|
odencd=$odencd
|
2011-06-22 23:36:30 +00:00
|
|
|
src=/images/181_1_00_Help5_OPT_Plus.png>
|
|
|
|
</a>
|
|
|
|
<div class=\"results blood\" style=\"margin: 0 0 0 5em\"></div>
|
2011-06-14 11:48:55 +00:00
|
|
|
"
|
2011-06-22 23:36:30 +00:00
|
|
|
puts "</div>"
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
|
|
|
|
2011-11-03 23:43:17 +00:00
|
|
|
set dir [cgi_get dir [system mediaroot]]
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
######################################################################
|
|
|
|
# Render web page
|
2011-06-16 23:49:48 +00:00
|
|
|
|
2011-07-01 22:56:53 +00:00
|
|
|
header
|
2011-06-16 03:10:41 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
puts {
|
|
|
|
<link href=/css/jquery.contextMenu.css rel=stylesheet type=text/css />
|
|
|
|
<script type="text/javascript" src="/js/jquery.contextMenu.js"></script>
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
<ul id=optmenu class=contextMenu>
|
2011-11-03 23:43:17 +00:00
|
|
|
<li class=delete><a href=#delete>Delete</a></li>
|
2011-06-22 23:36:30 +00:00
|
|
|
<li><a href=#lock>Toggle Lock</a></li>
|
2011-07-08 20:39:57 +00:00
|
|
|
<li><a href=#enc>Toggle Enc</a></li>
|
|
|
|
<li><a href=#new>Toggle New</a></li>
|
2011-06-22 23:36:30 +00:00
|
|
|
<li><a href=#rename>Rename</a></li>
|
|
|
|
<li><a href=#download>Download</a></li>
|
2011-11-03 23:43:17 +00:00
|
|
|
}
|
2011-11-04 00:55:13 +00:00
|
|
|
if {[system model] eq "HDR"} {
|
|
|
|
puts { <li class="separator"><a href=#decrypt>Decrypt</a></li> }
|
|
|
|
}
|
2011-11-28 15:24:38 +00:00
|
|
|
if $nicesplice {
|
2011-11-03 23:43:17 +00:00
|
|
|
puts { <li class="cut separator"><a href=#crop>Crop</a></li> }
|
|
|
|
}
|
|
|
|
puts {
|
2011-06-22 23:36:30 +00:00
|
|
|
</ul>
|
2011-06-16 23:49:48 +00:00
|
|
|
|
2011-06-25 20:59:50 +00:00
|
|
|
<div id=renameform title="Rename media file" style="display: none">
|
|
|
|
<form id=renameform_form>
|
|
|
|
<input type=hidden name="renameorig" id="renameorig" value="">
|
|
|
|
<input type=hidden name="titleorig" id="titleorig" value="">
|
|
|
|
<table border=0>
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
<label for="rename">
|
|
|
|
<b>New Filename</b>
|
|
|
|
</label>
|
|
|
|
</th>
|
|
|
|
<td>
|
|
|
|
<input type=text name="rename" id="rename"
|
|
|
|
value="" size=70 maxlength=255
|
|
|
|
class="text ui-widget-content ui-corner-all">
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr style="display: none" class=tstype>
|
|
|
|
<th>
|
|
|
|
<label for="renametitle" style="padding-top: 0.5em">
|
2011-12-06 00:13:41 +00:00
|
|
|
<b>New Medialist Title</b>
|
2011-06-25 20:59:50 +00:00
|
|
|
</label>
|
|
|
|
</th>
|
|
|
|
<td>
|
|
|
|
<input type=text name="renametitle" id="renametitle"
|
2011-06-26 23:05:38 +00:00
|
|
|
value="" size=70 maxlength=48
|
2011-06-25 20:59:50 +00:00
|
|
|
class="text ui-widget-content ui-corner-all">
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr style="display: none" class=tstype>
|
|
|
|
<td colspan=2 id=synopsis style="font-style: italic"></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
2011-10-03 22:47:44 +00:00
|
|
|
<div id=savestreamform title="Save streamed content"
|
|
|
|
style="display: none">
|
|
|
|
<div class=pre id=savestream_detail></div>
|
|
|
|
<form id=savestream_form>
|
|
|
|
}
|
|
|
|
puts "<input type=hidden name=dir value=\"$dir\">"
|
|
|
|
puts {
|
|
|
|
<table border=0>
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
<label for="savestream_name">
|
|
|
|
<b>Filename</b>
|
|
|
|
</label>
|
|
|
|
</th>
|
|
|
|
<td>
|
|
|
|
<input type=text name="savestream_name"
|
|
|
|
id="savestream_name"
|
|
|
|
value="" size=70 maxlength=255
|
|
|
|
class="text ui-widget-content ui-corner-all">
|
|
|
|
<img id=savestream_spin src=/img/loading.gif>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
<div id=dialogue></div>
|
|
|
|
<div id=confirm title="Confirmation Required"></div>
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
<script type=text/javascript src=/cgi-bin/browse/browse.js></script>
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
|
|
|
|
2011-06-25 20:59:50 +00:00
|
|
|
puts "<span style=\"display:none\" id=dir>$dir</span>"
|
|
|
|
|
2011-06-16 03:10:41 +00:00
|
|
|
# Breadcrumb path
|
2011-06-25 20:59:50 +00:00
|
|
|
puts "
|
|
|
|
<fieldset style=\"margin: 1em\">
|
|
|
|
<legend style=\"font-size: 1.5em; padding: 0 0.5em 0.5em 0.5em;\">
|
|
|
|
"
|
2011-06-14 11:48:55 +00:00
|
|
|
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>
|
|
|
|
}
|
2011-06-27 21:59:07 +00:00
|
|
|
puts "<span class=filesize id=dirsize></span>"
|
2011-06-25 20:59:50 +00:00
|
|
|
puts "</legend>"
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
# Parent directory
|
2011-06-14 11:48:55 +00:00
|
|
|
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-07-07 22:33:19 +00:00
|
|
|
<img border=0 src=/images/711_3_09_Media_Folder_UP.png class=va>
|
2011-06-14 11:48:55 +00:00
|
|
|
\[parent directory\]</a>
|
|
|
|
</div>
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
2011-06-22 23:36:30 +00:00
|
|
|
# Strip double slashes
|
2011-06-14 11:48:55 +00:00
|
|
|
regsub -all -- {\/+} "$dir/*" "/" dir
|
|
|
|
|
2011-12-05 21:44:30 +00:00
|
|
|
# Escape square brackets (for glob)
|
|
|
|
regsub -all {([\\[])} $dir {\\\1} dir
|
|
|
|
|
2011-12-06 00:13:41 +00:00
|
|
|
proc s_time {a b} {
|
|
|
|
set ad [file isdirectory $a]
|
|
|
|
set bd [file isdirectory $b]
|
|
|
|
|
|
|
|
if {$ad && !$bd} { return -1 }
|
|
|
|
if {$bd && !$ad} { return 1 }
|
|
|
|
if {$ad && $bd} {
|
|
|
|
if {$a < $b} { return -1 }
|
|
|
|
if {$a > $b} { return 1 }
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
file stat $a l
|
|
|
|
set at $l(ctime)
|
|
|
|
file stat $b l
|
|
|
|
set bt $l(ctime)
|
|
|
|
|
|
|
|
if {$at < $bt} { return -1 }
|
|
|
|
if {$at > $bt} { return 1 }
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
set files [glob -nocomplain $dir]
|
|
|
|
switch $order {
|
|
|
|
1 { set files [lsort -command s_time $files] }
|
|
|
|
default { set files [lsort $files] }
|
2011-06-14 11:48:55 +00:00
|
|
|
}
|
|
|
|
|
2011-12-06 00:13:41 +00:00
|
|
|
foreach file $files { entry $file }
|
|
|
|
|
2011-12-05 21:44:30 +00:00
|
|
|
puts "<a href=# id=selectall>Select all</a> | <a href=# id=deselectall>none</a>"
|
2011-11-28 15:24:38 +00:00
|
|
|
|
2011-12-06 00:13:41 +00:00
|
|
|
# Sort icons
|
|
|
|
puts "<div id=sortdiv>"
|
|
|
|
set sortlist {{0 sort_name name} {1 sort_date date}}
|
|
|
|
foreach sl $sortlist {
|
|
|
|
lassign $sl index img descr
|
|
|
|
|
|
|
|
if {$index} { puts " | " }
|
|
|
|
|
|
|
|
set tag "Currently sorting"
|
|
|
|
if {$order != $index} {
|
|
|
|
puts "
|
|
|
|
<a href=$env(REQUEST_URI)?$env(QUERY_STRING)&order=$index>"
|
|
|
|
set tag "Sort"
|
|
|
|
}
|
|
|
|
puts "<img class=va border=0 src=/img/$img.gif> $tag by $descr"
|
|
|
|
if {$order != $index} {
|
|
|
|
puts "</a>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
puts "</div>"
|
|
|
|
|
2011-06-25 20:59:50 +00:00
|
|
|
puts "</fieldset>"
|
2011-06-14 11:48:55 +00:00
|
|
|
|
2011-11-28 15:24:38 +00:00
|
|
|
puts "<div class=brow>"
|
2011-10-03 22:47:44 +00:00
|
|
|
|
|
|
|
puts {
|
2011-11-28 15:24:38 +00:00
|
|
|
<button id=delete>Delete</button>
|
2011-12-05 21:44:30 +00:00
|
|
|
<div id=deletewait class=blood style="display: none">
|
|
|
|
<img src=/img/loading.gif>Deleting may take some time, please be patient...
|
|
|
|
</div>
|
2011-10-03 22:47:44 +00:00
|
|
|
}
|
|
|
|
|
2011-11-27 23:29:14 +00:00
|
|
|
# Join
|
2011-11-28 15:24:38 +00:00
|
|
|
if $nicesplice {
|
2011-11-27 23:29:14 +00:00
|
|
|
puts { <button id=join>Join</button> }
|
|
|
|
}
|
|
|
|
|
2011-11-28 15:24:38 +00:00
|
|
|
puts "</div><div class=brow style=\"margin-top: 3px\">"
|
|
|
|
|
|
|
|
# De-duplicate
|
|
|
|
|
|
|
|
puts {
|
|
|
|
<button id=dedup>De-duplicate/tidy this folder</button>
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:47:44 +00:00
|
|
|
# Streamer file
|
|
|
|
|
|
|
|
if {[file exists /mnt/hd3/Streamer_down_file]} {
|
2011-11-28 15:24:38 +00:00
|
|
|
puts {
|
|
|
|
<button id=save_stream file=/mnt/hd3/Streamer_down_file>
|
|
|
|
Save last streamed content (e.g. iPlayer/YouTube)
|
|
|
|
</button>
|
|
|
|
}
|
2011-10-03 22:47:44 +00:00
|
|
|
}
|
|
|
|
|
2011-11-28 15:24:38 +00:00
|
|
|
puts "</div>"
|
|
|
|
|
2011-07-01 22:56:53 +00:00
|
|
|
footer
|
2011-06-14 11:48:55 +00:00
|
|
|
|