2011-10-03 22:47:44 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
2012-05-21 20:23:41 +00:00
|
|
|
source /mod/webif/lib/setup
|
2011-10-03 22:47:44 +00:00
|
|
|
require ts.class pretty_size altrow
|
|
|
|
|
2013-02-09 22:46:15 +00:00
|
|
|
header
|
|
|
|
|
2012-04-11 20:54:59 +00:00
|
|
|
source normalise.jim
|
|
|
|
source process.jim
|
|
|
|
|
2011-10-03 22:47:44 +00:00
|
|
|
set dir [cgi_get dir "/media/My Video"]
|
|
|
|
set doit [cgi_get doit 0]
|
|
|
|
|
2012-04-11 20:54:59 +00:00
|
|
|
puts "<script type=text/javascript src=script.js></script>"
|
|
|
|
|
2011-10-03 22:47:44 +00:00
|
|
|
puts "<fieldset style=\"display: inline\">
|
|
|
|
<legend>De-duplicate <span id=dir>$dir</span></legend>
|
|
|
|
<table class=borders>
|
|
|
|
<tr>
|
|
|
|
<th>File</th>
|
|
|
|
<th>Proposed Filename</th>
|
|
|
|
<th>Proposed Title</th>
|
|
|
|
<th>Status</th>
|
|
|
|
</tr>
|
|
|
|
"
|
|
|
|
|
2012-05-21 20:23:41 +00:00
|
|
|
loadseries $dir
|
2012-02-01 21:02:43 +00:00
|
|
|
foreach file [readdir $dir] {
|
|
|
|
set file "$dir/$file"
|
2011-10-03 22:47:44 +00:00
|
|
|
if {[file extension $file] ne ".hmt"} { continue }
|
2012-04-11 20:54:59 +00:00
|
|
|
|
2011-10-03 22:47:44 +00:00
|
|
|
set base [file tail [file rootname $file]]
|
2012-04-11 20:54:59 +00:00
|
|
|
lassign [dedupprocess $file] stat ts syn fn
|
|
|
|
|
|
|
|
altrow
|
2011-10-03 22:47:44 +00:00
|
|
|
puts "<td nowrap>$base</td>"
|
|
|
|
puts "<td>$fn</td>"
|
|
|
|
puts "<td>$syn</td>"
|
|
|
|
puts "<td>"
|
2012-04-11 20:54:59 +00:00
|
|
|
switch $stat {
|
2012-04-14 21:31:25 +00:00
|
|
|
inuse {
|
|
|
|
puts -nonewline "In Use"
|
|
|
|
}
|
2012-04-11 20:54:59 +00:00
|
|
|
dup {
|
2011-10-04 20:02:59 +00:00
|
|
|
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"
|
|
|
|
}
|
2012-04-11 20:54:59 +00:00
|
|
|
}
|
|
|
|
error {
|
2011-10-04 20:02:59 +00:00
|
|
|
puts -nonewline "Cannot process"
|
2012-04-11 20:54:59 +00:00
|
|
|
}
|
|
|
|
nothing {
|
2011-10-04 20:02:59 +00:00
|
|
|
puts -nonewline "Nothing to do"
|
2012-04-11 20:54:59 +00:00
|
|
|
}
|
|
|
|
preserve {
|
2011-11-12 11:12:07 +00:00
|
|
|
puts -nonewline "Preserving"
|
2012-04-11 20:54:59 +00:00
|
|
|
}
|
|
|
|
ok {
|
|
|
|
if {$doit} {
|
|
|
|
# Dooooo, it.
|
|
|
|
$ts settitle $syn
|
|
|
|
ts renamegroup $file $fn
|
|
|
|
puts -nonewline "Done"
|
|
|
|
}
|
|
|
|
}
|
2011-10-03 22:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
puts "</td>"
|
|
|
|
puts "</tr>"
|
|
|
|
}
|
|
|
|
|
|
|
|
puts {
|
|
|
|
</table>
|
|
|
|
</fieldset>
|
|
|
|
<div style="padding-top: 2em">
|
|
|
|
<small>
|
|
|
|
<button id=browse>Back to media browser</button>
|
|
|
|
}
|
|
|
|
|
|
|
|
if {!$doit} { puts "<button id=dedup>Process folder</button>" }
|
|
|
|
|
|
|
|
puts {
|
|
|
|
</small>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
footer
|
|
|
|
|