0

I have written an app to help me sync my music from iTunes to other devices, but since I have upgraded to Catalina, I am getting the wrong path to my library.

import Foundation
import iTunesLibrary

class ItunesHelper {
    var library: ITLibrary;

    init(library: ITLibrary) {
        self.library = library;
        print(library.mediaFolderLocation) // Optional(file:///Users/Midori/Music/1iTunes/iTunes%20Media/)
        print(library.musicFolderLocation) // Optional(file:///Users/Midori/Music/1iTunes/iTunes%20Media/)
    }
}

I'm not sure, what the problem is, but my iTunes folder is called 1iTunes and I don't know, why there is a 1 in front of the folder name. I have checked my old xml files and haven't found anything. I can't open the new Music app library file unfortunately, but Music (the new iTunes) does show the correct path in the library and everything is playing fine.

I have tried another project and I get the same results. Does anybody know, what the problem could be here?

edit: I just played around with my music library's location and I can see, that the actual location I'm getting from the music app has absolutely no influence on the location I am getting from the ITLibrary's musicFolderLocation. So I assume it must be getting it from somewhere else... the question is, where?

Thanks!

Slawa
  • 31
  • 5
  • Did you ever get this to work? If so, can you please post an answer? I'm struggling to get this framework to work in XCode 11.5/Swift 5.2 using Catalina 10.15.5 and Apple Music. My default library is on an external drive. I read somewhere that there is a bug in the frameworks that doesn't work with external drives. – SouthernYankee65 Jun 16 '20 at 22:41
  • Nope, not yet. I actually just ended up using a fixed path (/Users/[user]/Music). Not a clean solution, but it works for now. What path are you getting for your external library? – Slawa Jun 19 '20 at 14:38
  • I keep my library on an SD card along with my source code and I Rsync it routinely to another SD card. The path is "/Volumes/Music/iTunes/iTunes Media/Music/". The weird part is I get the correct location when running the code on my iMac, but when I use my Macbook it throws in a "media.location" in the path /Volumes/Music-1/media.location/Music/". Actually, after typing this I may be on to something...:) – SouthernYankee65 Jun 20 '20 at 20:34
  • Well, let me know, if you find anything. I'd really like to know, what the problem is... – Slawa Jun 21 '20 at 22:04
  • From what I've read in the class documentation, ITLibrary pulls from the default library. What is the default library? It's the last library opened, from what I can tell. I have a library on an SD card and another on my hard drive. If I use – SouthernYankee65 Sep 03 '20 at 18:27
  • I just replied to your question regarding this on the Apple Developers forum. After further thinking, I believe this broke right around the time they changed “iTunes“ to “Music“ and failed to update the code that should be updating that keypath in UserDefaults. As mentioned in my comment in ADF, I don't know the danger of modifying that keypath, but the library media location could be determined, I think, from the location of a media item in the meantime, and possibly update that keypath manually. Maybe doing a diff of the UserDefaults after choosing a new library manually could be done? – SouthernYankee65 Mar 31 '22 at 01:46

0 Answers0