Itunes Import + Errors?

Version 1.20.4.3517

Having issues with iTunes import claiming it is successful and then not actually showing any playlists at all? Only Error(s) I am seeing up front when trying the import that MAY be related are the following:

Couldn’t rename file “C:\Users\afh41\AppData\Local\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.itunes-new.db-shm” to “C:\Users\afh41\AppData\Local\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.itunes.db-shm”: The system cannot find the file specified

Couldn’t rename file “C:\Users\afh41\AppData\Local\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.itunes-new.db-wal” to “C:\Users\afh41\AppData\Local\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.itunes.db-wal”: The system cannot find the file specified

Also the Following:

Any ideas?

Something is broken. I’ve spent quite a few hours getting the iTunes import working. I know I’m getting closer since I’ve read more success stories about how people succeeded and I’m doing the exact same thing.

I’m running PMS ( Version 1.21.2.3943) in docker on a self built NAS with Ubuntu. I’ve got my iTunes library stored on the same NAS, mapped volumes to docker so it can import movies, tv shows and music. And also my iTunes library is on the same NAS.

  • I’ve enabled the iTunes Plugin in Settings → Settings → Plugins.
  • I’ve placed the library.xml in the root of the docker mapped volume and restarted PMS (by restarting the docker container).
  • I’ve verified that the user in the container can read the library.xml on the designated iTunes XML library path as set in the Plugin Settings.
  • I have created a new library of the type “Music” and ticked the check box to import iTunes playlists and ratings and so on.
  • After creation of that iTunes music library in iTunes, I can’t get the “import from iTunes” button to show up, like others seem to have been able to. I’ve restarted the container; no change.

I’ve triggered a re-read of the library.xml file by saving it, so PMS would pick that up and re-read it’s contents:

Jan 31, 2021 20:54:42.498 [0x7f78ea7fc700] DEBUG - File "/opt/library.xml" changed: 2021-01-31 20:48:11 (1612122491) => 2021-01-31 20:54:42 (1612122882).
Jan 31, 2021 20:54:42.498 [0x7f78ea7fc700] INFO - DatabaseLoader::handleChangedFile(0x3b1ab80)
Jan 31, 2021 20:54:42.729 [0x7f78ea7fc700] DEBUG - iTunes: Reading XML files...
Jan 31, 2021 20:54:42.729 [0x7f78ea7fc700] DEBUG - iTunes: Reading XML file: /opt/library.xml
Jan 31, 2021 20:54:44.246 [0x7f78ea7fc700] DEBUG - iTunes: Loading tracks...
Jan 31, 2021 20:54:46.027 [0x7f78ea7fc700] DEBUG - iTunes: Completed reading 2339 tracks in 1.1 seconds.
Jan 31, 2021 20:54:46.028 [0x7f78ea7fc700] INFO - iTunes: loading playlists...
Jan 31, 2021 20:54:46.068 [0x7f78ea7fc700] DEBUG - iTunes: reading tracks from playlist Liza
Jan 31, 2021 20:54:46.076 [0x7f78ea7fc700] DEBUG - iTunes: read 30 tracks for playlist Liza
Jan 31, 2021 20:54:46.076 [0x7f78ea7fc700] DEBUG - iTunes: reading tracks from playlist CD 01
Jan 31, 2021 20:54:46.082 [0x7f78ea7fc700] DEBUG - iTunes: read 22 tracks for playlist CD 01
...
Jan 31, 2021 20:54:46.258 [0x7f78ea7fc700] DEBUG - iTunes: reading tracks from playlist 03 Rock songs
Jan 31, 2021 20:54:46.311 [0x7f78ea7fc700] DEBUG - iTunes: read 176 tracks for playlist 03 Rock songs
Jan 31, 2021 20:54:46.311 [0x7f78ea7fc700] DEBUG - iTunes: reading tracks from playlist 04 Top 40 songs
Jan 31, 2021 20:54:46.483 [0x7f78ea7fc700] DEBUG - iTunes: read 587 tracks for playlist 04 Top 40 songs
Jan 31, 2021 20:54:46.484 [0x7f78ea7fc700] DEBUG - iTunes: reading tracks from playlist 06 Dance songs
Jan 31, 2021 20:54:46.533 [0x7f78ea7fc700] DEBUG - iTunes: read 193 tracks for playlist 06 Dance songs
...
Jan 31, 2021 20:54:46.848 [0x7f78ea7fc700] DEBUG - iTunes: reading tracks from playlist X-mas
Jan 31, 2021 20:54:46.870 [0x7f78ea7fc700] DEBUG - iTunes: read 82 tracks for playlist X-mas
...
Jan 31, 2021 20:54:46.879 [0x7f78ea7fc700] INFO - iTunes: done loading 39 playlists and 2 folders in 0.6 seconds.
Jan 31, 2021 20:54:46.967 [0x7f78ea7fc700] INFO - iTunes: parsed library in 1.8 seconds.
Jan 31, 2021 20:54:46.967 [0x7f78ea7fc700] DEBUG - Loading com.plexapp.plugins.itunes is complete (success=1)

So far so good you would say; the library.xml file was re-read and parsed successfully. But right after the last log line above, this is shown:

Jan 31, 2021 20:54:47.137 [0x7f78ea7fc700] ERROR - Couldn't rename file "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.itunes-new.db-shm" to "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.itunes.db-shm": No such file or directory
Jan 31, 2021 20:54:47.137 [0x7f78ea7fc700] ERROR - Couldn't rename file "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.itunes-new.db-wal" to "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.itunes.db-wal": No such file or directory
Jan 31, 2021 20:54:47.149 [0x7f78ea7fc700] DEBUG - iTunes: There are 2335 audio tracks and 4 video tracks.

And that’s it. I’m positive that this “renaming error” is the root cause I’m not seeing the playlists and ratings I’ve carefully curated the past decade. When I examine the contents of the /config/Library/Application Support/Plex Media Server/Plug-in Support/Databases directory, the “new” versions of the com.plexapp.plugins.itunes-new.db-shm and com.plexapp.plugins.itunes-new.db-wal indeed aren’t there. So it’s no wonder there is a renaming error. The “old” versions are present though:

root@6a354daeb41e:/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases# ls -la 
total 221788
drwxr-sr-x 2 abc users     4096 Jan 31 21:08 .
drwxr-sr-x 7 abc users     4096 Dec 18 16:28 ..
-rw-r--r-- 1 abc users  6197248 Jan 31 20:51 com.plexapp.dlna.db
-rw-r--r-- 1 abc users    32768 Jan 31 20:51 com.plexapp.dlna.db-shm
-rw-r--r-- 1 abc users  6233592 Jan 31 20:51 com.plexapp.dlna.db-wal
-rw-r--r-- 1 abc users  1691648 Jan 31 21:08 com.plexapp.plugins.itunes.db
-rw-r--r-- 1 abc users    32768 Jan 31 21:08 com.plexapp.plugins.itunes.db-shm
-rw-r--r-- 1 abc users        0 Jan 31 21:08 com.plexapp.plugins.itunes.db-wal
-rw-r--r-- 1 abc users 30924800 Jan 31 13:04 com.plexapp.plugins.library.blobs.db
-rw-r--r-- 1 abc users   764928 Jan 21 02:00 com.plexapp.plugins.library.blobs.db-2021-01-21
-rw-r--r-- 1 abc users   336896 Jan 24 02:00 com.plexapp.plugins.library.blobs.db-2021-01-24
-rw-r--r-- 1 abc users 22030336 Jan 27 02:04 com.plexapp.plugins.library.blobs.db-2021-01-27
-rw-r--r-- 1 abc users 21970944 Jan 30 02:01 com.plexapp.plugins.library.blobs.db-2021-01-30
-rw-r--r-- 1 abc users    32768 Jan 31 20:50 com.plexapp.plugins.library.blobs.db-shm
-rw-r--r-- 1 abc users        0 Jan 31 20:50 com.plexapp.plugins.library.blobs.db-wal
-rw-r--r-- 1 abc users 36726784 Jan 31 20:50 com.plexapp.plugins.library.db
-rw-r--r-- 1 abc users  6181888 Jan 21 02:00 com.plexapp.plugins.library.db-2021-01-21
-rw-r--r-- 1 abc users 12057600 Jan 24 02:00 com.plexapp.plugins.library.db-2021-01-24
-rw-r--r-- 1 abc users 40479744 Jan 27 02:04 com.plexapp.plugins.library.db-2021-01-27
-rw-r--r-- 1 abc users 37710848 Jan 30 02:01 com.plexapp.plugins.library.db-2021-01-30
-rw-r--r-- 1 abc users    32768 Jan 31 21:38 com.plexapp.plugins.library.db-shm
-rw-r--r-- 1 abc users   657128 Jan 31 21:38 com.plexapp.plugins.library.db-wal
-rw-r--r-- 1 abc users     4096 Jan 30 22:00 com.plexapp.plugins.trakttv.db
-rw-r--r-- 1 abc users    32768 Jan 31 20:51 com.plexapp.plugins.trakttv.db-shm
-rw-r--r-- 1 abc users  2933472 Jan 31 20:51 com.plexapp.plugins.trakttv.db-wal

So what’s going on here? Anyone got a clue?

– EDIT –
I’ve used sqlite3 to open the com.plexapp.plugins.itunes.db database to see if any content is in there, and there is… From the looks of it, all of the library.xml info is stored in the sqlite database. But it’s not imported or at least “visible” in the Plex web interface or iPhone app.

Any clues? Anyone?

I believe I’ve found what’s broken: my skill to be patient, persist and combine all the facts and results I’ve found the past few days. Apparently it’s not a “set here and be done with it” configuration. There are a lot of steps involved to get things right.

  1. get your music on the right location on your NAS, verify the path from the view of the docker container. (/opt in my case)
  2. enable the iTunes Plugin in Settings → Settings → Plugins
  3. enter the correct path of the iTunes library.xml you exported from Catalina’s Music app. Remember that this path must be correct from the view of the docker container. (/opt/library.xml in my case)
  4. restart PMS (the docker container in this case).
  5. create a new library in PMS of the type “Music” and name it as you like, select the folder in which it is stored and tick the check box “Import from iTunes”. Let PMS do the import, might take a while.
  6. While PMS is importing your music, you need to “search and replace” a path in the library.xml file, so that from the point of view of the docker container, the full path to the tracks are correct. Take your favorite editor to do that. It depends on what your full path currently is from the point of view of iTunes or Catalina’s Music app. When you’re already using your iTunes library on the NAS, than you probably have something like this: file:///Volumes/iTunes/iTunes%20Music/. This Music Folder is in the top of the library.xml file:
<key>Music Folder</key><string>file:///Volumes/iTunes/iTunes%20Music/</string>

An example of a fresh export of iTunes/Catalina’s Music app:

<key>Location</key><string>file:///Volumes/iTunes/iTunes%20Music/Music/Dj%20Sputnik/Club%20Play%20Dance%2003/1-11%20Africa.mp3</string>

As in my “/opt” example: what you need to do, is search and replace ALL occurrences of

Volumes/iTunes/iTunes%20Music/Music

with

opt

So in my case the example from my library.xml will look like this:

<key>Location</key><string>file:///opt/Dj%20Sputnik/Club%20Play%20Dance%2003/1-11%20Africa.mp3</string>

Now I’ve seen people using a Synology or QNAP NAS that had to use localhost as a prefix, like so

file://localhost/opt

That didn’t work in my case, I got messages of saying tracks couldn’t be found, wrong path. I guess that could be related to how Synology or QNAP run their PMS or dockerized version of PMS.

  1. Once you’ve replaced all occurrences of the file path from the iTunes-point-of-view, to the docker-point-of-view in the library.xml file, save it, or transfer it the location you specified in step 3. PMS should pick that change up automatically. You might see error messages about this new version of com.plexapp.plugins.itunes-new.db-shm that couldn’t be found, but apparently that’s not a showstopper after all :grin:
  2. Now comes a part that’s hard to describe exactly. The ONLY way to make this iTunes import actually work seems to be from the Playlist “menu” under the Home screen of Plex. Now if you don’t see that Playlist menu pinned to the sidebar, you probably don’t have any playlist at all. You need to create a music playlist first. It doesn’t matter what’s in it, as long as you have at least one playlist with one track in it, only then this Playlist menu will appear on the side bar. And it might not appear instantly, It can take a few minutes to show up. And it might only show up, when you click on the “More” section on the side bar. When the Playlist menu option shows up, pin it to the side bar (and rearrange it if you like). When it’s visible, you can select “Import from iTunes” when you click on the three dots (Actions). A dialog box pops up and you can select your options. If you’ve set your paths correctly, PMS will first import all your playlists and then it will update metadata on your tracks.
  3. In my case I got an error after a while on that dialog box saying: “Something went wrong. Make sure the server is available and try again”. But in the PMS log I could see it was still updating metadata and after a few minutes:
Jan 31, 2021 22:54:36.328 [0x7f786d7fa700] DEBUG - Updating metadata item (save) (2 Brothers on the 4th Floor) with ID 36271
Jan 31, 2021 22:54:36.331 [0x7f786d7fa700] DEBUG - Updating metadata item (save) (W&W) with ID 36281
Jan 31, 2021 22:54:36.335 [0x7f786d7fa700] DEBUG - Updating metadata item (save) (Thirty Seconds to Mars) with ID 36284
Jan 31, 2021 22:54:36.339 [0x7f786d7fa700] DEBUG - Updating metadata item (save) (The 1975) with ID 36292
Jan 31, 2021 22:54:36.344 [0x7f786d7fa700] DEBUG - iTunes importer imported data for 2269 of 2339 tracks.
Jan 31, 2021 22:54:36.351 [0x7f78ebfff700] DEBUG - Completed: [192.168.1.11:53846] 200 PUT /playlists/import/itunes?sectionID=14&force=1 (8 live) TLS GZIP 153810ms 274 bytes (pipelined: 2)

Presto! :star_struck: All my playlists are created and my ratings are imported too! :partying_face:

Amazing that you spent all the time figuring this out and plex won’t do anything about it. Still broken.