#!/mod/bin/jimsh package require cgi source /mod/var/mongoose/lib/setup require ts.class pretty_size puts "Content-Type: text/html" puts "" set ignore {.nts .thm .hmt .hmi} set include {.ts .avi .mpg .wmv .mkv} cgi_input #cgi_dump #set env(REQUEST_URI) '' #set _cgi(dir) "/media/My Video/Chuggington" proc directory {file bfile} { regsub -all " +" $bfile "" tbfile puts "
" puts "" puts "" puts "$bfile
" } proc entry {file} {{i 0}} { set bfile [file tail $file] if {[string index $bfile 0] == "\025"} { set bfile [string range $bfile 1 end] } if [file isdirectory "$file"] { directory $file $bfile continue } set ext [file extension $file] if {$ext in $::ignore || $ext ni $::include} { continue } file stat $file st set sz [pretty_size $st(size)] set base [file rootname $file] if {$ext eq ".ts" && [file exists "${base}.nts"]} { set type ts set ts [ts fetch $file 1] set img 741_1_10_Video_Title.png set pad 0 set newpad "top: -6; left: 4;" } else { set type gen set ts 0 set img 743_4_10_Video_Xvid_File.png set pad "2" set newpad "top: -2; left: 2;" } puts "
" 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 } } if {$new} { # Overlay the new image over the media one. puts " " } else { puts " " } puts " $bfile " # Size puts " ($sz) " # Icons set locked 0 if {$type eq "ts"} { # HD / SD if {[$ts get definition] eq "HD"} { set img "172_1_00_HD" } else { set img "172_1_26_SD" } puts "" # Locked if {[$ts flag "Locked"] > 0} { set locked 1 puts "" } # Encrypted if {[$ts flag "Encrypted"] > 0} { puts "" } # Guidance if {[$ts flag "Guidance"] > 0} { puts "" } } # Opt+ button puts "
" puts "
" } if {[dict exists $_cgi dir]} { set dir [dict get $_cgi dir] } else { set dir "/media/My Video" } ###################################################################### # Render web page header puts {
} puts "$dir" # 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 "" puts "" # Parent directory set parent [join [lrange [split $dir /] 0 end-1] /] if {$parent ne ""} { puts "
\[parent directory\]
" } # Strip double slashes regsub -all -- {\/+} "$dir/*" "/" dir foreach file [lsort [glob -nocomplain "$dir"]] { entry $file } puts "
" footer