如果在Windows上以编程方式设置 Itunes:首选项:高级:保持iTunes文件夹组织,我该如何解决?我与iTunes交互的Java应用程序需要知道这一点。
不幸的是,iTunes xml文件或Itunes COM API似乎都没有提供这些信息,我认为它是因为它们是存储在其他地方的偏好但我怎么能知道是否启用了,我还需要知道这个添加到库
时,将文件复制到iTunes Media Folder更新 注册表中没有任何内容,但我找到了一个首选项文件
C:\ Users \ username \ AppData \ Roaming \ Apple Computer \ iTunes
然而它似乎是加密/编码的,我不知道如何读取值
更新2:
保存了一份文件副本,在添加到库时将复制文件的值更改为iTunes Media文件夹并进行了比较并获得了更改
<key>Documents:132</key>
<data>
AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAEAAACwf6jgsOrUhX8BAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</data>
但是你可以看到很难发现差异,并且我很担心如果我攻击这个版本它可能会在iTunes版本之间中断,是否有办法解码这个文件?
更新3
我发现Apache Commons Configuration支持Apples plist格式为Xml格式http://commons.apache.org/proper/commons-configuration/apidocs/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.html但不幸的是这里使用的二进制格式。
我编写了这段列出所有密钥的代码,然后尝试解码位置属性,因为我知道这只包含一个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键中提取base64encoded数据,但不幸的是尝试解码这个base64encoding并没有真正让我到任何地方,也许我只会必须在启用/禁用标志时查找base64encoded数据的差异。
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)
optionBase54Data:AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAV09SQjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAADUXX4fAc2UWH8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA =
加上嵌入输出
WORB4
和
]〜X
可以在此处找到iTunes偏好文件的示例
答案 0 :(得分:0)
我复制了iTunesPrefs.xml并打开和关闭了设置,然后比较了差异。
选中它(真实)
Base64编码:AAIAAAAAAAEAAAAGAQAA ///// wEAAHoAAP //// 8EAEYAbABhAHQAAAAAAAAA
十六进制值:02 01 06 01 01 7a 04 46 6c 61 74
未检查(false)
Base64编码:AAIAAAAAAAEAAAAGAQAA ///// wEAAHsAAP //// 8EAEYAbABhAHQAAAAAAAAA
十六进制值:02 01 06 01 01 7b 04 46 6c 61 74
这包含在首选项:130中,这些值是如何存储的我不知道,也许你可以在这里找到一些东西。请考虑使用命令行查找文件中的差异,对于Linux diff
或对于Windows,fc
。
我知道这不是答案,但这不符合评论。