#!/mod/bin/jimsh package require cgi source /mod/var/mongoose/lib/ts.class puts "Content-Type: text/html" puts "" set ignore {nts thm hmt hmi} set standard {avi mpg wmv mkv} cgi_input #cgi_dump #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 "
$bfile " if {[$ts get definition] eq "HD"} { puts "" } else { puts "" } if {[$ts flag "Locked"] > 0} { puts "" } puts "
" } proc genfile {file bfile} { puts "
$bfile
" } proc directory {file bfile} { puts "
" puts "" puts "" puts "$bfile
" } 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 } } if {[dict exists $_cgi tsfile]} { set file [dict get $_cgi tsfile] set ts [ts fetch $file] 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 } source /mod/var/mongoose/lib/epg.class puts "
Title [$ts get title]
Synopsis [$ts get synopsis]
Definition " if {[$ts get definition] eq "HD"} { puts "" } else { puts "" } puts "
Channel [epg channelicon [$ts get channel_name] 50 "vertical-align: middle"] [$ts get channel_num] - [$ts get channel_name]
Start Time " puts [clock format [$ts get start] -format "%c %Z"] puts "
End Time " puts [clock format [$ts get end] -format "%c %Z"] puts "
Duration [$ts duration] minute(s).
Size [$ts size] MiB
Flags [$ts get flags]
" 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 {
} puts {
} # Breadcrumb path puts "

" set stub "" foreach part [split $dir /] { if {$stub eq "/"} { set name $part } else { set name "/$part" } append stub $name puts "$name } puts "

" set parent [join [lrange [split $dir /] 0 end-1] /] if {$parent ne ""} { puts "
\[parent directory\]
" } regsub -all -- {\/+} "$dir/*" "/" dir foreach file [lsort [glob -nocomplain "$dir"]] { entry $file } puts "
" source /mod/var/mongoose/html/lib/footer.jim