forked from hummypkg/webif
Enable decryption for HD model and in the absence of a DLNA server.
Support decryption via dropdown menu for files not yet indexed.
This commit is contained in:
parent
c15859ed30
commit
5d03bedfac
|
@ -1,10 +1,10 @@
|
|||
Package: webif
|
||||
Priority: optional
|
||||
Section: web
|
||||
Version: 1.4.3
|
||||
Version: 1.4.3-2
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hpkg.tv
|
||||
Depends: tcpfix,webif-channelicons(>=1.1.26),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.77),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.8),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.11),webif-charts(>=1.2-1),stripts(>=1.4.0),tmenu(>=1.21-2),ffmpeg(>=2.8),id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.95),sqlite3(>=3.15.1),jim-xconv
|
||||
Depends: tcpfix,webif-channelicons(>=1.1.26),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.77),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.8),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.11),webif-charts(>=1.2-1),stripts(>=1.4.1),tmenu(>=1.21-2),ffmpeg(>=2.8),id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.98),sqlite3(>=3.15.1),jim-xconv
|
||||
Suggests:
|
||||
Description: An evolving web interface for the Humax.
|
||||
Tags: https://hummy.tv/forum/threads/7712/
|
||||
|
|
|
@ -12,12 +12,8 @@ puts {
|
|||
<li class="separator rename"><a href=#rename>Rename</a></li>
|
||||
<li class=download><a href=#download>Download</a></li>
|
||||
|
||||
}
|
||||
if {$model eq "HDR"} {
|
||||
puts { <li class="separator decrypt"><a href=#decrypt>Decrypt</a></li> }
|
||||
puts { <li class="compress"><a href=#strip>Shrink</a></li> }
|
||||
} else {
|
||||
puts { <li class="compress separator"><a href=#strip>Shrink</a></li> }
|
||||
<li class="separator decrypt"><a href=#decrypt>Decrypt</a></li>
|
||||
<li class="compress"><a href=#strip>Shrink</a></li>
|
||||
}
|
||||
if {[system pkginst ffmpeg]} {
|
||||
puts {
|
||||
|
@ -88,16 +84,8 @@ puts {
|
|||
<li class="separator compress"><a href=#shrink>Auto-Shrink</a></li>
|
||||
<li class=compressr><a href=#shrinkr>Recursive Auto-Shrink</a></li>
|
||||
<li class=dedup><a href=#dedup>Auto-Dedup</a></li>
|
||||
}
|
||||
if {$model eq "HDR"} {
|
||||
puts {
|
||||
<li class=decrypt><a href=#decrypt>Auto-Decrypt</a></li>
|
||||
<li class=decryptr><a href=#decryptr>Recursive Auto-Decrypt
|
||||
</a></li>
|
||||
}
|
||||
}
|
||||
|
||||
puts {
|
||||
<li class=decrypt><a href=#decrypt>Auto-Decrypt</a></li>
|
||||
<li class=decryptr><a href=#decryptr>Recursive Auto-Decrypt</a></li>
|
||||
<li class=clock><a href=#expire>Auto-Expire Options</a></li>
|
||||
}
|
||||
|
||||
|
|
|
@ -3,64 +3,67 @@
|
|||
package require sqlite3
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require ts.class
|
||||
require ts.class system.class
|
||||
|
||||
jqplugin progressbar
|
||||
jscss decrypt.js
|
||||
header
|
||||
|
||||
set mode "dlna"
|
||||
if {[system model] eq "HD"} { set mode "direct" }
|
||||
|
||||
set rfile [cgi_get file]
|
||||
set ts [ts fetch $rfile]
|
||||
set dir [file dirname $rfile]
|
||||
set len [$ts duration 1]
|
||||
lassign [$ts dlnaloc "127.0.0.1"] url
|
||||
|
||||
if {$mode eq "dlna"} {
|
||||
if {![system is_listening 9000]} {
|
||||
puts {
|
||||
<div id=sysnotify class=warningbox style="width: 90%"><center>
|
||||
The Humax media server is not running.<br>
|
||||
Decryption will not use hardware acceleration.<br>
|
||||
Have you enabled <i>Content Sharing</i> in the Humax menus?<br>
|
||||
</center></div>
|
||||
}
|
||||
set mode "direct"
|
||||
}
|
||||
}
|
||||
|
||||
if {$mode eq "dlna"} {
|
||||
set method "Hardware accelerated (via DLNA)"
|
||||
} else {
|
||||
set method "Directly without hardware acceleration"
|
||||
}
|
||||
|
||||
puts "
|
||||
|
||||
<fieldset class=cleft>
|
||||
<legend>Decrypt in-place</legend>
|
||||
|
||||
<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>
|
||||
<tr><th>Decryption method:</th><td>$method</td></tr>
|
||||
</table>
|
||||
"
|
||||
|
||||
if {$url eq ""} {
|
||||
puts "This file has not been indexed by the media server.
|
||||
Cannot decrypt."
|
||||
puts "Have you enabled <i>Content Sharing</i> in the Humax menus?"
|
||||
exit
|
||||
}
|
||||
|
||||
if {![system is_listening 9000]} {
|
||||
puts "The Humax media server is not running, cannot decrypt."
|
||||
puts "Have you enabled <i>Content Sharing</i> in the Humax menus?"
|
||||
puts "It can sometimes turn itself off so it's worth double checking."
|
||||
puts "If it is on then try turning sharing off and on again."
|
||||
exit
|
||||
}
|
||||
|
||||
puts "
|
||||
|
||||
<span class=hidden id=params
|
||||
dir=\"[cgi_quote_url $dir]\"
|
||||
file=\"[cgi_quote_url $rfile]\"
|
||||
mode=\"$mode\"
|
||||
></span>
|
||||
|
||||
<div id=decryptdiv style=\"padding: 1em\">
|
||||
<div style=\"padding: 1em\">
|
||||
<span id=decryptdiv>
|
||||
<button id=decryptit>Perform decryption</button>
|
||||
</div>
|
||||
</span>
|
||||
<button id=back>Back to media list</button>
|
||||
</div>
|
||||
|
||||
<div id=progressdiv class=hidden>
|
||||
Decrypting: <div id=progressbar></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id=output class=pre style=\"margin-top: 10px\"></div>
|
||||
<div id=output class=\"hidden pre\" style=\"margin-top: 10px\"></div>
|
||||
</fieldset>
|
||||
|
||||
"
|
||||
|
||||
|
|
|
@ -3,14 +3,15 @@ var handle = 0;
|
|||
|
||||
function update()
|
||||
{
|
||||
$.get('progress.jim?file=' + $('#params').attr('file'),
|
||||
$.get('progress.jim?file=' + $('#params').attr('file') +
|
||||
'&mode=' + $('#params').attr('mode'),
|
||||
function(data) {
|
||||
if (handle)
|
||||
$('#progressbar').reportprogress(data);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(function() {
|
||||
|
||||
$('#progressbar').reportprogress(0);
|
||||
|
||||
|
@ -23,7 +24,10 @@ $('#decryptit').button().click(function() {
|
|||
$('#progressdiv').show('slow');
|
||||
$('#back').hide();
|
||||
handle = setInterval("update()", 1000);
|
||||
$('#output').load('execute.jim?file=' + $('#params').attr('file'),
|
||||
$('#output')
|
||||
.show()
|
||||
.load('execute.jim?file=' + $('#params').attr('file') +
|
||||
'&mode=' + $('#params').attr('mode'),
|
||||
function() {
|
||||
clearInterval(handle);
|
||||
handle = 0;
|
||||
|
|
|
@ -8,15 +8,32 @@ require ts.class system.class
|
|||
httpheader
|
||||
|
||||
set rfile [cgi_get file]
|
||||
set mode [cgi_get mode dlna]
|
||||
set ts [ts fetch $rfile]
|
||||
set dir [file dirname $rfile]
|
||||
set len [$ts duration 1]
|
||||
lassign [$ts dlnaloc "127.0.0.1"] url
|
||||
|
||||
if {$url eq ""} {
|
||||
puts "This file has not been indexed by the media server.
|
||||
Cannot decrypt."
|
||||
exit
|
||||
if {$mode eq "dlna"} {
|
||||
lassign [$ts dlnaloc "127.0.0.1"] url
|
||||
if {$url ne ""} {
|
||||
# File is indexed
|
||||
set helper 0
|
||||
} else {
|
||||
if {[catch {
|
||||
lassign [system dlnahelper [\
|
||||
file normalize $rfile]] url
|
||||
} msg]} {
|
||||
puts "Error: Cannot obtain DLNA access to file."
|
||||
exit
|
||||
}
|
||||
set helper 1
|
||||
}
|
||||
|
||||
if {$url eq ""} {
|
||||
puts "This file has not been indexed by the media server.
|
||||
Cannot decrypt."
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
if {[system inuse $rfile]} {
|
||||
|
@ -32,39 +49,53 @@ if {![file exists $origdir]} { file mkdir $origdir }
|
|||
|
||||
set shname [file tail $base]
|
||||
puts "Processing $shname"
|
||||
|
||||
if {[file exists "$origdir/$shname.ts"]} {
|
||||
puts "The file already exists in _original, cannot decrypt."
|
||||
exit
|
||||
}
|
||||
flush stdout
|
||||
|
||||
set token [system startop -multiple decrypt $rfile]
|
||||
exec wget -O "$rfile.decrypting" $url
|
||||
system endop $token
|
||||
set err 0
|
||||
if {$mode eq "dlna"} {
|
||||
if {[catch {exec wget -O "$rfile.decrypting" $url} msg opts]} {
|
||||
puts "Wget error - $msg - $opts"
|
||||
incr err
|
||||
}
|
||||
|
||||
puts "Moving recording to $origdir"
|
||||
|
||||
set tail [file tail $base]
|
||||
foreach ext $tsgroup {
|
||||
if {![file exists "$base.$ext"]} continue
|
||||
puts " $tail.$ext"
|
||||
file rename "$base.$ext" "${origdir}/$tail.$ext"
|
||||
}
|
||||
|
||||
file rename "$rfile.decrypting" $rfile
|
||||
file touch $rfile "$origdir/$tail.ts"
|
||||
|
||||
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"
|
||||
file touch "$dir/$sidecar" "$origdir/$tail.ts"
|
||||
# Release the helper lock once finished.
|
||||
if {$helper} { system dlnahelper -release }
|
||||
} else {
|
||||
if {[catch {
|
||||
exec /mod/bin/stripts -@@ "$base" "$base.decrypting"
|
||||
} msg opts]} {
|
||||
puts "Decrypt error - $msg - $opts"
|
||||
incr err
|
||||
}
|
||||
}
|
||||
|
||||
if {[file exists "$dir/$shname.hmt"]} {
|
||||
exec /mod/bin/hmt -encrypted "$dir/$shname.hmt"
|
||||
system endop $token
|
||||
|
||||
if {$err} exit
|
||||
|
||||
puts "Moving recording to $origdir"
|
||||
|
||||
$ts move "${origdir}" 1
|
||||
|
||||
if {$mode eq "dlna"} {
|
||||
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"
|
||||
file touch "$dir/$sidecar" "$origdir/$shname.ts"
|
||||
}
|
||||
}
|
||||
if {[file exists "$dir/$shname.hmt"]} {
|
||||
exec /mod/bin/hmt -encrypted "$dir/$shname.hmt"
|
||||
}
|
||||
} else {
|
||||
foreach ext $::tsgroup {
|
||||
if {![file exists "$base.decrypting.$ext"]} continue
|
||||
file rename "$base.decrypting.$ext" $base.$ext
|
||||
}
|
||||
}
|
||||
|
||||
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
|
||||
|
|
|
@ -7,13 +7,20 @@ require ts.class
|
|||
httpheader
|
||||
|
||||
set tsfile [cgi_get file]
|
||||
set mode [cgi_get mode dlna]
|
||||
set rfile [file normalize $tsfile]
|
||||
|
||||
if {![file exists "$rfile.decrypting"]} {
|
||||
if {$mode eq "dlna"} {
|
||||
set file "$rfile.decrypting"
|
||||
} else {
|
||||
set file "[file rootname $rfile].decrypting.ts"
|
||||
}
|
||||
|
||||
if {![file exists "$file"]} {
|
||||
puts "0"
|
||||
} else {
|
||||
set sz [file size $rfile]
|
||||
set nsz [file size "$rfile.decrypting"]
|
||||
set nsz [file size "$file"]
|
||||
|
||||
puts [expr $nsz * 100 / $sz]
|
||||
}
|
||||
|
|
|
@ -301,8 +301,7 @@ function preparemenu(el, menu)
|
|||
$(menu).enableContextMenuItems('#delete');
|
||||
}
|
||||
|
||||
if (el.attr('odencd') == 1 && el.attr('dlna') == 1 &&
|
||||
el.attr('encd') == 0)
|
||||
if (el.attr('odencd') == 1 && el.attr('encd') == 0)
|
||||
$(menu).enableContextMenuItems('#decrypt');
|
||||
else
|
||||
$(menu).disableContextMenuItems('#decrypt');
|
||||
|
|
|
@ -6,6 +6,11 @@ proc ::decrypt::dequeue {q ts} {
|
|||
set file [$ts get file]
|
||||
set rfile [file rootname $file]
|
||||
set bfile [file tail $file]
|
||||
set mode "dlna"
|
||||
|
||||
if {[system model] eq "HD"} { set mode "direct" }
|
||||
if {"-direct" in [$q get args]} { set mode "direct" }
|
||||
#if {$mode eq "dlna" && [$q get retries] > 5} { set mode "direct" }
|
||||
|
||||
if {![$ts flag "ODEncrypted"]} {
|
||||
return {"OK" "Already decrypted"}
|
||||
|
@ -15,7 +20,7 @@ proc ::decrypt::dequeue {q ts} {
|
|||
return {"FAILED" "Zero-byte recording, cannot process"}
|
||||
}
|
||||
|
||||
if {![system dlnastatus]} {
|
||||
if {$mode eq "dlna" && ![system dlnastatus]} {
|
||||
if {[system instandby]} {
|
||||
# Prevent polling every minute
|
||||
return [list "DEFER" "Cannot decrypt in standby" +120]
|
||||
|
@ -29,11 +34,6 @@ proc ::decrypt::dequeue {q ts} {
|
|||
return [list "DEFER" \
|
||||
"Time-shifted recording in-progress" +120]
|
||||
}
|
||||
# if {[$ts get scheddur] == 5700} {
|
||||
# # Likely to be instant-recording.
|
||||
# return [list "DEFER" \
|
||||
# "Instant-recording in-progress" +120]
|
||||
# }
|
||||
# Recording in progress, defer until near expected
|
||||
# end.
|
||||
set left $([$ts get end] - [clock seconds])
|
||||
|
@ -57,47 +57,60 @@ proc ::decrypt::dequeue {q ts} {
|
|||
"Already decrypted but the HMT flag was wrong (fixed)"}
|
||||
}
|
||||
|
||||
lassign [$ts dlnaloc "127.0.0.1"] url
|
||||
if {$mode eq "dlna"} {
|
||||
lassign [$ts dlnaloc "127.0.0.1"] url
|
||||
|
||||
if {[$ts flag "Encrypted"]} {
|
||||
#return {"DEFER" "Protected (Enc flag)"}
|
||||
# Unset the flag but use the DLNA helper to decrypt
|
||||
# this file since the DLNA database will be wrong.
|
||||
log " $file - ENC flag set, using helper."
|
||||
$ts unenc
|
||||
set url ""
|
||||
if {[$ts flag "Encrypted"]} {
|
||||
#return {"DEFER" "Protected (Enc flag)"}
|
||||
# Unset the flag but use the DLNA helper to decrypt
|
||||
# this file since the DLNA database will be wrong.
|
||||
log " $file - ENC flag set, using helper."
|
||||
$ts unenc
|
||||
set url ""
|
||||
}
|
||||
|
||||
if {$url ne ""} {
|
||||
log " $file - has been indexed."
|
||||
set helper 0
|
||||
} else {
|
||||
log " $file - Not yet indexed, trying helper."
|
||||
if {[catch {
|
||||
lassign [system dlnahelper [\
|
||||
file normalize $file]] url
|
||||
} msg]} {
|
||||
log " $file - $msg"
|
||||
return [list "DEFER" $msg]
|
||||
}
|
||||
if {$url eq ""} {
|
||||
return {"DEFER" "DLNA helper failed"}
|
||||
}
|
||||
set helper 1
|
||||
}
|
||||
}
|
||||
|
||||
if {$url ne ""} {
|
||||
log " $file - has been indexed."
|
||||
set helper 0
|
||||
} else {
|
||||
log " $file - Not yet indexed, trying helper."
|
||||
if {[catch {
|
||||
lassign [system dlnahelper [file normalize $file]] url
|
||||
} msg]} {
|
||||
log " $file - $msg"
|
||||
return [list "DEFER" $msg]
|
||||
}
|
||||
if {$url eq ""} {
|
||||
return {"DEFER" "DLNA helper failed"}
|
||||
}
|
||||
set helper 1
|
||||
}
|
||||
|
||||
# Perform the decryption by requesting the file from the DLNA server.
|
||||
set size [$ts size]
|
||||
::auto::dsc $size
|
||||
system startop decrypt $file
|
||||
::auto::startclock
|
||||
log " DECRYPT: $rfile" 0
|
||||
log " DLNA: $url" 0
|
||||
if {[catch {exec wget -O "$tmp/$bfile" $url} msg opts]} {
|
||||
::auto::log "Wget error - $msg - $opts"
|
||||
}
|
||||
|
||||
# Release the helper lock once finished.
|
||||
if {$helper} { system dlnahelper -release }
|
||||
if {$mode eq "dlna"} {
|
||||
log " DLNA: $url" 0
|
||||
if {[catch {exec wget -O "$tmp/$bfile" $url} msg opts]} {
|
||||
::auto::log "Wget error - $msg - $opts"
|
||||
}
|
||||
|
||||
# Release the helper lock once finished.
|
||||
if {$helper} { system dlnahelper -release }
|
||||
} else {
|
||||
log " Direct decryption" 0
|
||||
if {[catch {exec /mod/bin/stripts -@@ "$rfile" "$tmp/[\
|
||||
file rootname $bfile]" } msg opts]} {
|
||||
::auto::log "Decrypt error - $msg - $opts"
|
||||
system endop decrypt
|
||||
return {"FAILED" "Decryption failed"}
|
||||
}
|
||||
}
|
||||
|
||||
if {![file exists "$tmp/$bfile"]} {
|
||||
log " $file - Download failed." 0
|
||||
|
@ -121,9 +134,10 @@ proc ::decrypt::dequeue {q ts} {
|
|||
return {"DEFER" "Recording in use"}
|
||||
}
|
||||
|
||||
# Copy the HMT file over for stripts
|
||||
# Copy the HMT file over for stripts - can be removed once
|
||||
# stripts can work without a .hmt - XXX
|
||||
set thmt "$tmp/[file rootname $bfile].hmt"
|
||||
file copy "$rfile.hmt" $thmt
|
||||
if {![file exists $thmt]} { file copy "$rfile.hmt" $thmt }
|
||||
# Check that the file is no longer encrypted by analysing it.
|
||||
set anencd [exec /mod/bin/stripts -qE "$tmp/[file rootname $bfile]"]
|
||||
file delete $thmt
|
||||
|
@ -131,10 +145,11 @@ proc ::decrypt::dequeue {q ts} {
|
|||
if {$anencd != "0"} {
|
||||
log " $file - File did not decrypt properly." 0
|
||||
file tdelete "$tmp/$bfile"
|
||||
system endop decrypt
|
||||
if {[$q get retries] > 3} {
|
||||
system notify "$file - auto-decrypt failed."
|
||||
return {"FAILED" "Recording did not decrypt properly"}
|
||||
}
|
||||
system endop decrypt
|
||||
return {"DEFER" "Recording did not decrypt properly"}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue