Kodi Community Forum

Full Version: Video Database Cleaner add-on
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
So, where are the install instructions for those of us that don't know what we're doing? Install fails with "ERROR <general>: CAddonInstallJob[script.database.cleaner]: The dependency on xbmc.python version 2.1.0 could not be satisfied." which sounds to me like it requires that version of python, which is 20 years old? Is that right?
(2021-07-20, 05:53)DGenerateKane Wrote: [ -> ]So, where are the install instructions for those of us that don't know what we're doing? Install fails with "ERROR <general>: CAddonInstallJob[script.database.cleaner]: The dependency on xbmc.python version 2.1.0 could not be satisfied." which sounds to me like it requires that version of python, which is 20 years old? Is that right?

for Kodi 19 Matrix and python 3 all is here Smile 

GIT : https://github.com/klyco/script.database.cleaner

ZIP : https://github.com/klyco/script.database...master.zip
There seems to be an issue with the code that builds sql statements used when the "Remove a specific path from the database" option is used or the "Deep Clean" is used with a path specified.

The debug log following the execution of either operation contains lines similar to the following:
Quote:2021-07-24 16:49:22.122 T:8508    DEBUG <general>: Video Database Cleaner: Executing SQL command - SELECT strPath FROM path WHERE strPath LIKE %s - params: ['test%']
2021-07-24 16:49:22.127 T:8508    DEBUG <general>: Video Database Cleaner: Executing SQL command - SELECT count(*) FROM files WHERE NOT EXISTS (SELECT 1 FROM path WHERE path.idPath = files.idPath) OR idPath IN (SELECT DISTINCT idPath FROM path WHERE strPath LIKE %)s - params: ['test%']
2021-07-24 16:49:22.127 T:8508    DEBUG <general>: Video Database Cleaner: Error executing SQL statement. The SQL statement was: SELECT count(*) FROM files WHERE NOT EXISTS (SELECT 1 FROM path WHERE path.idPath = files.idPath) OR idPath IN (SELECT DISTINCT idPath FROM path WHERE strPath LIKE %)s, called with parameters ['test%']. Error: Not all parameters were used in the SQL statement

It looks like the string placeholder has somehow gotten a closing bracket inserted between the % and s.

I did start to look through the script code in effort to put in a pull request to fix it, but am unfortunately not familiar with python or with the codebase, so simply wouldn't have the time to learn both at the moment.
VDC query:
SELECT count(*) FROM files WHERE NOT EXISTS (SELECT 1 FROM path WHERE path.idPath = files.idPath) OR idPath IN (SELECT DISTINCT idPath FROM path WHERE strPath LIKE %)s

In Workbench MySQL:
18:30:40 SELECT count(*) FROM files WHERE NOT EXISTS (SELECT 1 FROM path WHERE path.idPath = files.idPath) OR idPath IN (SELECT DISTINCT idPath FROM path WHERE strPath LIKE %)s Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%)s' at line 1 0,0033 sec

LIKE is typically used for text strings, so the parameter should be enclosed in quotes or double quotes. No idea what the ) character is for.
(2021-07-20, 06:56)Nanomani Wrote: [ -> ]
(2021-07-20, 05:53)DGenerateKane Wrote: [ -> ] 
for Kodi 19 Matrix and python 3 all is here Smile 
ZIP : https://github.com/klyco/script.database...master.zip

Thanks!  I was having issues after changing to a new router, and updating to the latest version of this addon fixed it.  Thank you!
(2021-07-24, 18:33)Klojum Wrote: [ -> ]LIKE is typically used for text strings, so the parameter should be enclosed in quotes or double quotes. No idea what the ) character is for.
Its the terminator for the in statement.
Should read:
(SELECT DISTINCT idPath FROM path WHERE strPath LIKE %s)
@kenmills In that case, the query is wrong. ^^
I've found some time to investigate this today. Just looking for keywords around the sql statements that were logged meant that I only had to learn enough to understand what a few lines of the pyton code is doing instead of the whole lot.

Anyway, the issue can be fixed by updating line 183, which is currently:
python:
count_files_statement = count_files_statement[:-1] + '))' + count_files_statement[-1:]
to be:
python:
count_files_statement = count_files_statement + ')'

I also found that there's a similar SQL syntax issue when attempting to replace a path in the database, which can be fixed by updating line 1154, currently:
python:
sql = sql.replace('((strPath', '(strPath').replace(' AND ())', ')')
to be:
python:
sql = sql.replace('((strPath', '(strPath').replace(' AND ())', '')

I did attempt to raise pull requests for theses updates, but I don't seem to have access to push to the repo:
git:
$ git push origin no_sources_disabled_sql_fix
remote: Permission to klyco/script.database.cleaner.git denied to sim099.
fatal: unable to access 'https://github.com/klyco/script.database.cleaner.git/': The requested URL returned error: 403
(2021-08-22, 14:38)sim099 Wrote: [ -> ]I did attempt to raise pull requests for theses updates, but I don't seem to have access to push to the repo:

Assuming you forked klyco/script.database.cleaner then push your updates to a new branch of your fork and then create a PR from that back to the original.
(2021-08-22, 16:19)black_eagle Wrote: [ -> ]
(2021-08-22, 14:38)sim099 Wrote: [ -> ]I did attempt to raise pull requests for theses updates, but I don't seem to have access to push to the repo:

Assuming you forked klyco/script.database.cleaner then push your updates to a new branch of your fork and then create a PR from that back to the original.

I was attempting to push to the repo that I cloned from, but now you mention it that's unlikely to work.

It may be for the best to be honest. Those updates worked in the specific cases I mentioned, but when I tried to use it without either of those features enabled it failed with an SQL syntax error.
Hope you all are still active. This might be a ELI5 as I am more of a hardware tech nerd than software but  I have about 900 movies, id say 30% of them have duplicated, or I have deleted, or for whatever reason they are off my 2 external HDDs. I used the vanilla library clean, nothing happened. I have installed this add on 6.1 (i think?) I hit clean and it just opened up the vanilla library cleaner again and after about 20+ minutes nothing happened. I imagine I am doing something wrong on my end. I would love some help.
(2021-09-20, 22:32)fstr21 Wrote: [ -> ]I have about 900 movies, id say 30% of them have duplicated, or I have deleted, or for whatever reason they are off my 2 external HDDs

With duplicates it's hard to identify which is the correct entry.

What type of duplicates do you have?
- Extension only
- Different filename
- Both of the above
(2021-09-20, 23:01)Klojum Wrote: [ -> ]
(2021-09-20, 22:32)fstr21 Wrote: [ -> ]I have about 900 movies, id say 30% of them have duplicated, or I have deleted, or for whatever reason they are off my 2 external HDDs

With duplicates it's hard to identify which is the correct entry.

What type of duplicates do you have?
- Extension only
- Different filename
- Both of the above

The dupes don't concern me because if I can clean the entire library of movies that aren't connected to a source any more then it'll fix that problem as well. That's what I'm looking to do in the end. Basically I just want every movie that isn't on a source gone. Hell I can taken out all sources, it's just 2 hdd and delete the entire list and repopulate it if that's easier. Just can't figure out how to get rid of the initial list
(2021-09-20, 22:32)fstr21 Wrote: [ -> ]I used the vanilla library clean, nothing happened. I have installed this add on 6.1 (i think?) I hit clean and it just opened up the vanilla library cleaner again and after about 20+ minutes nothing happened.
 
Kodi's "Clean Library" option (under the settings) should do exactly what you're describing.

For example, adding "Movie/Movie.mkv" and then renaming it to "Movie (2021)/Movie (2021).mkv" and re-scanning would result in the movie being displayed twice. Deleting "Movie (2021)/Movie (2021).mkv" would obviously result in neither of those entries being useable because the filles they point to don't exist.

The "Clean Library" function checks all entries in the database to make sure that the referenced file is still available, removing that entry from the database if not. That's how it works as far as I understand it from my usage anyway, I haven't confirned that in the code.

(2021-09-21, 00:57)fstr21 Wrote: [ -> ]The dupes don't concern me because if I can clean the entire library of movies that aren't connected to a source any more then it'll fix that problem as well. That's what I'm looking to do in the end. Basically I just want every movie that isn't on a source gone. Hell I can taken out all sources, it's just 2 hdd and delete the entire list and repopulate it if that's easier. Just can't figure out how to get rid of the initial list

Weren't you asking how to get rid of the duplicates? Huh Laugh "Clean Library" should do that as long as the duplicates don't remain on the source(s) (i.e. you've deleted "Movie/Movie.mkv" in the example above meaning that Kodi no longer finds it).

If you just want to remove everything from your library then I'm pretty sure that if you begin to remove a source, you'll be asked if you want to remove everything under that source from the database.
(2021-09-21, 14:57)sim099 Wrote: [ -> ]
(2021-09-20, 22:32)fstr21 Wrote: [ -> ]I used the vanilla library clean, nothing happened. I have installed this add on 6.1 (i think?) I hit clean and it just opened up the vanilla library cleaner again and after about 20+ minutes nothing happened.
 
Kodi's "Clean Library" option (under the settings) should do exactly what you're describing.

For example, adding "Movie/Movie.mkv" and then renaming it to "Movie (2021)/Movie (2021).mkv" and re-scanning would result in the movie being displayed twice. Deleting "Movie (2021)/Movie (2021).mkv" would obviously result in neither of those entries being useable because the filles they point to don't exist.

The "Clean Library" function checks all entries in the database to make sure that the referenced file is still available, removing that entry from the database if not. That's how it works as far as I understand it from my usage anyway, I haven't confirned that in the code.

(2021-09-21, 00:57)fstr21 Wrote: [ -> ]The dupes don't concern me because if I can clean the entire library of movies that aren't connected to a source any more then it'll fix that problem as well. That's what I'm looking to do in the end. Basically I just want every movie that isn't on a source gone. Hell I can taken out all sources, it's just 2 hdd and delete the entire list and repopulate it if that's easier. Just can't figure out how to get rid of the initial list

Weren't you asking how to get rid of the duplicates? Huh Laugh "Clean Library" should do that as long as the duplicates don't remain on the source(s) (i.e. you've deleted "Movie/Movie.mkv" in the example above meaning that Kodi no longer finds it).

If you just want to remove everything from your library then I'm pretty sure that if you begin to remove a source, you'll be asked if you want to remove everything under that source from the database.

I'm still at work. But I think I might have a possible idea what's going on... By "removing a source" I assumed you meant disconnecting the actual hardware. That's what I was doing unplugging my hdd then running the cleaner. Now I'm thinking there is a software option to remove the source ... Assuming the source is connected ..somewhere in that menu?
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39