update dedup, require new rsvsync

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@909 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2012-04-11 20:54:59 +00:00
parent 68ae915f57
commit 52728ba471
7 changed files with 190 additions and 52 deletions

View File

@ -1,9 +1,9 @@
Package: webif
Priority: optional
Section: web
Version: 0.9.5
Version: 0.9.5-1
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons,mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73),jim-cgi(>=0.5),service-control(>=1.2),busybox(>=1.19.3-1),lsof,epg(>=1.0.9),hmt(>=1.1.6),ssmtp,anacron,trm,openssl-command,nicesplice,id3v2,file,rsvsync
Depends: webif-channelicons,mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73),jim-cgi(>=0.5),service-control(>=1.2),busybox(>=1.19.3-1),lsof,epg(>=1.0.9),hmt(>=1.1.6),ssmtp,anacron,trm,openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.1)
Suggests: ffmpeg,webif-iphone
Description: An evolving web interface for the Humax.

View File

@ -582,7 +582,7 @@ var dmenuclick = function(action, el, pos)
// Buttons
$('#dedup').button().click(function() {
window.location = '/cgi-bin/dedup.jim?dir='
window.location = '/dedup/dedup.jim?dir='
+ encodeURIComponent(dir);
});

74
var/mongoose/html/dedup/dedup Executable file
View File

@ -0,0 +1,74 @@
#!/mod/bin/jimsh
source /mod/var/mongoose/lib/setup
require ts.class
source /mod/var/mongoose/html/dedup/normalise.jim
source /mod/var/mongoose/html/dedup/process.jim
set dirs {}
set doit 0
foreach arg $argv {
if {$arg eq "-yes"} {
set doit 1
} else {
lappend dirs $arg
}
}
if {![llength $dirs]} { lappend dirs [exec pwd] }
foreach dir $dirs {
if {[string index $dir end] eq "/"} {
set dir [string range $dir 0 end-1]
}
puts "\[$dir\]"
foreach file [readdir $dir] {
if {[file extension $file] ne ".hmt"} { continue }
set file "$dir/$file"
set base [file tail [file rootname $file]]
lassign [dedupprocess $file] stat ts syn fn
puts -nonewline "$base -> "
switch $stat {
dup {
puts -nonewline "Duplicate"
if {$doit} {
set dupdir "$dir/_duplicates"
if {![file exists $dupdir]} {
file mkdir $dupdir
}
while {[file exists $dupdir/$fn.hmt]} {
append fn "~"
}
ts renamegroup $file "_duplicates/$fn"
puts -nonewline " - Renamed to _duplicates/$fn"
}
}
error {
puts -nonewline "Cannot process"
}
nothing {
puts -nonewline "Nothing to do"
}
preserve {
puts -nonewline "Preserving"
}
ok {
puts -nonewline $fn
if {$doit} {
# Dooooo, it.
$ts settitle $syn
ts renamegroup $file $fn
puts -nonewline "Done"
}
}
}
puts ""
}
}

View File

@ -4,6 +4,9 @@ package require cgi
source /mod/var/mongoose/lib/setup
require ts.class pretty_size altrow
source normalise.jim
source process.jim
puts "Content-Type: text/html"
puts ""
@ -15,6 +18,8 @@ set doit [cgi_get doit 0]
header
puts "<script type=text/javascript src=script.js></script>"
puts "<fieldset style=\"display: inline\">
<legend>De-duplicate <span id=dir>$dir</span></legend>
<table class=borders>
@ -31,34 +36,17 @@ set seen {}
foreach file [readdir $dir] {
set file "$dir/$file"
if {[file extension $file] ne ".hmt"} { continue }
altrow
set ts [ts fetch $file 1]
set base [file tail [file rootname $file]]
lassign [dedupprocess $file] stat ts syn fn
altrow
puts "<td nowrap>$base</td>"
set syn [$ts get synopsis]
regsub -nocase -all -- {^new series\.* *} $syn "" syn
regsub -nocase -all -- {^cbeebies\. *} $syn "" syn
regsub -nocase -all -- {^brand new series - *} $syn "" syn
regsub -all -- { *[:].*$} $syn "" syn
if {[string length $syn] > 40} {
lassign [split $syn "."] v w
set syn $v
if {[string length $syn] < 6 && [string length $w] < 6} {
append syn "_$w"
}
}
if {[string length $syn] < 10} {
if {[string match "${syn}*" [$ts get title]]} {
set syn [$ts get title]
} else {
append syn " [$ts get title]"
}
}
regsub -all -- {[\/ &]} $syn "_" fn
puts "<td>$fn</td>"
puts "<td>$syn</td>"
puts "<td>"
if {$fn in $seen} {
switch $stat {
dup {
puts -nonewline "Duplicate"
if {$doit} {
set dupdir "$dir/_duplicates"
@ -69,19 +57,25 @@ foreach file [readdir $dir] {
ts renamegroup $file "_duplicates/$fn"
puts -nonewline " - Renamed to _duplicates/$fn"
}
} elseif {[string length $syn] > 40} {
}
error {
puts -nonewline "Cannot process"
} elseif {$base eq $fn} {
}
nothing {
puts -nonewline "Nothing to do"
} elseif {[file exists "$dir/$fn.ts"]} {
}
preserve {
puts -nonewline "Preserving"
} elseif {$doit} {
# Dooooo, it.
$ts settitle $syn
ts renamegroup $file $fn
puts -nonewline "Done"
}
ok {
if {$doit} {
# Dooooo, it.
$ts settitle $syn
ts renamegroup $file $fn
puts -nonewline "Done"
}
}
}
lappend seen $fn
puts "</td>"
puts "</tr>"
@ -99,25 +93,8 @@ if {!$doit} { puts "<button id=dedup>Process folder</button>" }
puts {
</small>
</div>
<script type=text/javascript>
$('#browse').button().click(function() {
window.location = '/cgi-bin/browse.jim?dir=' +
encodeURIComponent($('#dir').text());
});
}
if {!$doit} {
puts {
$('#dedup').button().click(function() {
window.location = window.location + '&doit=1';
});
}
}
puts "</script>"
footer

View File

@ -0,0 +1,47 @@
#!/mod/bin/jimsh
set dedup_prefixes {
{^new series\.* *}
{^cbeebies\.* *}
{^brand new series *-* *}
{^\.+}
}
proc dedupnormalise {title {reserve ""}} {
global dedup_prefixes
# Strip common prefixes
foreach prefix $dedup_prefixes {
regsub -nocase -all -- $prefix $title "" title
}
# Strip anything following a colon.
regsub -all -- { *[:].*$} $title "" title
# If the resulting string is longer than 40 characters then
# split around . and take the left hand side if appropriate.
if {[string length $title] > 40} {
lassign [split $title "."] v w
set title $v
if {[string length $title] < 6 && [string length $w] < 6} {
append title "_$w"
}
}
# if still short, add the reserve string.
if {[string length $title] < 10} {
if {[string match "${title}*" $reserve]} {
set title $reserve
} else {
append title " $reserve"
}
}
# Shorten if too long.
if {[string length $title] > 40} {
set title [string range $title 0 39]
}
return $title
}

View File

@ -0,0 +1,26 @@
#!/mod/bin/jimsh
proc dedupprocess {file} {{seen {}}} {
set ts [ts fetch $file 1]
set dir [file dirname $file]
set base [file tail [file rootname $file]]
set syn [dedupnormalise [$ts get synopsis] [$ts get title]]
# Escape special characters to create the filename.
regsub -all -- {[\/ &]} $syn "_" fn
set stat ok
if {$fn in $seen} {
set stat dup
} elseif {[string length $syn] > 40} {
set stat error
} elseif {$base eq $fn} {
set stat nothing
} elseif {[file exists "$dir/$fn.ts"]} {
set stat preserve
}
lappend seen $fn
return [list $stat $ts $syn $fn]
}

View File

@ -0,0 +1,14 @@
$(function() {
$('#browse').button().click(function() {
window.location = '/cgi-bin/browse.jim?dir=' +
encodeURIComponent($('#dir').text());
});
$('#dedup').button().click(function() {
window.location = window.location + '&doit=1';
});
});