URL Update Script

WARNING USE THIS SCRIPT WITH CAUTION BACK UP mediasources.xml, sources.xml, MyVideos112.db, Textures13.db BEFORE YOU USE IT.

Hi I created this scriptupdate.sh (1.4 KB) to update the urls of all the videos in my library and the media sources.

If you want to use the script copy it to userdata and ssh into the box

cd .kodi/userdata
./update {searched} {repacedwith}

SO WHAT DOES IT DO FOR ME.

Well for me I was fed up of having to rescan all the content when I created a new box. I use Apache HTTPS to serve my media I use a different username and passwords for each box. That way I can stop certain boxes having access to 3D media and UHD media etc. So now I have a backup image for my masterbox which has access to everything.

The urls for the files and artwork etc all start with

HTTPS://masteruser:masterpass@mynas/

for the masterbox

And

HTTPS://box1:box1pass@mynas/
HTTPS://box2:box2pass@mynas/
…
etc for each box

So now if I want to setup a new box I restore the masterbox backup (which includes the script). I log in type

cd .kodi/userdata
./update masteruser:masterpass box3:box3pass

then reboot and clean the database which leaves me with a new box with all the appropriate content loaded for that box. It takes around 20 minutes to get a fully loaded working box ready.

WHY WOULD YOU USE IT ??

Well say to moves all your films from one drive to another

Old Drive

SMB://OLDNAS/FILMS

New Drive

SMB://NEWNAS/MEDIA/FILMS

All you need to do is login to you box having copied update.sh to the userdata folder and type

cd .kodi/userdata
./update “SMB://OLDNAS/FILMS” “SMB://NEWNAS/MEDIA/FILMS”

Then reboot and your box will now be working off the new server. PLEASE NOTE THIS DOES NOT CREATE OR MODIFY the password.xml file you need to do that by hand. I don’t use samba so I did not include it in the script

WHAT DOES IT DO.

The script simply replaces the first string with the second string in the sources.xml, mediasources.xml, VideoDB and TexturesDB in all the appropriate url fields.

PLEASE NOTE IT DOES NOT WORK ON MUSIC OR PICTURE CONTENT I HAVE NOT HAD CHANCE TO LOOK AT THOSE DATABASES AS I DON’T USE THEM FOR SHARED PICTURES AND MUSIC.

THE CODE

/bin/sh

echo “Renaming From : $1”
echo “Renaming To : $2”

echo “Renamining xmls”

sed -i “s/$1/$2/g” mediasources.xml
sed -i “s/$1/$2/g” sources.xml

echo “Renamining Video Artwork”
echo “UPDATE art SET url = replace(url,’$1’,’$2’);”
sqlite3 Database/MyVideos112.db “UPDATE art SET url = replace(url,’$1’,’$2’);”

echo “Renamining Video Episodes”

echo “UPDATE episode SET c18 = replace(c18,’$1’,’$2’);”

sqlite3 Database/MyVideos112.db “UPDATE episode SET c18 = replace(c18,’$1’,’$2’);”

echo “Renamining Video Movies”

echo “UPDATE movie SET c22 = replace(c22,’$1’,’$2’);”

sqlite3 Database/MyVideos112.db “UPDATE movie SET c22 = replace(c22,’$1’,’$2’);”

echo “Renamining Video Paths”

echo “UPDATE path SET strPath = replace(strPath,’$1’,’$2’);”

sqlite3 Database/MyVideos112.db “UPDATE path SET strPath = replace(strPath,’$1’,’$2’);”

echo “Renamining Textures Paths”

echo “UPDATE path SET url = replace(url,’$1’,’$2’);”

sqlite3 Database/Textures13.db “UPDATE path SET url = replace(url,’$1’,’$2’);”

echo “Renamining Textures Paths 2”

echo “UPDATE path SET texture = replace(texture,’$1’,’$2’);”

sqlite3 Database/Textures13.db “UPDATE path SET texture = replace(texture,’$1’,’$2’);”

echo “Renamining Textures Textures”

echo “UPDATE texture SET url = replace(url,’$1’,’$2’);”

sqlite3 Database/Textures13.db “UPDATE texture SET url = replace(url,’$1’,’$2’);”

1 Like

update.sh (1.4 KB)
New Version for 8.99.2 Database Version

update.sh (1.4 KB)

Latest Versoin
I found the earlier version would fail occasionally if kodi was accessing the database this version stops kodi does the update then starts it now it works every time.