gpt4 book ai didi

java - 如果 Itunes :Keep iTunes Folder Organized is set programmatically on Windows,我该如何解决

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:37:38 25 4
gpt4 key购买 nike

如果 Itunes:Preferences:Advanced:Keep iTunes Folder Organized 在 Windows 上以编程方式设置,我该如何解决,我与 iTunes 交互的 Java 应用程序需要知道这一点。

不幸的是,iTunes xml 文件或 Itunes COM API 似乎都没有提供此信息,我认为是因为它们是存储在其他地方的首选项但是我如何才能确定是否启用,我还需要知道这个 添加到资料库时将文件复制到 iTunes Media 文件夹

更新:注册表中没有任何内容,但我找到了一个首选项文件

C:\Users\用户名\AppData\Roaming\Apple Computer\iTunes

但是它似乎是加密/编码的,我不知道如何读取值

更新 2:

保存文件的副本,添加到库时更改将文件复制到iTunes Media Folder的值并进行比较并发现变化

<key>Documents:132</key>
<data>
AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAV09SQjQAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAACwf6jgsOrUhX8BAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</data>

但正如您所看到的,很难发现差异,而且我担心如果我破解了这个 valkue,它可能会在 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 key 中提取 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)

optionBase54Data:AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAV09SQjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAADUXX4fAc2UWH8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=

加上嵌入输出

WORB4

�]~͔X

可以在此处找到 iTunes 首选项文件的示例

http://www.jthink.net/jaikoz/scratch/iTunesPrefs.xml

最佳答案

我复制了打开和关闭设置的 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

这包含在 Preferences:130 下,我不知道这些值是如何存储的,也许你可以找到一些关于这个的东西。考虑使用命令行查找文件中的差异,diff 用于 linux 或 fc 用于 windows。

我知道这不是答案,但这不适合发表评论。

关于java - 如果 Itunes :Keep iTunes Folder Organized is set programmatically on Windows,我该如何解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17957433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com