How do I edit sources xml to change my library from a NAS to an attached USB3 drive?
#1
Music 
I want to change the source of my music library from a NAS to an attached USB drive. I have copied the music from the NAS to the USB drive and the folder structure is identical on both. The music is within a folder "Shared Music" on both drives. I am trying to avoid rescanning the music library and hope that I can get this task done by editing the sources xml file located within the userdata folder.

Is it a simple matter of editing the two references to the path to my NAS to that of the USB drive? If so I have a problem in that I am unable to see the path of the USB drive. When running Kodi I can see the path of my NAS if I use the context menu button when the NAS source is highlighted. I can click the "edit source" option and it shows the path. There is no equivalent for the USB attached drive. Any suggestions as to what to type for the path to the USB drive?

Is there anything else I would need to do?

I am using Kodi Leia 18.8 (Libreelec 9.2.5) on a Raspberry Pi 4, but I don't believe that is significant. I only use Kodi for music.. Here is my sources xml file

xml:
<sources>
    <programs>
        <default pathversion="1"></default>
    </programs>
    <video>
        <default pathversion="1"></default>
    </video>
    <music>
        <default pathversion="1"></default>
        <source>
            <name>WD-NAS</name>
            <path pathversion="1">nfs://192.168.0.201/nfs/Public/Shared Music/</path>
            <allowsharing>true</allowsharing>
        </source>
    </music>
    <pictures>
        <default pathversion="1"></default>
    </pictures>
    <files>
        <default pathversion="1"></default>
        <source>
            <name>Shared Music</name>
            <path pathversion="1">nfs://192.168.0.201/nfs/Public/Shared Music/</path>
            <allowsharing>true</allowsharing>
        </source>
    </files>
    <games>
        <default pathversion="1"></default>
    </games>
</sources>
Reply
#2
(2020-09-27, 21:40)jac55 Wrote: I have copied the music from the NAS to the USB drive and the folder structure is identical on both.

No, actually it is not. The 'problem' is that Kodi stores the full path of your media files, including the network and/or drive path from your device/server system.
The sources.xml file is only part of the problem. There are at least 3-4 tables in the Music database that also refer to paths used in your music collection.

So unless you know your way around SQL, you'll need to take the long way home. Just like with the video database, you could do a Music Library Export, so all metadata is saved in nfo files. That way, you can later restore the media collection without much hassle.™
Reply
#3
(2020-09-27, 21:40)jac55 Wrote: I am trying to avoid rescanning the music library and hope that I can get this task done by editing the sources xml file located within the userdata folder.

Is it a simple matter of editing the two references to the path to my NAS to that of the USB drive?
No, that approach will not work.

You could mess with lots of SQL if you are technically competent, but the simple approach is to create your music library by scanning the tag data embedded in the music files.
  • Take a backup copy of your mymusic72.db file just in case you miss a step.
  • You can also avoid refetching the additional artist and album information and artwork from remote sites by exporting this data and artwork first. Data can be exported either to separate nfo files (so it is picked up on rescanning) or to a single xml file that you can later import. It is must faster to pick this data up locally than request it again from the remote sites, and ensure you keep the same art choices etc.
  • To keep the transient song playback history data (playcount, lastplayed date and user rating) you want to export that to xml as well, and import to the newly scanned library.
  • That all done, drop the current music source(s)
  • Clean the library (Settings>media>library music section <- scroll down)
  • If you have not created separate nfo files (but a single xml) you may want to disable "Fetch additional data on update" setting so that artist and album info doesn't get requested from remote sites (this takes far longer than the tag scanning)
  • Add new music source(s) and scan into library.
  • Import the previously exported xml file especially song playback history

Not just like with the video library - music library is based on embedded tag data, nfo or xml exports can be used to preserve additional artist and album info only (not the library) and you can restore the playback history (recreating you video library loses that kind of transient data).

Good luck
Reply
#4
Thanks @Klojum and @DaveBlake for your very useful responses. I will export the additional artist info and backup where advised. I will rescan the library as suggested probably using a separate micro SD Card. Two separate SD cards holding the two different configurations seems like a good way to go, just in case I ever go back to the NAS as a source.
Reply

Logout Mark Read Team Forum Stats Members Help
How do I edit sources xml to change my library from a NAS to an attached USB3 drive?0