[Cuesheet Input] Fix metadata handling by merge

The inputs now have their own metadata function, so it should merge in
the track tags from the Cuesheet, and not just forward it to the
decoder.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2022-06-12 00:55:37 -07:00
parent ab16c43c85
commit aaade58842
3 changed files with 30 additions and 16 deletions

View file

@ -10,7 +10,9 @@
#import "CueSheet.h"
#import "CueSheetContainer.h"
#import "CueSheetTrack.h"
#import "CueSheetMetadataReader.h"
#import "NSDictionary+Merge.h"
#import "Logging.h"
@ -45,10 +47,13 @@
}
- (NSDictionary *)metadata {
NSDictionary *metadata = @{};
if(track != nil)
metadata = [CueSheetMetadataReader processDataForTrack:track];
if(decoder != nil)
return [decoder metadata];
return [metadata dictionaryByMergingWith:[decoder metadata]];
else
return @{};
return metadata;
}
- (BOOL)open:(id<CogSource>)s {

View file

@ -10,7 +10,11 @@
#import "Plugin.h"
#import "CueSheetTrack.h"
@interface CueSheetMetadataReader : NSObject <CogMetadataReader> {
}
+ (NSDictionary *)processDataForTrack:(CueSheetTrack *)track;
@end

View file

@ -10,7 +10,6 @@
#import "CueSheetDecoder.h"
#import "CueSheet.h"
#import "CueSheetTrack.h"
#import "AudioMetadataReader.h"
#import "NSDictionary+Merge.h"
@ -68,6 +67,16 @@
if(!embedded)
fileMetadata = [audioMetadataReader metadataForURL:[track url] skipCue:YES];
NSDictionary *cuesheetMetadata = [CueSheetMetadataReader processDataForTrack:track];
return [cuesheetMetadata dictionaryByMergingWith:fileMetadata];
}
}
return nil;
}
+ (NSDictionary *)processDataForTrack:(CueSheetTrack *)track {
NSMutableDictionary *cuesheetMetadata = [[NSMutableDictionary alloc] init];
if([track artist]) [cuesheetMetadata setValue:[track artist] forKey:@"artist"];
@ -81,11 +90,7 @@
if([track trackGain]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track trackGain]] forKey:@"replayGainTrackGain"];
if([track trackPeak]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track trackPeak]] forKey:@"replayGainTrackPeak"];
return [cuesheetMetadata dictionaryByMergingWith:fileMetadata];
}
}
return nil;
return [NSDictionary dictionaryWithDictionary:cuesheetMetadata];
}
@end