webif/var/mongoose/html/browse/download.jim
hummypkg 22320536ee browse relocation, system class improvements, safe_delete improvements, auto expire, utf-8, ...
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1420 2a923420-c742-0410-a762-8d5b09965624
2013-02-25 22:31:54 +00:00

44 lines
1.1 KiB
Plaintext
Executable File

#!/mod/bin/jimsh
package require cgi
package require sqlite3
source /mod/webif/lib/setup
require ts.class
set file [cgi_get file]
set urlbase [cgi_get base ""]
# Default to just downloading the raw file.
set url $file
set mime "video/ts"
if {[string match {*.ts} $file]} {
if {![catch {set ts [ts fetch $file]}]} {
# 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 $urlbase]
if {[llength $dlna]} { lassign $dlna url mime }
#puts "DLNA: $dlna"
}
}
}
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]"