From 67f6c931bb0c1fbccfaaf04e41d671550285cd66 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 17 Jun 2022 05:48:03 -0700 Subject: [PATCH] [Highly Complete / MIDI] Fix numeric tag reading The new Core Data interface is especially stringent with receiving NSNumber for the numeric types rather than NSString as was mistakenly allowed before. Fix that to prevent exceptions. Signed-off-by: Christopher Snowhill --- Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm | 7 ++++--- Plugins/MIDI/MIDI/MIDIMetadataReader.mm | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm b/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm index b3d8e667c..f86e70dbe 100644 --- a/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm +++ b/Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm @@ -266,11 +266,12 @@ static int psf_info_meta(void *context, const char *name, const char *value) { [taglc isEqualToString:@"albumartist"] || [taglc isEqualToString:@"artist"] || [taglc isEqualToString:@"album"] || - [taglc isEqualToString:@"year"] || - [taglc isEqualToString:@"genre"] || + [taglc isEqualToString:@"genre"]) { + [state->info setObject:svalue forKey:taglc]; + } else if([taglc isEqualToString:@"year"] || [taglc isEqualToString:@"track"] || [taglc isEqualToString:@"disc"]) { - [state->info setObject:svalue forKey:taglc]; + [state->info setObject:[NSNumber numberWithInt:[svalue intValue]] forKey:taglc]; } return 0; diff --git a/Plugins/MIDI/MIDI/MIDIMetadataReader.mm b/Plugins/MIDI/MIDI/MIDIMetadataReader.mm index 360bb8bc0..33461f37d 100644 --- a/Plugins/MIDI/MIDI/MIDIMetadataReader.mm +++ b/Plugins/MIDI/MIDI/MIDIMetadataReader.mm @@ -62,7 +62,7 @@ midi_meta_data_item item; bool remap_display_name = !metadata.get_item("title", item); - NSArray *allowedKeys = @[@"title", @"artist", @"albumartist", @"album", @"year", @"genre"]; + NSArray *allowedKeys = @[@"title", @"artist", @"albumartist", @"album", @"genre"]; NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:10]; @@ -72,8 +72,11 @@ if(![name isEqualToString:@"type"]) { if(remap_display_name && [name isEqualToString:@"display_name"]) name = @"title"; - if([allowedKeys containsObject:name]) + if([allowedKeys containsObject:name]) { [dict setObject:guess_encoding_of_string(item.m_value.c_str()) forKey:name]; + } else if([name isEqualToString:@"year"]) { + [dict setObject:[NSNumber numberWithInt:[guess_encoding_of_string(item.m_value.c_str()) intValue]] forKey:name]; + } } }