Kodi Community Forum

Full Version: Syncing Nvidia Shield with MySQL DB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I just bought 3 Nvidia Shield TV's (Amazon Prime day specials $139 each - so happy) to move away from my linux versions of Kodi. The machines I was running them on were bottom basement that sometimes struggled with what I would throw at them. Since I am starting new and now have some extra linux boxes to dedicate to acting as a mysql server, I figured it is time to sync everything up with an external database as it has been on my to-do list forever. I have been reading around and all of the instructions I have come across require me to perform some minor script work in the advanced settings file. How do I do this on a shield? Are there a set of Android-specific instructions I can follow? I am too new to Android to know better and am relying on as much instructions as you guys are willing to provide me with. Also, any advice would be appreciated.
Hi,

I am using 2 Shields and on oder Amazon FireTV, all are Running on the same MySQL Movie and Music Database.

I can provide the steps you'll need. But at first some questions.

How much do you know about accessing Android from your PC? Have you used the ADB so far?

Holger
I was able to begin navigating around the shield from my laptop via a usb connection.

All the help you can provide would be great and appreciated. Here is where I currently am situated.

I have set up the mysql server on address 192.168.0.252. I have statically set the address.
I have statically set the address of my test Shield to 192.168.0.141.

When I set up mysql on the ubuntu server  (fresh install of linux), I edited the /etc/mysql/mysql.conf.d/mysqld.cnf with bind-address 127.0.0.1 and bind-address 192.168.0.141. I also setup a user account on mysql with username/password kodi/kodi.
Just a thought: older Ubuntus are working with MySQL, newer Ubuntus are defaulting to MariaDB. The latter one seems to have some quirks when setting up. (I'm still running Ubuntu 14.04 and MySQL 5.5 ...)

If you can connect remotely to your Ubuntu (Server) and MySQL/MariaDB, using tools like MySQL Workbench, then your setup should be fine. But MySQL does not allow remote connections by default, so you need to overcome that first.
(2018-07-22, 02:35)Ou812_2018 Wrote: [ -> ]...

When I set up mysql on the ubuntu server  (fresh install of linux), I edited the /etc/mysql/mysql.conf.d/mysqld.cnf with bind-address 127.0.0.1 and bind-address 192.168.0.141. I also setup a user account on mysql with username/password kodi/kodi.
  If these bind addresses are the one the server ist listening for new connections I think this is misconfigured, they should be 127.0.0.1 for localhost and 192.168.0.252 for the actual network interface used by the server. But the last time I actually configured such server is about 15 years back, so I can't provide much help here. My MariaDB-Server comes with the QNAP-NAS unit I am using and here I just needed to activate the SQL-Server and accept remote-connections on port 3306.

But once you can connect it like Klojum said, here are the steps I am using to access my Shields to editing the config:

At first you'll need to activate the Android Debug Bridge (ADB) on the shield, that ones is used to access it remotely from your descktop.
The following steps are on the Shield:

Enable debugging

1. Goto Settings
2. Go across to About in Device
3. Go down to Build and click on it 10times until it says you are in development mode

ADB over USB

1. Make sure you have performed the above steps "Enable debugging"
2. Goto Settings
3. Go Across to Developer options
4. Go down to Debugging
5. Toggle USB debugging to On

ADB over Network

1. Make sure you have performed the above steps "Enable debugging"
2. Make sure you have performed the above steps "ADB over USB"
3. Toggle Network debugging to On


For the next part you'll need to install the Android Debug Bridge on your decktop. I'm using that on Windows, but it's available on Ubuntu as well here are two links for download (and some instructions):

https://www.linuxbabe.com/ubuntu/how-to-...6-10-14-04
https://forum.xda-developers.com/showthr...?t=2317790

Once you connected to your shield using the following command and authorizing the access as shown in the ubuntu link you can start editing the advancedsettings.xml.
adb connect 192.168.0.141

To use the MySQL/MariaDB database for Vidieo or Music-Database the advancedsettings.xml needs to contain the following part, with your config (as far as provides; I'm not sure about the port):

xml:
<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <host>192.168.0.252</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </videodatabase>
  <musicdatabase>
    <type>mysql</type>
    <host>192.168.0.252</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </musicdatabase>
</advancedsettings>

Save this file some where, for the following ADB commands I assume them on K:\ on Windows.

To get this on your shield you need to use the push command of adb, like
adb push "K:\advancedsettings.xml" /sdcard/Android/data/org.xbmc.kodi/files/.kodi/userdata/advancedsettings.xml

Thats basically all you need to get Kodi to use MySQL/MariaDB for your library. Once you start Kodi after that, it will connect to your MySQL/MariaDB and create the database MyVideosNNN (NNN being the version number depending on your Kodi Version, somewhere around 109 at the moment, I think). So your user kodi need the right to create new databases, by the way.

For the adb command the path used on the shield (or any other device) depends on some different things, here are some I had to use so far:

Shield Pro, local Kodi install: /sdcard/Android/data/org.xbmc.kodi/files/.kodi/userdata/advancedsettings.xml
Amazon FireTV on SDCard: /storage/sdcard1/Android/data/org.xbmc.kodi/files/.kodi/userdata/advancedsettings.xml
Amazon FireTV on SDCard: /sdcard/Android/data/org.xbmc.kodi/files/.kodi/userdata/advancedsettings.xml

You can determine the one needed with; you'll need to find the org.xbmc.kodi -folder
adb shell
cd
ls


To get ths to work on all three Shields you need to use the same Kodi-version on all three of them, as the used database depends on that.

The same way I'm configuring the sources.xml and passwords.xml, but that may be a bit off topic here. Wink

Holger

PS: Can someone explain how to get this Code-Tag to work? When I used it here only the whole text changed, despite selected Text. So I used the italic script instead.
Code:
This is code
(2018-07-22, 07:56)Klojum Wrote: [ -> ]MySQL Workbench

I have workbench making the remote connection with both root and kodi users. Thanks for the heads up.
Wow! Lots of detail here. I will let you know how I make out. Thanks for documenting the steps required to make this happen. I've been wanting to do this for years but just never really got around to it.
I seem to be up and running now. I checked the db and there are a bunch of new tables for movies, directors, actors, tvshows, and so on. I am importing the backup I had setup so I should have a better idea soon as to the success level but I am feeling pretty confident at this point.

I am assuming that the other shields will not need an import to be done as they will just grab their information from the db. Is this correct?

Next thing to tackle are setting up profiles for everyone in the house so that others don't muck up my viewed list. 

I am intrigued on the sources.xml and passwords.xml. What are the possibilities for this?

Thanks again for the help!
(2018-07-22, 15:56)Ou812_2018 Wrote: [ -> ]I am assuming that the other shields will not need an import to be done as they will just grab their information from the db. Is this correct?
Yes, these are just using this information without the need to import the library once again.
(2018-07-22, 15:56)Ou812_2018 Wrote: [ -> ]Next thing to tackle are setting up profiles for everyone in the house so that others don't muck up my viewed list. 
I've not been using (different) profiles so far. But I think to get different watch-states you'll need to define different videodatabases in each profile. You can do this by adding the name-tag in the advancedsettings.xml, I think.
(2018-07-22, 15:56)Ou812_2018 Wrote: [ -> ]I am intrigued on the sources.xml and passwords.xml. What are the possibilities for this?
These just store the information about, where to find (sources.xml) your movie-files etc. and the log-ins needed to access them (passwords.xml).

For sources.xml you can find an explanation here: https://kodi.wiki/view/Sources.xml/Types

The passwords.xml basicly replaces the path to include username and password:
xlm:

<passwords>
<path>
<from pathversion="1">smb://192.168.1.200/Movies</from>
<to pathversion="1">smb://user:[email protected]/Movies/</to>
</path>
<path>
<from pathversion="1">smb://192.168.1.200/TV Shows</from>
<to pathversion="1">smb://user:[email protected]/TV Shows/</to>
</path>
</passwords>
I've been playing around with this but i'm still running into some problems
I created the MySQL DB and populated it from my Kodi install on a Win 10 machine

I placed the xml file in the right place on the Shield TV.

When i restart Kodi on the Shield TV it shows all the entries, but i don't get any of the artwork. When i click on a movie/tv show, it says the file is no longer available.

I've done the exact same process on another pc i have and there it's working just fine.

Any idea why it doesn't work on the Shield but absolutely fine on another pc?
If i had to guess....i would assume that whereever you scanned your DB you used local pathing, where it should be maybe NFS or SMB?  I set all mine to be scanned via nfs:// rather that C:/ if windows or /Media/wahtever if linux, so that it could be picked up by any device via the remote address

If thats not the case, prob need a log
(2019-02-02, 22:08)wyild1 Wrote: [ -> ]If i had to guess....i would assume that whereever you scanned your DB you used local pathing, where it should be maybe NFS or SMB?  I set all mine to be scanned via nfs:// rather that C:/ if windows or /Media/wahtever if linux, so that it could be picked up by any device via the remote address

If thats not the case, prob need a log

Not to resurrect an old/dead thread, but I'm having similar issues. I've modified my advancedsettings to do a find and replace, with this being what I have tacked onto the SHIELD specifically:

Code:

 <pathsubstitution>
  <substitute>
    <from>/media/mergerfs/</from>
    <to>smb://192.168.1.17:445/media/mergerfs/</to>
  </substitute>
 </pathsubstitution>

The problem I'm running into, though, is that the SHIELD will say the content is missing even though the other systems (obviously) can access it just fine. Am I doing something wrong with the path substitution?
Make sure to copy sources.xml, mediasources.xml and passwords.xml from userdata folder on the primary device to your other ones. Currently I think that it can see the items in the library but can't access them to play/pull in artwork because.it.doesnt have access to the share