Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
Last active April 17, 2023 11:49
Show Gist options
  • Save magnetikonline/710e07d65c5495a24ca948595ed3f137 to your computer and use it in GitHub Desktop.
Save magnetikonline/710e07d65c5495a24ca948595ed3f137 to your computer and use it in GitHub Desktop.
Kodi media player - update video database file paths.

Kodi media player - update video database file paths

  • The Kodi databases are all SQLite3 based.
  • For Linux, the video database will be located at: ~/.kodi/userdata/Database/MyVideosXX.db, where XX is the version number. You will most likely want the highest number available for edit.

Install SQLite CLI tools, open database

$ sudo apt-get install libsqlite3-dev sqlite3
$ sqlite3 MyVideosXX.db

Queries

List paths

SELECT strPath FROM path WHERE (strPath LIKE '%/path/to/match/%');
SELECT c22 FROM movie WHERE (c22 LIKE '%/path/to/match/%');
SELECT c18 FROM episode WHERE (c18 LIKE '%/path/to/match/%');
SELECT url FROM art WHERE (url LIKE '%/path/to/match/%');
SELECT c16 FROM tvshow WHERE (c16 LIKE '%/path/to/match/%');
SELECT strFilename FROM files WHERE (strFilename LIKE '%/path/to/match/%');

Update paths

UPDATE path SET strPath = REPLACE(strPath,'/current/path/','/updated/path/');
UPDATE movie SET c22 = REPLACE(c22,'/current/path/','/updated/path/');
UPDATE episode SET c18 = REPLACE(c18,'/current/path/','/updated/path/');
UPDATE art SET url = REPLACE(url,'/current/path/','/updated/path/');
UPDATE tvshow SET c16 = REPLACE(c16,'/current/path/','/updated/path/');
UPDATE files SET strFilename = REPLACE(strFilename,'/current/path/','/updated/path/');

Reference

@cunlem
Copy link

cunlem commented Jan 25, 2023

There are URLs in art table of the form image://video@%2fvar%2fmedia%2fmyvideos%2fpath%2fto%2ffile/
with path separator escaped. In order to account for them:

UPDATE art SET url = REPLACE(url,'%2fcurrent%2fpath%2f','%2fupdated%2fpath%2f');

Such paths are also present in texture table (in TexturesXX.db):

UPDATE texture SET url = REPLACE(url,'%2fcurrent%2fpath%2f','%2fupdated%2fpath%2f');

@magnetikonline
Copy link
Author

Thanks @cunlem - I'd actually forgotten I used to use Kodi, many years ago 😄.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment