MySQL/Setting up Kodi

From Official Kodi Wiki
< MySQL
Revision as of 16:30, 5 December 2013 by Revnoah (talk | contribs) (moved the xml markup to the correct location; removed now-unnecessary note about skipping a step)
Jump to navigation Jump to search
Emblem-important-yellow.png NOTICE:
Since it seems that using "single file" export/import might be having issues with the image URLs for thumbnails in XBMC v12, this page of the MySQL guide has been recently simplified to say just use multiple file export as a safe method to both update the library to use network paths and to import the library for MySQL.

HOW-TO:Sync multiple libraries/Contents

Each device that will be sharing a library will need an advancedsetting.xml file.


Make files accessible over the network

If you haven't already done so, you will need to make your media files accessible to all your XBMC devices by sharing them on the network through file sharing. XBMC itself or the MySQL server will not share the actual files for this set up. Most operating systems have built-in methods for sharing files to the network, or a NAS device can be used.


Note:

  • If you use passwords on your network shares then you will need to copy (or sync) your passwords.xml file from the userdata folder to each XBMC device.
  • Do not use mapped drives on the OS-level, as XBMC will see those as local drives.
  • If you use smb:// paths, you may want to use static IP addresses rather than NetBIOS names, as not all your devices may be able to resolve the later.
  • Even if the media is on the same computer as one of the XBMC instances, you MUST use a network share path. You cannot use a local file path with MySQL.


See Category:File Sharing for some of the file sharing methods that work with XBMC.

Exporting

  1. Open XBMC on the computer that has the library you want to share
    1. Export the Video Library by doing the following:
      1. Go to System/Settings -> Video -> Library and select Export library
      2. Select Multiple files
    2. Export the Music Library by doing the following:
      1. Go to System/Settings -> Music -> Library and select Export library
      2. Select Multiple files

MySQL and advancedsettings.xml

advancedsettings.xml:
<advancedsettings>
    <videodatabase>
        <type>mysql</type>
        <host>***.***.***.***</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
    </videodatabase> 

    <musicdatabase>
        <type>mysql</type>
        <host>***.***.***.***</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
    </musicdatabase>

     <videolibrary>
          <importwatchedstate>true</importwatchedstate>
     </videolibrary>
</advancedsettings>

See also this note about using the <name> tag: #Name tag
<importwatchedstate> is only needed when you're importing a previous library from exported files.

  1. Create (or add to, if you already have one) an advancedsettings.xml file:
    1. Open up a plain text editor
    2. Copy and paste the text from the right-hand box into a new text document
    3. Replace the two instances of ***.***.***.*** with local network IP address of your MySQL server. If you installed MySQL on a Windows machine, do not use its NetBIOS name, as not all devices may be able to resolve them.
      Note: See Advancedsettings.xml#.3Cmusicdatabase.3E.2F.3Cvideodatabase.3E for various technical details about the advancedsettings.xml tags.
    4. Save the file as advancedsettings.xml
  2. Copy this advancedsettings.xml file you just created to the userdata folder of every XBMC install you want to sync with.

Adding network sources

  1. If you have a pre-existing local source, remove that source first
  2. Add videos to the library but instead of adding a local folder, choose Windows Network (SMB). Then, select the shared network folder that you set up previously.
    Note: You must add a network source using XBMC's standard formatting. For example, use "smb://192.168.1.20/Videos/" and not "\\BOBPC\Videos\". Also, do not use the OS to mount network shares as local drives and try to use static IP addresses over NetBIOS names. You may need to activate Windows Sharing on MacOS X or install and configure samba on Linux.
  3. Add music to the library as described above. Again, you'll end up with an identical library.

You can now add files and update the library from any of your XBMC devices and the library for all of them will stay in sync.

Importing

If you have exported your library to multiple nfo files as described above, they will be automatically imported when adding the network source. The end result will be an identical library, and your watched status for videos will be preserved. The database will now store a reference to the network location of the video, which will be the same when accessed from every XBMC install on your network.

Name tag

An additional <name> tag can be used for both the video and music entries in advancedsettings.xml if you want to change the name of the database.

The name tag is not required (XBMC will use a default "MyVideos" and "MyMusic" DB name) and it is recommended to not include it if you only need one library, as some users have reported problems/bugs when it was included.

The tag is only needed if you want to have separate databases on the same MySQL server, like for more than one shared library. For example, if you want to create multiple profiles, each with their own shared library, so that each XBMC device can "log-into" that library.