扫描 iTunes 资料库?

发布于 2024-12-02 12:21:12 字数 72 浏览 0 评论 0原文

我正在开发一个 Mac 应用程序,我需要它来扫描用户的 iTunes 库。知道我该怎么做吗?该应用程序将扫描库寻找不同的歌曲属性。

I'm working on a Mac app and I need it to scan the users iTunes library. Any idea how I would go about this? The app would scan the library looking for different song attributes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌酱 2024-12-09 12:21:12

要查找 iTunes 库的实际最新位置(而不希望它位于默认位置),请读取 ~/ 中的 iTunesRecentDatabasesiTunesRecentDatabasePaths 属性库/首选项/com.apple.iApps.plist

NSArray *libraryDatabases = [[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.iApps"] objectForKey:@"iTunesRecentDatabases"];
NSURL *libraryURL = (([libraryDatabases count])) ? [NSURL URLWithString:[dbs objectAtIndex:0]] : nil;

如需更高级的代码片段,请在 iMediaIMBiTunesParser.m


对于实际的数据库解析,建议使用 SAX 解析器,例如 NSXMLParser (相对于树解析器,例如 NSXMLDocument 或更糟:NSPropertylistSerialization),因为某些用户拥有的库包含多达(有时甚至超过 100,000 个轨道)。使用树解析甚至序列化会严重减慢速度并可能暂时阻止您的应用程序。

To find the actual most recent location of the iTunes library (and not hope for it to be at the default location) read the iTunesRecentDatabases or iTunesRecentDatabasePaths property from ~/Library/Preferences/com.apple.iApps.plist.

NSArray *libraryDatabases = [[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.iApps"] objectForKey:@"iTunesRecentDatabases"];
NSURL *libraryURL = (([libraryDatabases count])) ? [NSURL URLWithString:[dbs objectAtIndex:0]] : nil;

For a more advanced code snippet look for parserInstancesForMediaType: in iMedia's IMBiTunesParser.m


For the actual database parsing it is recommended to use a SAX parser, such as NSXMLParser (vs. a tree parser, such as NSXMLDocument or even worse: NSPropertylistSerialization) as some users have librares with up to and sometimes even more than 100,000+ tracks. Using tree parsing or even serialization will seriously slow down and potentially block your app temporarily.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文