I am in the process of converting a Python program to a macOS app and I am now able to read the Apple Music library directly using the ITunesLibrary Framework. I was reading the exported XML library in python and keyed all my music to the persistentID property, which I still want to do. However, my data file that needs to be converted has the persistentID stored as a string type value because that is how iTunes/Apple Music exports the XML file. The ITunesLibrary Framework retrieves the persistentID as a NSNumber type value.
I did a little digging to see if there was a conversion method between the two so I can run a script on my data file and convert all the persistentID string types to NSNumber types. What I found does not work. It returns nil.
// The two below persistID's are for the same song.
var XMLPID = "7C9C79C87E3BEE04" // <--- persistentID from the XML file
var ITLPID:NSNumber = 8979185659088203268 // <--- persistentID from the ITL Framework
// I found this in another discussion here:
let convertedPID = NumberFormatter().number(from: XMLPID)
print("XML PID = \(XMLPID)")
print("Converted PID = \(convertedPID)")
Appreciate any help in getting this to work.