2020-05-26, 13:50
@black_eagle
Having a scrub tool to clean out the database is a good thing to have although Kodi should be really able to clean up after itself. I read that you mainly focus on the
This is part of a PHP script I run whenever I need to clean out a TV show from the Kodi database. Some 17 18 tables are possibly linked to a single TV show as you can see.
I'm hoping that something similar will ever end up in the Kodi application. Too bad my C++ skills are non-existent at this time.
And then there are also the related database entries in the local Textures13.db database as well as the subsequent local thumbnail files...
I don't know if you can use any of the above script, but perhaps it's an eye opener.
Having a scrub tool to clean out the database is a good thing to have although Kodi should be really able to clean up after itself. I read that you mainly focus on the
files
database table alone. That's a good start, but other video database tables will contain leftovers as well from deleted videos.This is part of a PHP script I run whenever I need to clean out a TV show from the Kodi database. Some 17 18 tables are possibly linked to a single TV show as you can see.
php:
dump ('Remove selected TV show from video database');
$result = mysqli_autocommit($_SESSION['connection']['video'], FALSE);
$result = mysqli_begin_transaction($_SESSION['connection']['video']);
$query = array();
$query[] = 'DELETE FROM path WHERE idParentPath='.$tvshow_root_path.' OR idPath='.$tvshow_root_path;
$query[] = 'DELETE FROM actor_link WHERE media_type="tvshow" AND media_id='.$idShow;
$query[] = 'DELETE FROM country_link WHERE media_type="tvshow" AND media_id='.$idShow;
$query[] = 'DELETE FROM director_link WHERE media_type="tvshow" AND media_id='.$idShow;
$query[] = 'DELETE FROM writer_link WHERE media_type="tvshow" AND media_id='.$idShow;
$query[] = 'DELETE FROM uniqueid WHERE media_type="tvshow" AND media_id='.$idShow;
$query[] = 'DELETE FROM studio_link WHERE media_type="tvshow" AND media_id='.$idShow;
$query[] = 'DELETE FROM rating WHERE media_type="tvshow" AND media_id='.$idShow;
$query[] = 'DELETE FROM genre_link WHERE media_type="tvshow" AND media_id='.$idShow;
$query[] = 'DELETE FROM art WHERE media_type IN ("tvshow", "episode") AND media_id='.$idShow;
$query[] = 'DELETE FROM streamdetails WHERE idFile IN ( SELECT idFile FROM episode WHERE idShow='.$idShow.')';
$query[] = 'DELETE FROM settings WHERE idFile IN ( SELECT idFile FROM episode WHERE idShow='.$idShow.')';
$query[] = 'DELETE FROM bookmark WHERE idFile IN ( SELECT idFile FROM episode WHERE idShow='.$idShow.')';
$query[] = 'DELETE FROM files WHERE idFile IN ( SELECT idFile FROM episode WHERE idShow='.$idShow.')';
$query[] = 'DELETE FROM tvshowlinkpath WHERE idShow='.$idShow;
$query[] = 'DELETE FROM episode WHERE idShow='.$idShow;
$query[] = 'DELETE FROM seasons WHERE idShow='.$idShow;
$query[] = 'DELETE FROM tvshow WHERE idShow='.$idShow;
foreach ($query as $key => $kwry)
{
$result = do_query($kwry, 'video', 'DELETE rule #'.$key);
if ($_SESSION['connection']['video']->errno != 0) { $err_flag++; }
}
if ($err_flag == 0)
{
$result = mysqli_commit($_SESSION['connection']['video']);
if ($result)
{
dump('TV show has been exterminated from MySQL database.');
}
else
{
dump('MySQL commit was NOT executed.');
}
}
else
{
$result = mysqli_rollback($_SESSION['connection']['video']);
dump('TV show could not be exterminated from MySQL database.');
}
I'm hoping that something similar will ever end up in the Kodi application. Too bad my C++ skills are non-existent at this time.
And then there are also the related database entries in the local Textures13.db database as well as the subsequent local thumbnail files...
I don't know if you can use any of the above script, but perhaps it's an eye opener.