Get a list of Movies in video library

I have OSMC installed on a Raspberry Pi. I manage it remotely though the command line. I want to get a list of Movies (and TV Shows if possible) that have been scanned to the library. I can get a list of files easily enough but I specifically want a list of the movies that have been scanned to the library.

Is there a way of getting this list?

Use the Web interface of Kodi.
Activate under Settings - > Services

I have set Chorus as the web interface and it works perfect but does not provide me with a list of movies. Perhaps I can scrape the web interface to create a list.

I want a list of movies in the library to cross-reference with another Kodi installation I have elsewhere.

Ok, so you just want a plain list? You can get that directly from the database with SELECT * FROM movie;
How you would execute that query depends on your setup (either sqlite or mysql)

I’m not familiar with how to execute SQL commands on OSMC, but I’ll give it a go. The databases are located in the userdata folder. So,
ls -ahl ~/.kodi/userdata/Database
drwxrwxrwx 3 osmc osmc 4.0K Dec 21 15:01 . drwxr-xr-x 9 osmc osmc 4.0K Dec 20 12:37 .. -rwxrwxrwx 1 osmc osmc 2.3M Aug 20 18:17 Addons16.db -rw-r--r-- 1 osmc osmc 4.4M Dec 21 15:01 Addons19.db drwxrwxrwx 2 osmc osmc 4.0K Jul 5 10:04 CDDB -rw-r--r-- 1 osmc osmc 5.0M Aug 20 18:33 Epg10.db -rwxrwxrwx 1 osmc osmc 5.0M Aug 20 10:13 Epg8.db -rwxrwxrwx 1 osmc osmc 2.4M Aug 20 12:34 MyMusic48.db -rw-r--r-- 1 osmc osmc 2.4M Aug 20 18:33 MyMusic52.db -rwxrwxrwx 1 osmc osmc 8.2M Aug 20 17:28 MyVideos90.db -rw-r--r-- 1 osmc osmc 5.7M Dec 21 14:06 MyVideos93.db -rwxrwxrwx 1 osmc osmc 324K Aug 20 10:13 TV26.db -rw-r--r-- 1 osmc osmc 324K Aug 20 18:33 TV29.db -rwxrwxrwx 1 osmc osmc 2.7M Dec 21 15:01 Textures13.db -rwxrwxrwx 1 osmc osmc 20K Dec 18 10:25 ViewModes6.db -rw-r--r-- 1 osmc osmc 383K Dec 21 11:31 onechannelcache.db
I installed mysql with
sudo apt-get install mysql-server mysql-client
I set the password and then ran the following query
mysql -u root -p -e 'SELECT * FROM movies;' MyVideos93.db
However I get the following error
ERROR 1049 (42000): Unknown database 'MyVideos93.db'

Am I going wrong somewhere?

texturecache may be a better option.
e.g. j movies

If you generally are not using the mysql shared database this would be the wrong approach. You then should have query against the sqlite database. If you want to switch to mysql I would suggest you install mysql from the App Store. You then would first need to export the database, switch to mysql in MyOSMC and then import the data again.

But as @popcornmix wrote maybe for your problem just using texturecache maybe easier provides a data dump containing amongst other things the movie titles. A little bit of python coding returns the movie titles as a JSON file:

import os, json, time now = str(time.time()) datadump = os.system("./ j movies >> datadump"+now+".json") datadump = json.load(open("datadump"+now+".json")) movietitle = [] for i in range(0,len(datadump)): <indent> movietitle.append(datadump[i]['title']) json.dump(movietitle,open("movielist.json", "w"))

However this seems quite messy. Perhaps the sql database is a cleaner method to achieve a list of movie titles.

I installed sqlite with
sudo apt-get install sqlite3
I opened the sqlite shell with
cd ~/.kodi/userdata/Database sqlite3 MyVideos94.db
Note: your .db file may have a different name.
To return the list of movies as a results.txt. file run:
.separator | .output results.txt SELECT c00 FROM movie; .exit
A list of movies in the library is now in the results.txt file.

This is probably “more correct” than the method although neither is straightforward.

Running the following bash script will also return a list of movies in a txt :
#!/bin/bash cd ~/.kodi/userdata/Database && sqlite3 MyVideos94.db << SQL$ .output output.txt SELECT c00 FROM movie; SQL_ENTRY_TAG_1