Spotlight importing fixed.
parent
a624165bc9
commit
d8ac96afbf
|
@ -14,6 +14,9 @@ static NSArray * mdKeys;
|
||||||
// Corresponding array for playlist entry keys
|
// Corresponding array for playlist entry keys
|
||||||
static NSArray * entryKeys;
|
static NSArray * entryKeys;
|
||||||
|
|
||||||
|
// extramdKeys represents those keys that require additional processing
|
||||||
|
static NSArray * extramdKeys;
|
||||||
|
|
||||||
// And the dictionary that matches them
|
// And the dictionary that matches them
|
||||||
static NSDictionary * tags;
|
static NSDictionary * tags;
|
||||||
|
|
||||||
|
@ -37,6 +40,9 @@ static NSDictionary * tags;
|
||||||
@"year",
|
@"year",
|
||||||
@"genre",
|
@"genre",
|
||||||
nil];
|
nil];
|
||||||
|
extramdKeys = [NSArray arrayWithObjects:
|
||||||
|
@"kMDItemPath",
|
||||||
|
nil];
|
||||||
tags = [NSDictionary dictionaryWithObjects:entryKeys forKeys:mdKeys];
|
tags = [NSDictionary dictionaryWithObjects:entryKeys forKeys:mdKeys];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +51,14 @@ static NSDictionary * tags;
|
||||||
// use the matching tag sets to generate a playlist entry
|
// use the matching tag sets to generate a playlist entry
|
||||||
SpotlightPlaylistEntry *entry = [[[SpotlightPlaylistEntry alloc] init] autorelease];
|
SpotlightPlaylistEntry *entry = [[[SpotlightPlaylistEntry alloc] init] autorelease];
|
||||||
NSDictionary *songAttributes = [metadataItem valuesForAttributes:mdKeys];
|
NSDictionary *songAttributes = [metadataItem valuesForAttributes:mdKeys];
|
||||||
|
NSDictionary *extraAttributes = [metadataItem valuesForAttributes:extramdKeys];
|
||||||
for (NSString * mdKey in tags) {
|
for (NSString * mdKey in tags) {
|
||||||
[entry setValue: [songAttributes objectForKey:mdKey]
|
[entry setValue: [songAttributes objectForKey:mdKey]
|
||||||
forKey:[tags objectForKey:mdKey]];
|
forKey:[tags objectForKey:mdKey]];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// URL needs to be generated from the simple path stored in kMDItemPath
|
||||||
|
[entry setURL: [NSURL fileURLWithPath: [extraAttributes objectForKey:@"kMDItemPath"]]];
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,12 +90,8 @@ static NSPredicate * musicOnlyPredicate = nil;
|
||||||
{
|
{
|
||||||
[self.query disableUpdates];
|
[self.query disableUpdates];
|
||||||
|
|
||||||
NSArray *songPaths = [[playlistController selectedObjects]valueForKey:@"kMDItemPath"];
|
NSArray *songURLs = [[playlistController selectedObjects]valueForKey:@"url"];
|
||||||
NSMutableArray *songURLs = [NSMutableArray arrayWithCapacity:[songPaths count]];
|
[spotlightWindowController.playlistLoader addURLs:songURLs sort:NO];
|
||||||
for (NSString *songPath in songPaths) {
|
|
||||||
[songURLs addObject:[NSURL fileURLWithPath:songPath]];
|
|
||||||
}
|
|
||||||
[spotlightWindowController.playlistLoader addURLs:songURLs sort:NO];
|
|
||||||
|
|
||||||
[self.query enableUpdates];
|
[self.query enableUpdates];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue