@@ -168,33 +168,54 @@ where
168168 } ,
169169 }
170170 } ,
171- // Support the case of TRACKNUMBER being equal to current/total
172- k if k. eq_ignore_ascii_case ( b"TRACKNUMBER" ) => {
171+ // Support the case of TRACKNUMBER / DISCNUMBER being equal to current/total
172+ k if ( k. eq_ignore_ascii_case ( b"TRACKNUMBER" )
173+ || k. eq_ignore_ascii_case ( b"DISCNUMBER" ) ) =>
174+ {
173175 match utf8_decode_str ( value) {
174176 Ok ( value) => {
177+ let key = if k. eq_ignore_ascii_case ( b"TRACKNUMBER" ) {
178+ String :: from ( "TRACKNUMBER" )
179+ } else {
180+ String :: from ( "DISCNUMBER" )
181+ } ;
182+
175183 if !parse_options. implicit_conversions {
176- tag. items
177- . push ( ( String :: from ( "TRACKNUMBER" ) , value. to_owned ( ) ) ) ;
184+ tag. items . push ( ( key, value. to_owned ( ) ) ) ;
178185 continue ;
179186 }
180187
181188 // try to parse as current/total
182189 let mut value_split = value. splitn ( 2 , '/' ) ;
183- let track_number: Option < u32 > =
184- value_split. next ( ) . and_then ( |b| b. parse ( ) . ok ( ) ) ;
185- let track_total: Option < u32 > =
186- value_split. next ( ) . and_then ( |b| b. parse ( ) . ok ( ) ) ;
187-
188- if let Some ( n) = track_number {
189- tag. set_track ( n) ;
190- } else {
191- // Probably some other format, like a vinyl track number (A1, B1, etc.).
192- // Just leave it up to the caller to deal with.
193- tag. items
194- . push ( ( String :: from ( "TRACKNUMBER" ) , value. to_owned ( ) ) ) ;
195- }
196- if let Some ( n) = track_total {
197- tag. set_track_total ( n) ;
190+ let current: Option < u32 > = value_split. next ( ) . and_then ( |b| b. parse ( ) . ok ( ) ) ;
191+ let total: Option < u32 > = value_split. next ( ) . and_then ( |b| b. parse ( ) . ok ( ) ) ;
192+
193+ match key. as_str ( ) {
194+ "TRACKNUMBER" => {
195+ if let Some ( n) = total {
196+ tag. set_track_total ( n) ;
197+ }
198+ if let Some ( n) = current {
199+ tag. set_track ( n) ;
200+ } else {
201+ // Probably some other format, like a vinyl track number (A1, B1, etc.).
202+ // Just leave it up to the caller to deal with.
203+ tag. items . push ( ( key, value. to_owned ( ) ) ) ;
204+ }
205+ } ,
206+ "DISCNUMBER" => {
207+ if let Some ( n) = total {
208+ tag. set_disk_total ( n) ;
209+ }
210+ if let Some ( n) = current {
211+ tag. set_disk ( n) ;
212+ } else {
213+ // Probably some other format, like a vinyl track number (A1, B1, etc.).
214+ // Just leave it up to the caller to deal with.
215+ tag. items . push ( ( key, value. to_owned ( ) ) ) ;
216+ }
217+ } ,
218+ _ => { } ,
198219 }
199220 } ,
200221 Err ( e) => {
0 commit comments