Support setting the seriesnum, episodenum, episodetot attributes in "rename"

This commit is contained in:
df 2021-01-01 23:57:54 +00:00 committed by HummyPkg
parent 1c868ae201
commit 18bed926b3
5 changed files with 87 additions and 7 deletions

View File

@ -103,7 +103,7 @@ if {[llength $plugins(dmenu)]} {
}
}
# the maxlength values for title and synopsis are 1 less than the maximum to
# the maxlength values for title and synopsis are 1 less than the maximum to
# allow for an extra byte to indicate character encoding (see rename.jim)
puts {
</ul>
@ -138,13 +138,44 @@ puts {
</td>
</tr>
<tr style="display: none" class=tstype>
<th>
<label for="rename_seriesnum" style="padding-top: 0.5em">
<b>New Series Number</b>
</label>
</th>
<td>
<span title="Series number">
<input type=number name="rename_seriesnum" id="rename_seriesnum"
value=0 max=255
class="uint8_t ui-widget-content ui-corner-all">
</span>
<label for="rename_episodenum" style="padding-top: 0.5em">
<b>Episode</b>
</label>
<span title="Episode number">
<input type=number name="rename_episodenum"
id="rename_episodenum" value=0 max=255
class="uint8_t ui-widget-content ui-corner-all">
</span>
<label for="rename_episodetot" style="padding-top: 0.5em">
<b>of</b>
</label>
<span title="Episode total">
<input type=number name="rename_episodetot"
id="rename_episodetot" value=0 max=255
class="uint8_t ui-widget-content ui-corner-all">
</span>
</td>
</tr>
<tr style="display: none" class=tstype>
<th>
<label for="rename_synopsis" style="padding-top: 0.5em">
<b>New Synopsis</b>
</label>
</th>
<td>
<td colspan=3>
<textarea name="rename_synopsis" id="rename_synopsis"
value="" cols=70 rows=4 maxlength=251
class="text ui-widget-content ui-corner-all"></textarea>

View File

@ -14,6 +14,9 @@ puts "{"
puts "\"title\" : \"[jescape [$ts get title]]\","
puts "\"synopsis\" : \"[jescape [$ts get synopsis]]\","
puts "\"guidance\" : \"[jescape [$ts get guidance]]\","
puts "\"genre\" : [jescape [$ts genrenib]]"
puts "\"genre\" : [jescape [$ts genrenib]],"
puts "\"seriesnum\" : [jescape [$ts get seriesnum]],"
puts "\"episodenum\" : [jescape [$ts get episodenum]],"
puts "\"episodetot\" : [jescape [$ts get episodetot]]"
puts "}"

View File

@ -30,8 +30,7 @@ if {[file isdirectory $file]} {
set new "\025$new"
}
if {$new ne $old} {
if {$attr eq "guidance" ||
[string length $new] > 0} {
if {$attr eq guidance || $new ne ""} {
$ts set$attr $new
}
}
@ -39,6 +38,45 @@ if {[file isdirectory $file]} {
puts "$attr: $msg"
}
}
# deal with series number/ep num/ep total, which get set together
# list the old values seen in case a later one is changed
set epdataold {}
# list values to be set, or {}
set epdatanew {}
foreach attr {seriesnum episodenum episodetot} {
if {[catch {
set new [string map {"\n" ""} [
string trim [cgi_get "rename_$attr"]]]
set old [$ts get $attr]
if {$new ne $old} {
switch $attr {
seriesnum {
set epdatanew [list $new]
}
episodenum -
episodetot {
if {$epdatanew eq {}} {
set epdatanew $epdataold
}
lappend epdatanew $new
}
}
} elseif {$epdatanew eq {}} {
# nothing to be changed yet
lappend epdataold $old
} else {
# fill to-be-set list with old value
lappend epdatanew $old
}
} msg]} {
puts "$attr: $msg"
}
}
if {$epdatanew ne {}} {
if {[catch {$ts storeepisode $epdatanew} msg]} {
puts "ts::storeepisode: $msg"
}
}
if {"$dir/$newfile.ts" ne "$file"} { ts renamegroup $file $newfile }
} else {

View File

@ -105,6 +105,9 @@ function epginfo_callback(data, status, xhr)
$('#rename_synopsis').val(data.synopsis);
$('#rename_guidance').val(data.guidance);
$('#rename_genre').val(data.genre);
$('#rename_seriesnum').val(data.seriesnum);
$('#rename_episodenum').val(data.episodenum);
$('#rename_episodetot').val(data.episodetot);
$('tr.tstype').show('slow');
}
@ -113,11 +116,11 @@ function insert_folder_size(folder, size)
{
// folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
// ID of size element is ID + RFC4648 s5 encoding of folder name
folder = "ID" +
folder = "ID" +
btoa(escape(folder))
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
.replace(/=/g, '');
//console.log("Folder: (%s) = (%s)", folder, size);
if (size.search(/\d$/) == -1)
size += 'iB';

View File

@ -30,3 +30,8 @@ img.qb
color: #ff4000;
}
input.uint8_t
{
width: 6ch;
}