[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>swiftingly
parent
ab16c43c85
commit
aaade58842
|
@ -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 {
|
||||
|
|
|
@ -10,7 +10,11 @@
|
|||
|
||||
#import "Plugin.h"
|
||||
|
||||
#import "CueSheetTrack.h"
|
||||
|
||||
@interface CueSheetMetadataReader : NSObject <CogMetadataReader> {
|
||||
}
|
||||
|
||||
+ (NSDictionary *)processDataForTrack:(CueSheetTrack *)track;
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#import "CueSheetDecoder.h"
|
||||
|
||||
#import "CueSheet.h"
|
||||
#import "CueSheetTrack.h"
|
||||
|
||||
#import "AudioMetadataReader.h"
|
||||
#import "NSDictionary+Merge.h"
|
||||
|
@ -68,18 +67,7 @@
|
|||
if(!embedded)
|
||||
fileMetadata = [audioMetadataReader metadataForURL:[track url] skipCue:YES];
|
||||
|
||||
NSMutableDictionary *cuesheetMetadata = [[NSMutableDictionary alloc] init];
|
||||
|
||||
if([track artist]) [cuesheetMetadata setValue:[track artist] forKey:@"artist"];
|
||||
if([track album]) [cuesheetMetadata setValue:[track album] forKey:@"album"];
|
||||
if([track title]) [cuesheetMetadata setValue:[track title] forKey:@"title"];
|
||||
if([[track track] intValue]) [cuesheetMetadata setValue:[NSNumber numberWithInt:[[track track] intValue]] forKey:@"track"];
|
||||
if([track genre]) [cuesheetMetadata setValue:[track genre] forKey:@"genre"];
|
||||
if([[track year] intValue]) [cuesheetMetadata setValue:[NSNumber numberWithInt:[[track year] intValue]] forKey:@"year"];
|
||||
if([track albumGain]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track albumGain]] forKey:@"replayGainAlbumGain"];
|
||||
if([track albumPeak]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track albumPeak]] forKey:@"replayGainAlbumPeak"];
|
||||
if([track trackGain]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track trackGain]] forKey:@"replayGainTrackGain"];
|
||||
if([track trackPeak]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track trackPeak]] forKey:@"replayGainTrackPeak"];
|
||||
NSDictionary *cuesheetMetadata = [CueSheetMetadataReader processDataForTrack:track];
|
||||
|
||||
return [cuesheetMetadata dictionaryByMergingWith:fileMetadata];
|
||||
}
|
||||
|
@ -88,4 +76,21 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)processDataForTrack:(CueSheetTrack *)track {
|
||||
NSMutableDictionary *cuesheetMetadata = [[NSMutableDictionary alloc] init];
|
||||
|
||||
if([track artist]) [cuesheetMetadata setValue:[track artist] forKey:@"artist"];
|
||||
if([track album]) [cuesheetMetadata setValue:[track album] forKey:@"album"];
|
||||
if([track title]) [cuesheetMetadata setValue:[track title] forKey:@"title"];
|
||||
if([[track track] intValue]) [cuesheetMetadata setValue:[NSNumber numberWithInt:[[track track] intValue]] forKey:@"track"];
|
||||
if([track genre]) [cuesheetMetadata setValue:[track genre] forKey:@"genre"];
|
||||
if([[track year] intValue]) [cuesheetMetadata setValue:[NSNumber numberWithInt:[[track year] intValue]] forKey:@"year"];
|
||||
if([track albumGain]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track albumGain]] forKey:@"replayGainAlbumGain"];
|
||||
if([track albumPeak]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track albumPeak]] forKey:@"replayGainAlbumPeak"];
|
||||
if([track trackGain]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track trackGain]] forKey:@"replayGainTrackGain"];
|
||||
if([track trackPeak]) [cuesheetMetadata setValue:[NSNumber numberWithFloat:[track trackPeak]] forKey:@"replayGainTrackPeak"];
|
||||
|
||||
return [NSDictionary dictionaryWithDictionary:cuesheetMetadata];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue