Last active
August 29, 2015 14:06
Revisions
-
hensing revised this gist
Sep 23, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/usr/bin/env python # coding: utf-8 """ simple notebook to patch/replace XBMC paths in MyVideo.db infos: [howto @ wiki.xbmc.org](http://wiki.xbmc.org/index.php?title=HOW-TO:Update_SQL_databases_when_files_move) see also [path substitution](http://wiki.xbmc.org/index.php?title=Path_substitution) """ -
hensing created this gist
Sep 23, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ #!/usr/bin/env python # coding: utf-8 """ simple notebook to patch XBMC paths in MyVideo.db infos: [howto @ wiki.xbmc.org](http://wiki.xbmc.org/index.php?title=HOW-TO:Update_SQL_databases_when_files_move) see also [path substitution](http://wiki.xbmc.org/index.php?title=Path_substitution) """ __author__ = 'Henning Dickten' import sqlite3 import glob from os import path # SETTINGS dbpath = './' old_path = r'nfs://myserver//old_path' new_path = r'nfs://mynewserver//new_path' # MYVIDEO.DB # # get latest database: videos = glob.glob(path.join(dbpath, r'MyVideos*.db')) videos.sort() # get cursor: connection = sqlite3.Connection(videos[-1]) cursor = connection.cursor() # patch MyVideo db: cursor.execute('UPDATE path SET strPath = REPLACE(strPath, ?, ?);', (old_path, new_path)) cursor.execute('UPDATE movie SET c22 = REPLACE(c22, ?, ?);', (old_path, new_path)) cursor.execute('UPDATE episode SET c18 = REPLACE(c18, ?, ?);', (old_path, new_path)) cursor.execute('UPDATE art SET url = REPLACE(url, ?, ?);', (old_path, new_path)) cursor.execute('UPDATE tvshow SET c16 = REPLACE(c16, ?, ?);', (old_path, new_path)) # commit changes connection.commit() # TEXTURES.DB # # get latest database: textures = glob.glob(path.join(dbpath, r'Textures*.db')) textures.sort() # get cursor: connection = sqlite3.Connection(textures[-1]) cursor = connection.cursor() # patch Textures.db cursor.execute('UPDATE path SET url = REPLACE(url, ?, ?);', (old_path, new_path)) # commit changes connection.commit() # MUSIC.DB # # get latest database music = glob.glob(path.join(dbpath, r'MyMusic*.db')) music.sort() # get cursor: connection = sqlite3.Connection(music[-1]) cursor = connection.cursor() # patch Textures.db cursor.execute('UPDATE path SET strPath = REPLACE(strPath, ?, ?);', (old_path, new_path)) # commit changes connection.commit()