@@ -4,6 +4,7 @@ use crate::config::{ParseOptions, ParsingMode};
4
4
use crate :: error:: { ErrorKind , LoftyError , Result } ;
5
5
use crate :: macros:: { decode_err, err, parse_mode_choice} ;
6
6
use crate :: picture:: { MimeType , Picture , PictureInformation , PictureType } ;
7
+ use crate :: tag:: Accessor ;
7
8
use crate :: util:: text:: { utf16_decode, utf8_decode, utf8_decode_str} ;
8
9
9
10
use std:: borrow:: Cow ;
@@ -167,6 +168,32 @@ where
167
168
} ,
168
169
}
169
170
} ,
171
+ // Support the case of TRACKNUMBER being equal to current/total
172
+ k if k. eq_ignore_ascii_case ( b"TRACKNUMBER" ) => {
173
+ match utf8_decode_str ( value) {
174
+ Ok ( value) => {
175
+ let mut value_split = value. splitn ( 2 , '/' ) ;
176
+ let track_number: Option < u32 > =
177
+ value_split. next ( ) . and_then ( |b| b. parse ( ) . ok ( ) ) ;
178
+ let track_total: Option < u32 > =
179
+ value_split. next ( ) . and_then ( |b| b. parse ( ) . ok ( ) ) ;
180
+ if let Some ( n) = track_number {
181
+ tag. set_track ( n) ;
182
+ }
183
+ if let Some ( n) = track_total {
184
+ tag. set_track_total ( n) ;
185
+ }
186
+ } ,
187
+ Err ( e) => {
188
+ if parse_mode == ParsingMode :: Strict {
189
+ return Err ( e) ;
190
+ }
191
+
192
+ log:: warn!( "Non UTF-8 value found, discarding field {key:?}" ) ;
193
+ continue ;
194
+ } ,
195
+ }
196
+ } ,
170
197
// The valid range is 0x20..=0x7D not including 0x3D
171
198
k if k. iter ( ) . all ( |c| ( b' ' ..=b'}' ) . contains ( c) && * c != b'=' ) => {
172
199
// SAFETY: We just verified that all of the bytes fall within the subset of ASCII
0 commit comments