Spotlight importing fixed.

CQTexperiment
matthewleon 2008-02-11 14:42:13 +00:00
parent a624165bc9
commit d8ac96afbf
2 changed files with 11 additions and 6 deletions

View File

@ -14,6 +14,9 @@ static NSArray * mdKeys;
// Corresponding array for playlist entry keys
static NSArray * entryKeys;
// extramdKeys represents those keys that require additional processing
static NSArray * extramdKeys;
// And the dictionary that matches them
static NSDictionary * tags;
@ -37,6 +40,9 @@ static NSDictionary * tags;
@"year",
@"genre",
nil];
extramdKeys = [NSArray arrayWithObjects:
@"kMDItemPath",
nil];
tags = [NSDictionary dictionaryWithObjects:entryKeys forKeys:mdKeys];
}
@ -45,11 +51,14 @@ static NSDictionary * tags;
// use the matching tag sets to generate a playlist entry
SpotlightPlaylistEntry *entry = [[[SpotlightPlaylistEntry alloc] init] autorelease];
NSDictionary *songAttributes = [metadataItem valuesForAttributes:mdKeys];
NSDictionary *extraAttributes = [metadataItem valuesForAttributes:extramdKeys];
for (NSString * mdKey in tags) {
[entry setValue: [songAttributes 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;
}

View File

@ -90,12 +90,8 @@ static NSPredicate * musicOnlyPredicate = nil;
{
[self.query disableUpdates];
NSArray *songPaths = [[playlistController selectedObjects]valueForKey:@"kMDItemPath"];
NSMutableArray *songURLs = [NSMutableArray arrayWithCapacity:[songPaths count]];
for (NSString *songPath in songPaths) {
[songURLs addObject:[NSURL fileURLWithPath:songPath]];
}
[spotlightWindowController.playlistLoader addURLs:songURLs sort:NO];
NSArray *songURLs = [[playlistController selectedObjects]valueForKey:@"url"];
[spotlightWindowController.playlistLoader addURLs:songURLs sort:NO];
[self.query enableUpdates];
}