Skip to content

Database Analyzer

jbinkley60 edited this page Jul 4, 2024 · 39 revisions

Last updated July 4, 2024

The Kodi Selective Cleaner offers a powerful table analyzer for tables in the Kodi video and music (future) databases. It analyzes the selected table looking for unmatched entries in all related tables and providing options for viewing, CSV exporting or cleaning the tables.

Video DB Data Analyzer

The video analyzer is accessed through the main menu. Clicking on the menu option will bring up a table selector to choose which table to analyze.

video_analyzer1

Selecting a table will bring up the a selection option for the function to perform.

video_analyzer2

This example shows the visual output of the episode table and selecting the Analyze Table option. Note that items which have a blue highlight are orphaned data records and can be cleaned by the clean function. Items not in blue are simple unmatched data integrity items which should be fixed but are unlikely to cause a problem with normal Kodi operations. The counts show the orphaned records and those which have data integrity mismatches. The complete list of items which can be cleaned are found below in the Details.

video_analyzer11

If there are no unmatched records found in the table being analyzed a popup notification will appear. This example is for the actor table.

video_analyzer4


Video DB Data Analyzer Details

For those who want to peek under the covers of the video database analyzer, here is some additional information regarding which tables are evaluated for unmatched data when selecting a Kodi video database table to analyze.

Table Analyzed Unmatched Analysis
actor Unmatched entries against actor_link, director_link and writer_link tables
actor_link Unmatched entries against actor, movie, episode, tvshow, musicvideo and seasons tables
art Unmatched entries against sets, movie, episode, tvshow, musicvideo and seasons tables
director_link Unmatched entries against actor, movie, episode and musicvideo tables
episode Unmatched entries against files, rating, path, uniqueid, tvshow and seasons
files Unmatched entries against path
files strict (Note 1) Unmatched entries against episode, movie and musicvideo and streamdetails tables (audio and video separately)
genre_link Unmatched entries against movie, episode, musicvideo and tvshow tables
movie Unmatched entries against files, rating, path, uniqueid, and sets
musicvideo Unmatched entries against files and path
path Unmatched entries against files and path entry is not a parent path
seasons Unmatched entries against episode and tvshow tables
sets Unmatched entries against movies
streamdetails Unmatched entries against files
tag_link Unmatched entries against tag, episode, movie, musicvideo and tvshow
tvshows Unmatched entries against episode, rating and seasons
uniqueid Unmatched entries against episode, movie and musicvideo
videoversion Unmatched entries against files, movie and videoversiontype
writer_link Unmatched entries against actor, movie and episode tables

Bold unmatched data can be cleaned. Other unmatched data are data integrity items which should be fixed.

Note 1 - Use files table strict mode carefully. Strict mode cleaning will remove file table entries that do not match against the movie, episode or musicvideo tables. This can be helpful in removing Internet downloaded and other temporary content but can also remove tile table entries / resume points for content added to the file table by other addons. Please review the analyze table contents carefully before cleaning in strict mode.


Video DB Data Analyzer CSV Export

In addition to providing a display output, the Video DB Data Analyzer can provide a CSV output of the results for additional analysis.

video_analyzer2

selecting the Analyze / CSV export option will run the analyzer followed by a CSV export. When completed a popup notification dialog will indicate completion and the location of the CSV output file.

video_analyzer7

The CSV files will be named: kscleaner_video_analyzer_ + the table name + a timestamp.

video_analyzer9

The contents of the CSV file will have the same information as the GUI display and a column named clean which will be a 'Yes' or 'No' indicating whether the Video DB Analyze clean function will remove the unmatched record or not.


Video DB Data Cleaner

In addition to the video DB analyzer and CSV export functions, the Kodi Selective Cleaner offers an intelligent cleaner capability to help you keep your Kodi video database clean and in better working order. The cleaner function takes the output from the analyzer and removes orphaned data while leaving unmatched data untouched. In this example we have the video DB movie table with both an orphaned and an unmatched record in the database.

clean1

To run the cleaner it is suggested to first run the analyzer to see the results in advance and then select the cleaner function.

clean2

Running the cleaner will bring up a dialog box asking you to confirm you want to clean the selected table.

clean3

Once the cleaner runs it will display another dialog box indicating how many orphaned record were cleaned.

clean4

Going back into the analyzer shows that the orphaned record was removed bu the unmatched record remains.

clean5

The addon logging utility will keep track and record all changes made by the cleaner function.

clean6


Analyze - Clean All

Kodi Selective Cleaner now has addon settings to add Analyzing All and Cleaning All tables menu items in the Video Database Analyzer vs. doing each one individually. When enabled you will see the menu items added at the top of the table selector in the Video Database Analyzer menu.

video_analyzer12

When selecting the Clean all you will be prompted to ensure you really want to clean everything. This cannot be undone except by a database restore.

video_analyzer13

It is highly recommended that if you don't want to do an individual table-by-table approach prior to performing a Clean All Tables function that you perform an Analyze All Table function and review the output. Depending upon the addon setting your results will either be displayed in the Kodi GUI, written to a file or both.

The output from an Analyze All Tables function is the combination of running this for each table individually.

GUI Sample Analysis

video_analyzer14

Text File Analysis

video_analyzer15


Duplicate Video Media Analysis

Beginning with version 1.0.7, the Kodi Selective Cleaner now offers a duplicate video media analysis feature to help find duplicate files, movies, TV episodes and music videos. This feature is enabled in the addon settings and allows outputting the results either to the GUI, to a text file or both.

When enabled an additional menu item will appear at the top of the table selector menu.

video_analyzer17

You will then be prompted with a multi-selector menu dialog as to what you want to analyze for duplicates. You can select any or all of the items.

video_analyzer16

Here are two sample GUI outputs:

Duplicate movie analysis with no duplicates found.

video_analyzer18

Duplicate TV Episode analysis with duplicates found.

video_analyzer19

The duplicate video media analysis performs two checks for each media type, first by title or episode and then second by file name.

Here are more details on the exact analysis performed by media type. Note that for TV Episodes there is an addon setting to utilize enhanced duplicate analysis. This is to help with situations where folks may utilize duplicate naming for multipart TV episodes which cause unwanted false positives. The recommendation is to start with enhanced analysis being disabled and only enable if you are seeing many unwanted false positive duplicates.

Duplicate analysis Analysis Details
Movies by Title Duplicate movie titles (column c00) in the movie_view table
Movies by File Duplicate movie file names (strFileName) in the movie_view table
Episodes by Show, Episode and Season Analyzes episode title, season and episode (columns strTitle, c12, c13) in episode_view table
Enhanced Episodes by Show, Episode and Season Analyzes episode title, season, episode, aired date (columns strTitle, c12, c13, c05) in episode_view table
Episodes by File Duplicate episode file names (strFileName) in the episode_view table
Enhanced Episodes by File Analyzes episode file name, season, episode (columns strFileName, c12, c13) in episode_view table
Music Videos by Title Duplicate music video titles (column c00) in the musicvideo_view table
Music Videos by File Duplicate music video file names (strFileName) in the musicvideo_view table

Notes:

All duplicate matches are exact matches and not like matches. Thus title.mkv would not match title.2020.h264.mkv
Normal episode duplicate analysis by file expects TV episode file name to follow that Kodi s0xe00x naming convention.