2011-08-13 00:18:12 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
|
|
|
package require sqlite3
|
|
|
|
source /mod/var/mongoose/lib/setup
|
|
|
|
require ts.class
|
|
|
|
|
2011-08-20 20:45:23 +00:00
|
|
|
#puts "Content-Type: text/plain\r\n\r\n"
|
|
|
|
|
2011-08-13 00:18:12 +00:00
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
2011-11-06 16:34:30 +00:00
|
|
|
set file [cgi_get file]
|
2011-08-13 00:18:12 +00:00
|
|
|
|
2011-10-11 19:51:58 +00:00
|
|
|
# Default to just downloading the raw file.
|
2011-08-13 00:18:12 +00:00
|
|
|
set url $file
|
|
|
|
set mime "video/ts"
|
2011-10-11 19:51:58 +00:00
|
|
|
|
2011-12-09 20:33:57 +00:00
|
|
|
if {[string match {*.ts} $file]} {
|
|
|
|
if {![catch {set ts [ts fetch $file]}]} {
|
2011-10-11 19:51:58 +00:00
|
|
|
|
2011-12-09 20:33:57 +00:00
|
|
|
# If it's encrypted on disk and the DLNA option is available,
|
|
|
|
# then use the server to perform decryption on the fly.
|
|
|
|
if {[$ts flag "ODEncrypted"] > 0} {
|
|
|
|
set dlna [$ts dlnaloc]
|
|
|
|
if {[llength $dlna]} { lassign $dlna url mime }
|
|
|
|
|
|
|
|
#puts "DLNA: $dlna"
|
|
|
|
}
|
|
|
|
}
|
2011-11-06 16:34:30 +00:00
|
|
|
}
|
2011-08-13 00:18:12 +00:00
|
|
|
|
|
|
|
puts "Content-Type: text/plain"
|
|
|
|
puts "Refresh: 0; url=$url"
|
|
|
|
puts "Content-length: 0"
|
|
|
|
puts ""
|
|
|
|
|
|
|
|
#puts "Pragma: public"
|
|
|
|
#puts "Expires: 0"
|
|
|
|
#puts "Cache-Control: must-revalidate, post-check=0, pre-check=0"
|
|
|
|
#puts "Content-Type: application/force-download"
|
|
|
|
#puts "Content-Type: application/download"
|
|
|
|
#puts "Content-Type: $mime"
|
|
|
|
#puts "Content-Disposition: attachment; filename=\"[file tail $file]\""
|
|
|
|
#puts "Content-Transfer-Encoding: binary"
|
|
|
|
#puts "Content-Length: [file size $rfile]"
|
|
|
|
|