• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iTunes Music Library parsing help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iTunes Music Library parsing help


  • Subject: Re: iTunes Music Library parsing help
  • From: "James B. Tuley" <email@hidden>
  • Date: Sun, 6 Mar 2005 16:05:42 -0600


On Mar 6, 2005, at 3:00 PM, Dave DeLong wrote:

Hi everyone,

I've got some code that parses the iTunes Music Library.xml file by pushing it into a dictionary:

NSURL * iTunesDatabaseLocation = [NSURL fileURLWithPath:[@"~/music/iTunes/iTunes Music Library.xml" stringByExpandingTildeInPath]];
NSDictionary * iTunesDatabase = [NSDictionary dictionaryWithContentsOfURL:iTunesDatabaseLocation];


I then iterate through the dictionary with an NSEnumerator to construct some custom Playlist objects that contain the list of all the songs in each playlist, etc.

The problem is that it takes a VERY long time to do this -- well over a minute. I think that's a little odd, because I wrote the exact same method in another language and it could pull all available track information, store each track in a seperate track object, then create the entire and correct playlist hierarchy with references to each track. It could do all of this in less than three seconds.

Perhaps I'm doing something wrong? Why on earth should it be taking more than 20 times as much time? Here's all the parsing code:

An NSDictionary is basically a HashTable, this algorithm you wrote pretty much puts the preexisting table of tracks hashed by ID it into an array that you are using to look up songs, and causes you to have to iterate through song library until you find the song each time, defeating the purpose of it being already in a hashtable.



I made the slightest modification to this section of your code to allow quick lookups of the songs by id->


		NSArray * ids = [currentList objectForKey:@"Playlist Items"];
		NSEnumerator * idEnumerator = [ids objectEnumerator];
		NSDictionary * currentId;
		NSMutableArray * playSongs = [[NSMutableArray alloc] init];
		while (currentId = [idEnumerator nextObject])
		{
			NSString* i = [currentId objectForKey:@"Track ID"];
			NSDictionary* songFromID =[tracks objectForKey: i];
			[playSongs addObject:songFromID];

		}

-Jay
http://indyjt.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: iTunes Music Library parsing help
      • From: Dave DeLong <email@hidden>
References: 
 >iTunes Music Library parsing help (From: Dave DeLong <email@hidden>)

  • Prev by Date: Any method to prevent context help mode?
  • Next by Date: Learning Cocoa/ObjectiveC and wondering why I had to do this.
  • Previous by thread: iTunes Music Library parsing help
  • Next by thread: Re: iTunes Music Library parsing help
  • Index(es):
    • Date
    • Thread