2011-11-04 00:55:13 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require sqlite3
|
|
|
|
package require cgi
|
|
|
|
source /mod/var/mongoose/lib/setup
|
|
|
|
require ts.class
|
|
|
|
|
|
|
|
puts "Content-Type: text/html\r\n\r\n"
|
|
|
|
|
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
2011-12-09 20:33:57 +00:00
|
|
|
set rfile [cgi_get file]
|
2011-11-04 00:55:13 +00:00
|
|
|
set ts [ts fetch $rfile]
|
|
|
|
set dir [file dirname $rfile]
|
|
|
|
set len [$ts duration 1]
|
|
|
|
lassign [$ts dlnaloc] url
|
|
|
|
|
|
|
|
if {[cgi_get do] eq "it"} {
|
2011-12-09 20:33:57 +00:00
|
|
|
set xstart [clock milliseconds]
|
2011-11-12 11:12:07 +00:00
|
|
|
|
2011-11-04 00:55:13 +00:00
|
|
|
set base [file rootname $rfile]
|
|
|
|
set origdir "$dir/_original"
|
|
|
|
if {![file exists $origdir]} { file mkdir $origdir }
|
|
|
|
|
|
|
|
set shname [file tail $base]
|
|
|
|
puts "Processing $shname"
|
|
|
|
|
|
|
|
exec wget -O "$rfile.decrypting" $url
|
|
|
|
|
|
|
|
puts "Moving recording to $origdir"
|
|
|
|
|
|
|
|
foreach f [glob -nocomplain "${base}.*"] {
|
|
|
|
if {[file extension $f] eq ".decrypting"} { continue }
|
|
|
|
set tail [file tail $f]
|
|
|
|
puts " $tail"
|
|
|
|
file rename $f "${origdir}/$tail"
|
|
|
|
}
|
|
|
|
|
|
|
|
file rename "$rfile.decrypting" $rfile
|
|
|
|
|
|
|
|
foreach ext {nts hmt thm} {
|
|
|
|
set sidecar "$shname.$ext"
|
|
|
|
if {[file exists "$origdir/$sidecar"]} {
|
|
|
|
puts "Copying back sidecar $ext"
|
|
|
|
file copy "$origdir/$sidecar" "$dir/$sidecar"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[file exists "$dir/$shname.hmt"]} {
|
|
|
|
exec /mod/bin/hmt -encrypted "$dir/$shname.hmt"
|
|
|
|
}
|
|
|
|
|
2011-12-09 20:33:57 +00:00
|
|
|
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
|
|
|
|
puts "Time taken: $xtime"
|
|
|
|
|
2011-11-04 00:55:13 +00:00
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
header
|
|
|
|
|
|
|
|
puts "
|
|
|
|
<link href=/css/jquery.progressbar.css rel=stylesheet type=text/css />
|
|
|
|
<script type=\"text/javascript\" src=\"/js/jquery.progressbar.js\"></script>
|
|
|
|
|
|
|
|
<table class=keyval cellpadding=5>
|
|
|
|
<tr><th>File:</th><td>$rfile</td></tr>
|
|
|
|
<tr><th>Length:</th><td>[clock format $len -format "%T"]</td></tr>
|
|
|
|
<tr><th>DLNA URL</th><td>$url</td></tr>
|
|
|
|
</table>
|
|
|
|
"
|
|
|
|
|
|
|
|
if {$url eq ""} {
|
|
|
|
puts "This file has not been indexed by the media server.
|
|
|
|
Cannot decrypt."
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
puts {
|
|
|
|
|
|
|
|
<div style="margin-top: 10px"></div>
|
|
|
|
<div id=decryptdiv><button id=decryptit>Perform decryption</button></div>
|
|
|
|
<div id=progressdiv style="display: none">
|
|
|
|
Decrypting: <div id=progressbar></div>
|
|
|
|
}
|
|
|
|
puts "<button id=back
|
|
|
|
dir=\"[cgi_quote_url $dir]\"
|
|
|
|
rfile=\"[cgi_quote_url $rfile]\"
|
|
|
|
style=\"display: none\">Back to media list</button>"
|
|
|
|
puts {
|
|
|
|
<div id=output class=pre style="margin-top: 10px"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type=text/javascript>
|
|
|
|
|
|
|
|
var handle = 0;
|
|
|
|
|
|
|
|
function update()
|
|
|
|
{
|
|
|
|
$.get('/cgi-bin/browse/decrypt_progress.jim?file='
|
|
|
|
+ $('#back').attr('rfile'), function(data) {
|
|
|
|
if (handle)
|
|
|
|
$('#progressbar').reportprogress(data);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
$('#progressbar').reportprogress(0);
|
|
|
|
|
|
|
|
$('#back').button().click(function() {
|
|
|
|
window.location = '/cgi-bin/browse.jim?dir=' + $(this).attr('dir');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#decryptit').button().click(function() {
|
|
|
|
$('#decryptdiv').hide('slow');
|
|
|
|
$('#progressdiv').show('slow');
|
|
|
|
handle = setInterval("update()", 1000);
|
|
|
|
$('#output').load(document.URL + '&do=it', function() {
|
|
|
|
clearInterval(handle);
|
|
|
|
handle = 0;
|
|
|
|
$('#back').show();
|
|
|
|
$('#progressbar').reportprogress(100);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
}
|
|
|
|
|