From 18bed926b30043c8f27028f2a871385758a62fcd Mon Sep 17 00:00:00 2001 From: df Date: Fri, 1 Jan 2021 23:57:54 +0000 Subject: [PATCH] Support setting the seriesnum, episodenum, episodetot attributes in "rename" --- webif/html/browse/assets.jim | 35 ++++++++++++++++++++++++++-- webif/html/browse/epgtitle.jim | 5 +++- webif/html/browse/rename.jim | 42 ++++++++++++++++++++++++++++++++-- webif/html/browse/script.js | 7 ++++-- webif/html/browse/style.css | 5 ++++ 5 files changed, 87 insertions(+), 7 deletions(-) diff --git a/webif/html/browse/assets.jim b/webif/html/browse/assets.jim index 8735f9a..0fc652b 100755 --- a/webif/html/browse/assets.jim +++ b/webif/html/browse/assets.jim @@ -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 { @@ -138,13 +138,44 @@ puts { + + + + + + + + + + + + + + + + + + + - + diff --git a/webif/html/browse/epgtitle.jim b/webif/html/browse/epgtitle.jim index 36c1c4a..7cdfbcd 100755 --- a/webif/html/browse/epgtitle.jim +++ b/webif/html/browse/epgtitle.jim @@ -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 "}" diff --git a/webif/html/browse/rename.jim b/webif/html/browse/rename.jim index 1e3a07a..c141ae7 100755 --- a/webif/html/browse/rename.jim +++ b/webif/html/browse/rename.jim @@ -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 { diff --git a/webif/html/browse/script.js b/webif/html/browse/script.js index cec02bb..d0548be 100755 --- a/webif/html/browse/script.js +++ b/webif/html/browse/script.js @@ -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'; diff --git a/webif/html/browse/style.css b/webif/html/browse/style.css index a299b79..d2e2fa3 100644 --- a/webif/html/browse/style.css +++ b/webif/html/browse/style.css @@ -30,3 +30,8 @@ img.qb color: #ff4000; } +input.uint8_t +{ + width: 6ch; +} +