Page 1 of 1

XBMC and MySQL – All rooms in sync!

XBMC and MySQL – All rooms in sync!
   26

One of the really nice features of XBMC is that it has the means to provide additional information on TV-Series, Movies and/or Music.

XBMC does not only work with the background info or synopsis of a movie or TV Series/Episode, it also remembers which ones you have seen, and even where in a movie you stopped – so that at a later time you can resume where you left of.

There is one little bummer to this though … the XBMC in my living-room is not sharing this the XBMC in my bedroom – and this is where MySQL comes in play.




The “Ideal” XBMC setup …

I found the ideal XBMC setup to be the one where you have:

  • One (or more) network location containing all the media.
    For example a NAS box (QNAP for example), a Windows setup with a shared media folder, a Linux box running FreeNAS, etc.
  • One or more XBMC PC’s throughout the house.
    They should all be running exact the same version of XBMC, but can be running on different operating systems.
Sharing files on the XBMC boxes themselves works as well, but can make things more complicated – specially when you’d like to sync them as described here. In this article, I’m going to assume that you’re working with a setup like this: one central network share, and one or more XBMC HTPC’s.

Installing MySQL

MySQL is a freely available, yet powerful database engine intended for server use – you wouldn’t know, but the majority of webservers actually utilize MySQL to run their dynamic content. Recent changes in XBMC make it possible to use MySQL for storing information that can be shared amongst several other XBMC setups in your house. Setting up MySQL is straight forward and you might already have it … for example my QNAP NAS already comes with MySQL pre-installed (it just needs enabling).

Here is my article on How to install MySQL, Web-Server, and phpMyAdmin on your QNAP.

MySQL is available other platforms as well: Windows, Linux, MacOS X.
You could of course decide to manually install MySQL – go to this link and select the OS (not needed for a QNAP NAS). I do however strongly recommended (not needed for a QNAP NAS setups) to use one of the many AMP (Apache, MySQL, PHP) packages (most are free);

  • WAMP Server for Windows, or
  • XAMPP for multiple platforms including Windows, MacOS X and Linux.
  • MAMP for MacOS X (OS X Server already comes with MySQL)

 

The advantage being that it’s easy to install and they all come with phpMyAdmin preinstalled – which makes maintaining MySQL and running queries so much easier straight from any web-browser. The disadvantage (?) might be that Apache (webserver) will be installed as well (disk-space / minimal CPU load).

But … I don’t want to use phpMyAdmin! 

If you decide to use a setup without phpMyAdmin then make yourself familiar with how to access MySQL from the command line on your system (or get a program like EMS MySQL Manager or DevArt SQL Studio, or the free HeidiSQL), see the MySQL documentation for details on your system since you will have to manually (in a shell) go to the mysql command line tool for execute a few SQL statements.

The typical command for all systems is: mysql -u username -p
(replace username with your actual username, the -p will make MySQL ask for your password)

Firewalls 

On some systems (Windows migth be one of those) you will have to make sure that the port (default: 3306) you’re using for database access is not blocked by your firewall.

Preparing a Database

XBMC Version 

I’m assuming XBMC Eden (v11) or newer for this article ….
Older XBMC versions will work the same way for SVN version R28117 or above, but might require you to run two additional SQL statements!

Upgrading to a newer version of XBMC or KODI 

Note that when you upgrade to a newer version of KODI/XBMC that the database will be re-created for that particular version.
This could mean that your Kodi starts a little slow the first time, just let it be and do it’s thing.

Based on the following instructions you will give XBMC the access to the database it needs to create those databases, the needed tables, and eventually your library data.

The Short Version

Go to phpMyAdmin and click the “SQL” tab. In the upcoming text-box type (or paste) the following SQL statements and click the “Go” button in the lower right corner to execute the SQL statements:


1
2
CREATE USER 'xbmc' IDENTIFIED BY 'xbmc';
GRANT ALL ON *.* TO 'xbmc';

What does this do?


CREATE USER 'xbmc' IDENTIFIED BY 'xbmc';

Translated: Create the user “xbmc” with the password “xbmc

PHPMyAdmin/MySQL - Create a user for XBMC

PHPMyAdmin/MySQL – Create a user for XBMC

After execution, PHPMyAdmin will jump back to the PHPMyAdmin start page – unless you somehow made a typo. You can click the tab “Privileges” and under the “User Overview”  you should now see (at the bottom) the user “xbmc“.

Note: I used the password “xbmc” in this example (without the quotes, right after “IDENTIFIED BY”), feel free to use a different password if you’re concerned with security. Make sure to use that new password consistently throughout the next steps.


GRANT ALL ON *.* TO 'xbmc';

Again a loose translation: Grant the user “xbmc” full access

This will give the user “xbmc” sufficient access to create and modify databases.

OK, so from a MySQL perspective we’re set …

CAUTION 

These instruction assume you use XBMC Eden (v11)!

Older versions might require you to run two additional SQL statements to create the actual databases (Eden will do this automatically):


1
2
CREATE DATABASE xbmc_video;
CREATE DATABASE xbmc_music;

Moving to a newer XBMC version … 

When moving to a newer version of XBMC, it can happen that the newer version (Eden and newer) will copy the data of the old database to a new database. The new database, to be used by the newer XBMC version, will have the same name followed by a 2 digit number.

For example: xbmc_music (old – will remain untouched) will be copied into xbmc_music18 (new – will now be used).

Configure your XBMC setup(s)

Consistent Paths! 

All XBMC’s – Use the exact same paths to Movies, Music, and TV-Series!

Before we proceed with the MySQL connection for our XBMC boxes we should make sure that the path to our Movies, Music, and TV-Series are consistent for all XBMC’s you’re using. So make sure that all “sources” for all your XBMC HTPC’s are setup equally!

This is a must, otherwise the different paths will be seen as different files!

I recommend starting with 1 single XBMC setup. Make clear notes on what shares (path) have been setup for the different sources and media types – we want to replicate those on the other XBMC’s.

Another reason to start with just 1 XBMC box is that we can use PHPMyAdmin to see what XBMC is really saving in the database, and that in turn will give us a better understanding of what might be a reason why certain things do or do not work.

First we need to make sure that we use a version of XBMC that can actually handle all this fun – current versions support this just fine. So just download a recent version (XBMC Download Page or get OpenElec). It is said that SVN version R28117 and above should be good to go (source).

Step 1: Export your current Library (optional)

This is optional, but it might save a lot of time if we simply re-import the hard work once the MySQL Connection is up and running. This way we don’t have to re-scan your entire library and instead use what we already have.

In XBMC go to the “System” menu, select “Settings” → “Video” where you select “Export Library” option. XBMC will now ask if you want to save this as a single file (yes) and where to save it – pick your destination. After the export you’ll find a folder name (something like) “xbmc_videodb_2012-01-23“.

XBMC (Eden/ v11) - System menu - Select Settings

XBMC (Eden/ v11) – System menu – Select Settings

XBMC (Eden/ v11) - Video menu - Export Video Library

XBMC (Eden/ v11) – Video menu – Export Video Library

Step 2: Create a file “advancedsettings.xml”

Open a plain text editor ( Windows: Notepad or Notepad++,  MacOS X: TextWrangler Linux: VI or Nano) and paste the following text, after adapting it to your scenario:

  • Replace 192.168.1.100 with the IP address of your MySQL Server.
  • If you changed the default port number of your MySQL server, then change 3306 to the port number you picked (3306 is the default port, so if you didn’t change it during the MySQL setup, don’t change it here either).
  • Enter the proper username between <user> and </user> (if you did not use the suggested “xbmc”)
  • Enter the correct password between <pass> and </pass> (if you decided to use something else than “xbmc”)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<advancedsettings>
    <videodatabase>
        <type>mysql</type>
        <host>192.168.1.100</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
        <name>xbmc_video</name>
    </videodatabase>

    <musicdatabase>
        <type>mysql</type>
        <host>192.168.1.100</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
        <name>xbmc_music</name>
    </musicdatabase>
</advancedsettings>

<name> no longer needed? 

The name tag (<name>…</name>) appears no longer needed if you’re using one of the more recent versions of XBMC when using only one shared database.

XBMC will chooses it’s own name and add the version number of the database structure after it for example “xbmc_video60” or “xbmc_video67”. When a new database version is being created the old data will be copied into the new database. This is (probably) a result of an experimental stage in which the database structure changes over time. Unfortunate, specially when you use a few different versions of XBMC as it makes quite a mess in MySQL.

It can however be useful if you want to utilize two different databases, for example one for XBMC stations for Adults and one for the Kids.
The use of multiple databases however have been reported to cause issues.

 

Now save this file as “advancedsettings.xml“.

  •  Windows XP
    Move this file to “C:\Documents and Settings\<your_user_name>\Application Data\XBMC\userdata\“.
  •  Windows Vista, 7, 8 and newer
    Move this file to “%APPDATA%\XBMC\userdata” (you can paste this in the Windows Explorer).
  •  MacOS X
    In the Finder, click the “Go” menu and select the “Go to Folder …” option. A window opens saying “Go to the folder”, paste “~/Library/Application Support/XBMC/userdata” (without the quotes of course) in the text box and click “Go“.
    Now move the advancedsettings.xml file to the folder that just opened.
  •  Linux
    The file needs to go into this folder: ~/.xbmc/userdata
    Accessing this under a live version is a little harder, use either SSH access, or press CTRL+ALT+F2 to go to the shell (use CTRL-ALT-F7 to go back to XBMC) and do this all manually with either VI or nano.
    Some great version can be found at XBMCFreak, or you can use the XBMC Live version.
  •  OpenElec
    A shared folder called “userdata” can be found in your network for the machine running OpenElec, drop the file in there and reboot the machine.
    OpenElec is for example available for Linux, AppleTV (1st generation), and Raspberry Pi – they all use the same method which is awesome!
  •  Apple iOS device (iPad, AppleTV2, etc)
    The instructions claim to save the file here (untested!): “/private/var/mobile/Library/Preferences/XBMC/userdata/“.
  •   CrystalBuntu / CrystalHD
    Use SSH to access the file (ssh username@ip-address). The file goes here: “/root/.xbmc/userdata“.

Step 3: Restart XBMC and optionally import the exported library

Shutdown and restart your XBMC HTPC.

If you find that the startup of your XBMC takes forever then please verify a few things:

  • Did you use the right IP address, username, password, and database name in the advancedsettings.xml?
  • Does your server or XBMC box have a firewall that blocks port 3306?
  • Did you execute the SQL statements properly? (most common issue: lack of access rights)
  • Is MySQL actually running?
  • Does your XBMC version support MySQL syncing?
  • Do you have an older XBMC version (Dharma) and did you execute the 2 additional SQL statements (CREATE DATABASE)?

 

If you see in phpMyAdmin that several tables, and maybe even new databases, have been created, then you’re ready to import the previously (optional) export library – the import steps are similar to the previously executed import steps.
phpMyAdmin - XBMC made some tables!

phpMyAdmin – XBMC made some tables!

Repeat step 2 and 3 (use the same advancedsettings.xml file) for your other XBMC boxes – even if they run on different operating systems!

The Result …

After doing this for two XBMC setups;

  1. Running Eden Beta2 on MacOS X Lion
  2. Running a nightly build (also Eden) of OpenElec (Linux) on a dinky AMD E350 computer (Foxconn nt-a3500 – Dutch review)
  3. Running MySQL on my QNAP NAS

 

Now I can see on both machines where I paused, to then resume on the other machine.

XBMC - Machine 1 - MacOS X Eden Beta 2 paused here ...

XBMC – Machine 1 – MacOS X Eden Beta 2 paused here …

XBMC - Machine 2 - OpenElec (nightly build) Wants to resume here ...

XBMC – Machine 2 – OpenElec (nightly build) Wants to resume here …

Tips to prevent or fix issues and make configuration easier

We now have an XBMC setup that syncs with your MySQL database, but little problems might still sneak in and quite a few of them are easy to prevent.

Use the Debug Log!

XBMC knows several levels of debugging and when running into issues, it will be almost required to use.
More information can be found at the following links: XBMC DebugXBMC Geavanceerde Debug, and XBMC advancedsettings.xml debug opties.

DEFAULT DEBUG LOG

If you want to do debugging the default setting is always needed:
The default is enabled in the User Interface: In Settings -> System -> Debugging – toggle the Enable debug logging setting.

ADVANCED DEBUG LOG

The advanced debugging takes a little more effort and generates some very good info.
You will need to add the example code below to your advancedsettings.xml file, where the loglevel (1 in the example) can have the following values:

XBMC Debug LogLevels
 LogLevel What it does …
-1  No logging at all.
0  (Default) Only log errors.
1  Debug logging.
2  Debug logging (shows CPU and Memory on screen).
3  Same a level 2, but adds SMB (Windows shares) logging.

<advancedsettings><loglevel>1</loglevel></advancedsettings>

A few items I ran into or have seen with other users:

  Duplicate entries, not saving where I paused

On one box the server was referred to by it’s name and the other one used an IP address – resulting in two different entries for every file in the database!
This obviously prevented it from marking the proper entry as “wachted”.

For unknown reasons one XBMC box saved a path in the regular format (ie. sbm://<servername>/path), while the other one added username and password (ie. smb://<username>:<password>@<server>/<path>) – obviously again the database stored this as two different files, and again not tracking “watched” properly.

Having to enter sources manually does not only cause these kind of issue, but it is also an cumbersome exercise.
Do it once and copy the proper files saves on work and problems later on due to inconsistency.

  Different databases?

A problem I have not found a good solution for:
Probably the biggest issue I’ve been running into is the different database structures for different versions of XBMC – this unfortunately has not been made backwards compatible and creates additional databases on your MySQL server. Not only does it seem unnecessary, but it also comes with problem, since the newer XBMC and the older XBMC versions will NOT keep those databases in sync.

  Database not populating – Can’t find MySQL

I actually ran into situations where XBMC started quicker than the network when using dynamic IP addresses (DHCP). The network wasn’t up in time so XBMC did not find the MySQL server so the database remained empty. The solution I found (for OpenElec) was to create a file called “autostart.sh” (see example content below) and copy it into the “Configfiles” of your OpenElec XBMC box.

This will give you XBMC box a fixed IP address!

You will of course need to modify line 3 (the new fixed IP address of your XBMC box) and line 4 (the IP address of your modem or router).


1
2
3
4
#!/bin/sh
ifconfig eth0 up
ifconfig eth0 192.168.1.97
route add default gw 192.168.1.1

  Database not populating – Permission Errors

Another reason why the database might not populate is when there are file permission issues with your music or video files.
Easiest way to discover this is with the advanced debugging. You might see messages like seen below.

What happens is that XBMC can see that there are files and folders, which is enough for most scrapers, but I cannot open the file (to determine resoultion, codec, etc).

File permissions can be a tough topic to deal with. One of the visitors of Tweaking4All resolved it by removing ALL sources, and by manually (not using the XBMC filebrowser!) adding them in the format smb://servername/path/to/video.

Since I didn’t experience this issue, I cannot confirm if this is the only and best method – but you will have to look into how XBMC accesses your files and what the access rights are. (reference: XBMC Forum, and OpenElec Forum)


17:44:11 T:2879218784 INFO: FileSmb->Open: Unable to open file :

...

unix_err:'d' error : 'Permission denied'

...

  Rules of thumb that I follow

  • Use the consistent paths when referring to a server for your sources.
  • Refer to a server by it’s IP address for your sources, it appears faster.
  • Setup one XBMC box with all the sources and settings you’d like and then copy the configuration files to the other XBMC boxes (reboot after copying).

 

The following files appear to be crucial in this process:

  • advancedsettings.xml
  • sources.xml
  • passwords.xml

 

  Database speed improvements

For certain versions of XBMC the databases have not been fully optimized for speed. Adding the following indices will give it a little boost (source: OpenElect configure MySQL) – only do this when you know what you’re doing since database structures will be different with different XBMC versions!

XBMC v12 (Frodo) has these indexes already – so no need to add them.

For Video:


1
2
3
ALTER TABLE movie ADD INDEX ix_idFile(idFile);
ALTER TABLE movie ADD INDEX idMovie(idMovie);
ALTER TABLE movie ADD INDEX idFile(idFile);

For Music:
(not applicable for XMBC 12 and newer)


1
2
3
4
5
6
7
CREATE INDEX idAlbum_idx ON song(idAlbum);
CREATE INDEX idArtist_idx ON song(idArtist);
CREATE INDEX idArtist_idx ON album(idArtist);
CREATE INDEX idArtist_idx ON exartistsong(idArtist);
CREATE INDEX idArtist_idx ON exartistalbum(idArtist);
ALTER TABLE song ADD INDEX idArtist(idArtist);
ALTER TABLE song ADD INDEX idGenre(idGenre);

  Speed boost: MyISAM vs InnoDB

I noticed that with XBMC v12 (Frodo) that suddenly database access could be very slow – specially after watching a TV Show Episode and trying to go watch the next episode.

After a lot of tinkering I noticed that the slow down is caused because of two factors:

  • The Database engine used on MySQL was MyISAM (slow performance issues).
  • The XBMC developers chose to use VIEWs (which is not recommended under MySQL).

 

Now without changing the core of XBMC, I have no fix for the use of VIEWs.

I do however have control over the database engine – so I switched to InnoDB and guess what … everything works blistering fast again.
For the brave amongst you, the following SQL will convert all tables to InnoDB:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
ALTER TABLE writerlinkmovie ENGINE=InnoDB;
ALTER TABLE writerlinkepisode ENGINE=InnoDB;
ALTER TABLE version ENGINE=InnoDB;
ALTER TABLE tvshowlinkpath ENGINE=InnoDB;
ALTER TABLE tvshow ENGINE=InnoDB;
ALTER TABLE taglinks ENGINE=InnoDB;
ALTER TABLE tag ENGINE=InnoDB;
ALTER TABLE studiolinktvshow ENGINE=InnoDB;
ALTER TABLE studiolinkmusicvideo ENGINE=InnoDB;
ALTER TABLE studiolinkmovie ENGINE=InnoDB;
ALTER TABLE studio ENGINE=InnoDB;
ALTER TABLE streamdetails ENGINE=InnoDB;
ALTER TABLE stacktimes ENGINE=InnoDB;
ALTER TABLE settings ENGINE=InnoDB;
ALTER TABLE sets ENGINE=InnoDB;
ALTER TABLE seasons ENGINE=InnoDB;
ALTER TABLE path ENGINE=InnoDB;
ALTER TABLE musicvideo ENGINE=InnoDB;
ALTER TABLE movielinktvshow ENGINE=InnoDB;
ALTER TABLE movie ENGINE=InnoDB;
ALTER TABLE genrelinktvshow ENGINE=InnoDB;
ALTER TABLE genrelinkmusicvideo ENGINE=InnoDB;
ALTER TABLE genrelinkmovie ENGINE=InnoDB;
ALTER TABLE genre ENGINE=InnoDB;
ALTER TABLE files ENGINE=InnoDB;
ALTER TABLE episode ENGINE=InnoDB;
ALTER TABLE directorlinktvshow ENGINE=InnoDB;
ALTER TABLE directorlinkmusicvideo ENGINE=InnoDB;
ALTER TABLE directorlinkmovie ENGINE=InnoDB;
ALTER TABLE directorlinkepisode ENGINE=InnoDB;
ALTER TABLE countrylinkmovie ENGINE=InnoDB;
ALTER TABLE country ENGINE=InnoDB;
ALTER TABLE bookmark ENGINE=InnoDB;
ALTER TABLE artistlinkmusicvideo ENGINE=InnoDB;
ALTER TABLE art ENGINE=InnoDB;
ALTER TABLE actors ENGINE=InnoDB;
ALTER TABLE actorlinktvshow ENGINE=InnoDB;
ALTER TABLE actorlinkmovie ENGINE=InnoDB;
ALTER TABLE actorlinkepisode ENGINE=InnoDB;

It should be noted that I you might want to look in the InnoDB settings in your my.cnf file found in /etc/config.
If you did so, a restart of MySQL is needed for it to take effect:


/etc/init.d/mysqld.sh restart

Additional Resources

Even though implementing this is relatively easy; this topic can come with additional questions, find below some links to related webpages:

 

Enjoy watching TV with your newly added XBMC feature …  

Donation options


Donations are very much appreciated, but not required. Donations will be used for web-hosting expenses, project hardware or a motivational boost (a drink or snack). Thank you very much for those have donated already! It's truly AwEsOmE to see that folks like our articles and small applications.

Comments


There are 26 comments. You can read them below.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.

  • Jul 11, 2013 - 12:03 PM - hans Comment Link

    UPDATE: I have updated the information in the trouble shooting section. 

    Reply

    hans

  • Jul 19, 2013 - 10:31 PM - hans Comment Link

    UPDATE: Added a speed boost trick (switch from MyISAM to InnoDB). 

    Reply

    hans

  • Jul 22, 2013 - 3:43 AM - Errol Comment Link

    Hi,

    Thank you for your guide.

    I followed it and I was successful, 2 xbmc databases had been created. However, when I add the sources on my xbmc(windows7), my library won’t update.

    Reply

    Errol

    • Jul 22, 2013 - 10:31 AM - hans Comment Link

      Hi Errol,

      Are all you XBMC versions the same? (independent of the Operating System)

      Does you Windows box have full access to the files? (appears to be a common thing when the path is not working properly)

      Did you go through the debug logs? If that doesn’t show you anything: enable advanced debugging in the advancedsettings.xml.

      Reply

      hans

  • Aug 18, 2013 - 10:45 AM - hans Comment Link

    For those that are interested in the my.cnf that I use on my QNAP (note that I did not modify any of the paths):

    [client]
    port = 3306
    socket = /tmp/mysql.sock
    [mysqld]
    port = 3306
    socket = /tmp/mysql.sock
    skip-locking
    key_buffer = 256M
    max_allowed_packet = 48M
    table_cache = 256
    sort_buffer_size = 8M
    net_buffer_length = 16K
    read_buffer_size = 8M
    read_rnd_buffer_size = 4M
    myisam_sort_buffer_size = 64M
    server-id = 1
    innodb_data_home_dir = /usr/local/mysql/var/
    innodb_data_file_path = ibdata1:10M:autoextend
    innodb_log_group_home_dir = /usr/local/mysql/var/
    innodb_buffer_pool_size = 64M
    innodb_additional_mem_pool_size = 32M
    [mysqldump]
    quick
    max_allowed_packet = 16M
    [mysql]
    no-auto-rehash
    [isamchk]
    key_buffer = 20M
    sort_buffer_size = 20M
    read_buffer = 2M
    write_buffer = 2M
    [myisamchk]
    key_buffer = 20M
    sort_buffer_size = 20M
    read_buffer = 2M
    write_buffer = 2M
    [mysqlhotcopy]
    interactive-timeout
    Reply

    hans

  • Aug 20, 2013 - 2:21 AM - olivvvv Comment Link

    Excellent Tutorial !

    Just one thing, when i put the optimisation code for music database, i have this error (i’m on xbmc 12.2)

    Erreur

    requête SQL:

    CREATE INDEX idArtist_idx ON song(

    idArtist
    );

    MySQL a répondu: Documentation

    #1072 – Key column ‘idArtist’ doesn’t exist in table 

    Reply

    olivvvv

    • Aug 20, 2013 - 9:28 AM - hans Comment Link

      Hi Olivvvv,

      Thanks for the positive feedback  … I’ll add a note with the optimizing query that in the newer (v12+) XBMC the idArtists no longer seems to exist in the ‘song’ table. 

      Thanks you!

      Reply

      hans

  • Feb 4, 2014 - 9:15 AM - Fandy Backers - Author: Comment Link

    Hi,

    I also like your tutorial, but i have several more question/problems. When i have such system in my home, all xbmc clients all connected to one database, then i watched a movie like WAR or something. Then i want to watch in my bedroom, then i see what i have watched. But now comes the tricky one. Now i want my son to see his watched list and not mine. So, i would like to have some xbmc devices has their own user, but still connected to the same database. When i have seperate xbmc databases, all xbmc devices has to be updated seperatly, and that i don’t want.

    Then when you update a database, where do you do that? I would choose only one update system, and when i update, i don’t want to update it on an xbmc client. Because if there is added much media, you have to wait a long time until it’s updated.. Is there not a commandline command script i can execute every hour or so? 

    so that the update is spread over the clients when it’s finished!

    best regards,

    Fandy Backers

    Reply

    Fandy Backers

    • Feb 4, 2014 - 10:01 AM - hans Comment Link

      Thank you Fandy for your positive feedback. 

      You bring an interesting challeng – and I have thought about a similar challenge as well.
      The XBMC MySQL tables do indeed not have a per-user tracking of what has been watched.

      The database gets updated every time a XBMC box runs a scan for new files, and with multiple databases this indeed may come with a lot of data.

      As for updating the database every hour you could for example use the Library Auto Updater, which allows you to set time and interval.
      You will still have to maintain 2 databases, which might come with problems of it’s own.

      Also: What if the family watches a movie together,…? Shouldn’t both databases be updated? (there is no mechanism for that)
      To achieve this you’d need to restructure the database, so it can track “last played” (ie. the “resumeTime” in the “settings” table) per user or user group. Which theoretically could be done based on a user profile (at least OpenElec allows the use of user profiles).

      However, none of this is provisioned in the database or the XBMC software …

      If none of this is needed and both databases live on the same MySQL server then you could consider playing with the table triggers.
      For example: when records are added, duplicate them to the other database. But here too I can see issues when more than one XBMC box is trying to send data to the database.

      What might work, and I have not tested this:
      – Disable content scanning on all XBMC boxes, except for one (your main XBMC box that’s most of the time active)
      – Add triggers to the tables to replicate records to the 2nd database (for your son)

      When new content is scanned and added, it will be inserted in database-1, which then automatically replicates to database-2.
      (this will take some work to setup the triggers and MySQL knowledge is required – for example to avoid replicating “lastPlayed” and “resumeTime” information)

      Reply

      hans

  • Feb 18, 2014 - 8:42 AM - Ade Comment Link

    Hi

    I found this page via the qnap forums and you also link to an article about caching the thumbs. Which doesn’t seem to be live anymore. 

    Is this now frowned upon in your opinion?

    Ideally I would like my multiple xbmc to all have the same images for movie posters and the like, otherwise the OCD in me will go into overdrive. I’ve seen some other guides how how to do this but as your quite is geared towards qnap and you seem to keep things up to date I thought I’d ask you the question

    Reply

    Ade

    • Feb 18, 2014 - 9:40 AM - hans Comment Link

      Hi Ade,

      It seems that shared thumbnails is being frowned upon … I just don’t share that opinion.

      I’m of the opinion that thumbnails etc should be stored in a central place, I mean: why download the same stuff for every movie or episode for each XBMC setup, right?

      What I do at this moment:
      – Every movie (or TVShow) is stored in it’s own directory.
      – Next step is to use a tool like ViMediaManager (it’s for Mac, but there are plenty alternatives for Windows users) to download related info and images, which will be stored in the same directory.

      This way, my XBMC boxes do not have to download all the needed info and clipart.

      What still happens though is that it seems that XBMC caches these images locally – i.e. it makes a copy of the images.
      It can be seen as a waste of space on your XBMC box, but so far I have not gotten into any space issues (smallest disk I use is 30Gb SSD). 

      On rare occasions, with TV-Shows only, I have noticed that one or the other TV-Show is not syncing it’s thumbnails correctly and the generic image is shown instead (which is annoying).

      I wouldn’t mind looking at the guides you’ve found, I wouldn’t mind learning something new 

      Reply

      hans

      • Feb 18, 2014 - 10:10 AM - Ade Comment Link

        Hi Hans,

        I found this youtube guide from the guy from QuixVenture. He talks about using a path subsistute file in your XBMC user config folder which then puts all the thumbs into a shared folder he’s created on his NAS (synology NAS but not much difference between them an QNAP) 

        Link below, i’ve indexed it to start as the part where he talks about thumbnails. So I’m probably going to give this a go too.

        http://youtu.be/U6PPouAnnpY?t=2m58s

        Reply

        Ade

      • Feb 18, 2014 - 1:29 PM - hans Comment Link

        Path substitution is what is frowned upon … that’s how I used to do it.

        Some more info: XBMC Path Sustitution

        Based on that info it should still work, but might be slower than local thumbnails.
        Note that this “trick” will of course also work with a QNAP NAS.

        From that page:

        Example 2 – changing where thumbnails are stored

        Note: This is considered an advanced (complicated) and experimental feature.
        Note: This will slowdown thumbnail loading, but might be worth it for low-memory devices such as the ATV2.

        <advancedsettings>
         <pathsubstitution>
          <substitute>
            <from>special://masterprofile/Thumbnails/</from>
            <to>PROTOCOL://YOUR_NETWORK_SHARE/xbmc/userdata/Thumbnails/</to>
          </substitute>
         </pathsubstitution>
        </advancedsettings>
        Reply

        hans

  • Sep 10, 2014 - 12:47 AM - ictinc Comment Link

    Hi there, 

    Thank you so much for this tutorial. It did have some problems setting it up, but nothing that could be fixed. However I’m now trying to do the same for metahandler and universal toolkit. I created their databases on the same MySQL server with the same credentials but they won’t populate. 

    Do you have any idea what the problem could be? 

    Cheers, 

    Ictinc

    Reply

    ictinc

    • Sep 10, 2014 - 8:59 AM - hans - Author: Comment Link

      Common problems (I have zero experience with metahandler and universal toolkit … I think) are:

      – Correct Username/Password (watch capitals etc)
      – Correct MySQL reights for that Username
      – Correct TCP/IP Port (default 3306)
      – Network not yet running when a connection attempt is made (probably not the case with your setup).

      Reply

      hans

  • Dec 12, 2014 - 3:01 AM - frank Comment Link

    Hi there, 

    I have bought 3 MX III Android 4.4 TV Boxes with a 13.1 XBMC Gotham onboard. I´m very satisfied with this cheap units in a standalone enviroment, but unfortunately I´m running into some Network related
    Issues when I´m trying to use more than one device at the same time. If we start to watch movies at the same time, the playback will always stop on one of the devices. When it stopped on my device and I´m restarting the movie,
    it will stop on the other end, and so on. In the past I have used up to 3 dune players at the same time without any trouble.

    The library is running on a dual core W2003 Server.
    The network Switch is a 24 port 100/100 from HP (managable)

    Any suggestions ?

    MX III Android 4.4
    CPU: Amlogic S802 Quad-Core 2,0 GHz (Cortex-A9)
    GPU: Octa-Core-Mali-450 GPU
    RAM: 1G DDR3
    Flash: 8GB 

    Thanks in advance

    Frank

    Reply

    frank

    • Dec 12, 2014 - 7:50 AM - hans - Author: Comment Link

      Hi Frank,

      I have hardly any experience with Android boxes with XBMC, so I’m only guessing things I’d check, some of them very obvious but sometimes (even by myself) overlooked;

      1) Make sure all boxes have a different “name” (device name, network name, etc) in the network.
      2) Make sure they all get a unique IP address.

      The problem might be related to how a share is being accessed. Do they all use the same username/password to access the network share and can W2003 server handle this? (I run a Linux server, and I can imagine Windows to be problematic at times)

      The latter feels like where your problem occurs. Maybe W2003 does not like it that the same user logs in from different machines at the same time?

      Reply

      hans

  • Aug 30, 2015 - 4:05 AM - Patrik Comment Link

    Hi,

    I have been fighting with dulicates a lot, mainy because if use both Windows and Linux (Raspberry Pi) and they save the path differently (lower case / upper case issues).

    So after cleaning up the database manually for the fourth time in a year, I ended up adding a a unique index to two tables. This seems to have solved the problem for me. I did this with Kodi 14.2, but it shoud work fine with other versions too. Just change the name of the database in the queries.

    So here is what I ended up running:

    ALTER TABLE `MyVideos90`.`path` DROP INDEX `ix_path`, ADD UNIQUE INDEX `ix_path` (`strPath`(255));
    ALTER TABLE `MyVideos90`.`files` ADD UNIQUE INDEX `ux_files` (`strFilename`(255));

    Hope this helps others with the same issue.

    br. Patrik

    Reply

    Patrik

    • Aug 30, 2015 - 4:42 AM - hans - Author: Comment Link

      Thanks for the tip Patrik! 

      Since I only have Linux based KODI setups, I had not run into this issue.

      Your solution looks like something you have to repeat every now and then?
      (Drop “ix_path” index and recreate it, dito for “ux_files”)

      I’m not sure how Kodi handles database errors, but it might be a better idea to add a trigger that handles the differences in names. I’m a little surprised that Windows represents a filename/path with differences in upper/lowercase. Do you have any examples?
      I’m just being curious …. 

      Reply

      hans

  • Oct 30, 2015 - 2:12 PM - JimmySmasher Comment Link

    Man, great tut. I was messing with this most of today and it was really doing my head in, but now I have it working. Cheers mate.

    Reply

    JimmySmasher

  • Nov 6, 2015 - 12:32 PM - Vera Comment Link

    Hello,

    After completed a skin setup – Aeon Nox on Kodi 15.1 (LG smart TV), there is a message on the top left side of my TV:

    LOG:/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/temp/kodi.log

    MEM:406088/1048576 KB – FPS: 60.5 fps

    CPU: CPU0: 0/0%….CPU1…..

    Can someone tell me how to get rid of it?

    Thank you in advance,

    Vera

    Reply

    Vera

    • Nov 7, 2015 - 2:56 AM - hans - Author: Comment Link

      Hi Vera,

      Looks like you (or the skin) has enabled the viewing of realtime system info. This is commonly used to see how well the system is keeping up, but only used in rare occasions by (for example) developers, but it’s not quite the same as you’ve shown here – on my remote I have a button for that, but it only shows during playback (and I read somewhere that when you have a keyboard attached that pressing “O” would do the same thing).

      Try the buttons on your remote, to see if makes it disappear. 

      First question: did you restart the Android device you’re using? (to see if it comes back – you probably already did that).
      Second question: where did you get the skin? Through Kodi or did you download it somewhere?
      Third: Try uninstalling and re-installing the Aeon Nox skin.

      I know these might sound silly “solutions” but it’s worth a try.

      I installed Aeon Nox just now, based on your question, and I cannot reproduce the problem. Mind you though that the skin version is 5.6.0 and I’m running Kodi 14.2 (and you just reminded me to update my HTPC haha).

      Reply

      hans

    • Nov 7, 2015 - 3:58 AM - hans - Author: Comment Link

      Hi Vera,

      I’ve just upgraded my HTPC to Kodi 15.2, and tried the skin Aeon Nox. I cannot reproduce the issue … 

      Does this issue appear when you use a different skin? Confluence or (my favorite) Amber?

      Reply

      hans

  • Mar 24, 2017 - 4:35 PM - Ade Comment Link

    just came back to this after 3 years to set back up on my new QNAP, and also do a clean kodi install on my Raspberry Pi, all still working well. Excellent guide

    Reply

    Ade



Your Comment …

Friendly request to not post large files here (like source codes, log files or config files). Please use the Forum for that purpose.

Please share:
*
*
Notify me about new comments (email).
       You can also use your RSS reader to track comments.


Tweaking4All uses the free Gravatar service for Avatar display.
Tweaking4All will never share your email address with others.