如果 Itunes:Keep iTunes Folder Organized 在 Windows 上以编程方式设置,我该如何解决
Posted
技术标签:
【中文标题】如果 Itunes:Keep iTunes Folder Organized 在 Windows 上以编程方式设置,我该如何解决【英文标题】:How can I work out if Itunes:Keep iTunes Folder Organized is set programmatically on Windows 【发布时间】:2013-07-31 05:08:36 【问题描述】:如果 Itunes:Preferences:Advanced:Keep iTunes Folder Organized 在 Windows 上以编程方式设置,我该如何解决,我与 iTunes 交互的 Java 应用程序需要知道这一点。
不幸的是,iTunes xml 文件或 Itunes COM API 似乎都没有提供此信息,我认为是因为它们是存储在其他地方的首选项,但我如何才能确定是否启用,我还需要知道这一点 添加到库时将文件复制到 iTunes 媒体文件夹
更新: 注册表中没有任何内容,但我找到了首选项文件
C:\Users\用户名\AppData\Roaming\Apple Computer\iTunes
但它似乎被加密/编码,我不知道如何读取值
更新 2:
保存文件的副本,在添加到库时更改了 Copy files to iTunes Media Folder 的值并进行比较并获得了更改
<key>Documents:132</key>
<data>
AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAV09SQjQAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAACwf6jgsOrUhX8BAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</data>
但是您可以看到很难发现差异,并且我担心如果我破解了这个 valkue,它可能会在 iTunes 版本之间中断,有没有办法解码这个文件?
更新 3
我发现Apache Commons Configuration支持Apple的plist格式为Xml格式http://commons.apache.org/proper/commons-configuration/apidocs/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.html但不幸的是这里使用的二进制格式。
我编写了列出所有键的代码,然后尝试解码 location 属性,因为我知道它只包含一个 base64 编码器文件路径。
public File getITunesXMLFile()
String homedir = System.getProperty("user.home");
File prefsFile = new File(homedir,"AppData/Roaming/Apple Computer/iTunes/iTunesPrefs.xml");
try
XMLPropertyListConfiguration xpc = new XMLPropertyListConfiguration(prefsFile);
xpc.load();
Iterator<String> keys = xpc.getKeys();
while(keys.hasNext())
String nextKey = keys.next();
System.out.println(nextKey+":"+xpc.getProperty(nextKey).getClass());
ArrayList location = (ArrayList)xpc.getProperty("User Preferences.iTunes Library XML Location:1");
System.out.println("Location:"+location.get(0).getClass());
System.out.println("Location:"+location.get(1).getClass());
System.out.println("Location1:"+ new BASE64Decoder().decodeBuffer(location.get(0).toString()));
System.out.println("Location2:"+ new BASE64Decoder().decodeBuffer(location.get(1).toString()));
catch(Exception ex)
MainWindow.logger.log(Level.SEVERE,"Unable to open iTunes Prefs file:"+prefsFile.getName(),ex);
File xmlFile = new File(homedir + "/Music/iTunes/iTunes Music Library.xml");
if (!xmlFile.exists())
return null;
return xmlFile;
但不幸的是,数据作为 [B 类型的类的 ArrayList 返回,这对我来说毫无意义,它不是类的有效名称。
输出是
EQ Preferences.EQPresets:129:class java.util.ArrayList
User Preferences.Documents:132:class java.util.ArrayList
User Preferences.Gracenote User ID:1:class java.util.ArrayList
User Preferences.Music Store:1:class java.util.ArrayList
User Preferences.Pairing Preferences:301:class java.util.ArrayList
User Preferences.Preferences:130:class java.util.ArrayList
User Preferences.Radio Tuner Categories:131:class java.util.ArrayList
User Preferences.Touch Remote Preferences:400:class java.util.ArrayList
User Preferences.iTunes Library XML Location:1:class java.util.ArrayList
User Preferences.iTunes..exe:AAC Encoder:class java.util.ArrayList
User Preferences.iTunes..exe:iTunes Classic Visualiser:class java.util.ArrayList
User Preferences.license-agreements.EA0962:class java.util.ArrayList
User Preferences.storefront:class java.util.ArrayList
Location:class [B
Location:class [B
Location1:[B@58a7a
Location2:[B@2893bb6f
+++++++++++++++++++++++++++++++++++++++++++++++
也发现了这个问题https://issues.apache.org/jira/browse/CONFIGURATION-262
更新 4
找到一个已经支持二进制代码的库。google.com/p/plist 看起来很有希望
更新 5
我已经设法使用这个库来解码 Xml 文件位置,如下所示(来自 Apache Commons Codec 1.8 的 Base64 类)
public File getITunesXMLFile()
System.getProperties().list(System.out);
String homedir = System.getProperty("user.home");
File prefsFile = new File(homedir,"AppData/Roaming/Apple Computer/iTunes/iTunesPrefs.xml");
File xmlFile;
try
NSDictionary rootDict = (NSDictionary) PropertyListParser.parse(prefsFile);
NSDictionary userPrefs = (NSDictionary) rootDict.objectForKey("User Preferences");
if(userPrefs!=null)
NSData iTunesLocation = (NSData) userPrefs.objectForKey("iTunes Library XML Location:1");
if(iTunesLocation!=null)
String base64 = iTunesLocation.getBase64EncodedData();
String filepath = new String(Base64.decodeBase64(base64),"UTF-16LE");
xmlFile = new File(filepath);
System.out.println(filepath+":File Exists:"+xmlFile.exists());
if (xmlFile.exists())
return xmlFile;
catch(Exception ex)
ex.printStackTrace();
//Use default then
xmlFile = new File(homedir + "/Music/iTunes/iTunes Music Library.xml");
if (xmlFile.exists())
return xmlFile;
return null;
更新 6
我尝试对我真正感兴趣的数据执行此操作,我能够从 Documents:132 密钥中提取 base64 编码的数据,但不幸的是,尝试解码这个 base64 编码并没有真正让我到任何地方,也许我只是启用/禁用标志时,必须查找 base64 编码数据的差异。
public boolean isiTunesCopyFolderToMediaFolder()
String homedir = System.getProperty("user.home");
File prefsFile = new File(homedir,"AppData/Roaming/Apple Computer/iTunes/iTunesPrefs.xml");
try
NSDictionary rootDict = (NSDictionary) PropertyListParser.parse(prefsFile);
NSDictionary userPrefs = (NSDictionary) rootDict.objectForKey("User Preferences");
if(userPrefs!=null)
NSData options = (NSData) userPrefs.objectForKey("Documents:132");
if(options!=null)
String base64 = options.getBase64EncodedData();
System.out.println("optionBase54Data:"+base64);
String optionData = new String(Base64.decodeBase64(base64));
System.out.println("optionData:"+optionData);
return true;
catch(Exception ex)
ex.printStackTrace();
return false;
主要输出空格(AAAA's)
optionBase54Data:AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAV09SQjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAADUXX4fAc2UWH8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA = P>
加上嵌入输出
WORB4
和
�]~͔X
可以在此处找到 iTunes 首选项文件的示例
http://www.jthink.net/jaikoz/scratch/iTunesPrefs.xml
【问题讨论】:
你查看注册表了吗? 我现在有,注册表中没有,但我想我找到了偏好 A hack:保存文件的副本,更改首选项设置(取消选中“保持井井有条”框),保存第二份副本,做一个差异......也许你可以看到区别? 谢谢,这有点帮助 这看起来像 base64 编码的二进制文件。我意识到这并没有多大帮助——但AAA
= 0x00
和AQA
= 0x10
。我不认为这完全是巧合。不幸的是,这可能是特定结构的二进制图像......我不知道结构是什么。如果你愿意,我可以帮你把它变成二进制格式。不确定它是否真的有帮助。
【参考方案1】:
我复制了打开和关闭设置的 iTunesPrefs.xml,然后比较了差异。
检查后(真)
Base64 编码:AAIAAAAAAAEAAAAGAQAA/////wEAAHoAAP////8EAEYAbABhAHQAAAAAAAAA
十六进制值:02 01 06 01 01 7a 04 46 6c 61 74
不检查(假)
Base64 编码:AAIAAAAAAAEAAAAGAQAA/////wEAAHsAAP////8EAEYAbABhAHQAAAAAAAAA
十六进制值:02 01 06 01 01 7b 04 46 6c 61 74
这包含在 Preferences:130 下,这些值是如何存储的我不知道,也许你可以在这找到一些东西。考虑使用命令行查找文件中的差异,diff
用于 linux 或 fc
用于 Windows。
我知道这不是答案,但这不适合评论。
【讨论】:
以上是关于如果 Itunes:Keep iTunes Folder Organized 在 Windows 上以编程方式设置,我该如何解决的主要内容,如果未能解决你的问题,请参考以下文章
如果我们只需要更改 iTunes 应用程序图标,我们是不是需要上传新版本?