Post

Replies

Boosts

Views

Activity

What APIs can be used to modify the Music.app library?
Hi everyone, I'd like to write a one-off app to make some modifications to my own Music.app (aka iTunes) library. This is for content that I have stored using iTunes Match, so it's effectively a library that dates back to the iTunes years. However, from what I can see, APIs with modification support are essentially... nothing? I can get everything ready in a simple Swift command-line app using https://developer.apple.com/documentation/ituneslibrary, however I can't actually write any changes. It seems that the only modification solution available is actually still AppleScript. Everything there still works, and in theory I could do the majority of the logic using iTunesLibrary and then do the modifications with AppleScript via NSAppleScript. In order to do this, I just need an identifier that I can use to correlate items from each API. There is: iTunesLibrary: https://developer.apple.com/documentation/ituneslibrary/itlibmediaentity/1809728-persistentid AppleScript Item object for AppleScript has a "persistent ID" property which sounds like the same thing There's also an id property However, in my experiments it didn't appear that any of these correlated together Of course, I could possibly re-write the whole thing using AppleScript, but that would be slow and painful! So, posting here to see if anyone has any idea how or even if this can be done. Hope someone can help! Thanks in advance
0
0
566
Feb ’24
Exclude by mediaSubtype is broken
Hi all,It would seem that this is a clear bug in the Photos framework: using PHFetchOptions with a predicate works great for *selecting* particular mediaSubtypes, but as soon as one tries to *exclude* a subtype, nothing is returned. Better explained with code:// control: entire library let library = PHAsset.fetchAssetsWithMediaType(.Image, options: PHFetchOptions()) print("Entire library: \(library.count)") // expected result: PHAssetMediaSubtype.PhotoScreenshot *only* // actual: works fine let options1 = PHFetchOptions() options1.predicate = NSPredicate(format: "(mediaSubtype & %d) != 0", PHAssetMediaSubtype.PhotoScreenshot.rawValue) let result1 = PHAsset.fetchAssetsWithMediaType(.Image, options: options1) print("Screenshots: \(result1.count)") // expected result: all types *except for* PHAssetMediaSubtype.PhotoScreenshot // actual: returns nothing let options2 = PHFetchOptions() options2.predicate = NSPredicate(format: "(mediaSubtype & %d) == 0", PHAssetMediaSubtype.PhotoScreenshot.rawValue) let result2 = PHAsset.fetchAssetsWithMediaType(.Image, options: options2) print("Not screenshots: \(result2.count)") // expected result1 + result2 = library assert(result1.count + result2.count == library.count)Output on a fresh simulator with one imported screenshot:Entire library: 12 Screenshots: 1 Not screenshots: 0 assertion failed: : file /Users/jc/Desktop/LibraryPredicate/LibraryPredicate/ViewController.swift, line 36Assertion fails on device as well.This would appear to be a common issue:https://forums.developer.apple.com/message/110146#110146http://stackoverflow.com/questions/31528441/how-to-to-filter-by-media-subtype-using-nspredicate-with-phfetchoptionshttp://stackoverflow.com/questions/35229279/phfetchoptions-mediasubtype-predicatehttp://stackoverflow.com/questions/31939082/nspredicate-to-exclude-slow-motion-videos-from-phfetchresultsI'd love to report this as a bug, but the bug reporter is not responding right now. *sigh*
4
1
1.7k
Mar ’16