Kodi Community Forum

Full Version: Attempting to migrate video.database.cleaner to Kodi 19
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I found a 10 part Python course from StackSkills for $23USD, not a bad price at all!
(2021-05-18, 14:26)kenmills Wrote: [ -> ]not a bad price at all!

There is also https://www.learnpython.org/ (duh..) as a freebie, but that's for the very basics afaict.
@jbinkley60 How are you selecting the value for ContentDeleteURL in your program?
(2021-05-18, 14:54)Klojum Wrote: [ -> ]@jbinkley60 How are you selecting the value for ContentDeleteURL in your program?

That's the URL to my uPNP sever.  I took the lazy way out and parse out the unique TCP port number for the server.  That could be replaced with whatever unique matching path item desired.  So for instance if you are allowing the user to select a path to clean we could use the strPath field from the Path table. 


Jeff
(2021-05-18, 13:21)jbinkley60 Wrote: [ -> ]For Python learning I highly recommend LeanPub Python Apprentice ..  It's PDF and not online and has a small cost but it is very good.  They have an online version but I am not sure how much it is.

Found it. There are plenty document converters available. Got a PDF with clickable links, so that's nice.
They actually have 3 books in the series but 90% or more of what you will likely need is in the Apprentice book.


Jeff
I installed the master source of the database cleaner on my Kodi 19.1 laptop, but I got no program icon on Kodi's add-ons page.
The program starts though. (I haven't fully used it yet)
Thanks!  Yeah I just amended the asset tags as I think they were incorrectly input.

Also, it currently does not fully function - the SQL queries (that need to work with both SQLlite and MySQL) are looking like the culprit.  I am working on them now, as well as incorporating the texturecache.py file into the addon.

I hope to have it updated and ready for full testing by May 31.
Yup, got the icon again, thx. I'll try and do some more work on the movie queries.

Seeing jbinkley60's script, it's possible to retrieve result sets from database queries.
If that can properly work, then we can really get some work done (and if real life allows it).
A few more things that are triggering me (in no particular order):

- Shortening the Kodi messages as much as possible, so there won't be any scrolling necessary. The exit Kodi message text: Script aborted - No changes made causes this text to horizontally scroll because it's just a few characters too long. How about Exit - No changes made ?
- Keeping messages in line with Kodi actions, such as Run "Clean Video Library" for best results
- Change Starting Up to Scanning library.... Starting is itself a 'duh' moment for me.

Hereunder is my current PHP script for removing alienated movie sets.
php:
FUNCTION movieset_remove()
{
# GET ALL SET IDs
$sets = array();
$row_aff = 0 ;
$row_cnt = 0 ;
$query = "SELECT idSet,strSet FROM sets ORDER BY idSet ASC";
$result = do_query($query, 'video', 'Movieset IDs');
# PLACE INTO ARRAY FOR DOUBLECHECK
while ($row = $result->fetch_assoc())
{
$sets[] = $row['idSet'];
$fanart[] = $row['strSet'];
}

# CHECK MOVIES FOR SETIDs
foreach ($sets as $set => $value)
{
$query = 'SELECT idSet FROM movie WHERE idSet='.$value;
$result = do_query($query, 'video', 'Movies in set');
$row_cnt = $result->num_rows;

# CHANGE TO <= 1 FOR REMOVING SETS TO MOVIES WITH ONLY 1 MOVIESET
if ($row_cnt == 0)
{
# REMOVE SET
$subquery = 'DELETE FROM idSet WHERE idSet='.$value;
$subresult = do_query($query, 'video', 'Remove movieset');
$row_aff += $subresult->affected_rows;

# REMOVE MOVIESET FANART FROM MOVIESET FOLDER
$folder = MOVIESET_PATH . $fanart[$set];
# REMOVE REMARK CHARS FOR ACTUAL FOLDER DELETE
// unlink($folder);
}
}
return ($row_aff);
}

Of course, the script could be evenshorter if you leave out the separate storage of set id's , and handle them directly. And adding a START TRANSACTION and ROLLBACK TRANSACTION would add safety.
Great catches mate - I agree with them all and will make those changes.  I like the idea of cleaning up all the text etc, I have just been tunnel-visioned on the DB queries for now.  Great stuff, thx!!
I'm still browsing and learning if the current Python scripts can do what I want them to do. I need to combine script snippets and see if they work for me.
The only beef I have with Python for now is to maintain the 80 char line limit... I'll try, but I'm definitely not gonna make any promises Tongue
(2021-05-22, 19:25)Klojum Wrote: [ -> ]I'm still browsing and learning if the current Python scripts can do what I want them to do. I need to combine script snippets and see if they work for me.
The only beef I have with Python for now is to maintain the 80 char line limit... I'll try, but I'm definitely not gonna make any promises Tongue

Laugh I hear ya!
(2021-05-20, 22:10)kenmills Wrote: [ -> ]I hope to have it updated and ready for full testing by May 31.

Okay... Time is up! Tongue
(2021-05-22, 19:25)Klojum Wrote: [ -> ]I'm still browsing and learning if the current Python scripts can do what I want them to do. I need to combine script snippets and see if they work for me.
The only beef I have with Python for now is to maintain the 80 char line limit... I'll try, but I'm definitely not gonna make any promises Tongue

In Python you put a \ at the end of a line to get around 80 characters.  Here's an example of a large Kodi select query:

        curf = db.execute('SELECT idFile, playcount, idPath, lastPlayed FROM files INNER JOIN episode            \
        USING (idFile) INNER JOIN path USING (idPath) INNER JOIN tvshow USING (idshow)                                 \
        WHERE tvshow.c00=? and idParentPath=? and episode.c12=? and episode.c13=? COLLATE NOCASE',   \
        (mseries, ppathnumb, mseason, mepisode))     # Check if episode exists in Kodi DB under parent path


Jeff
Pages: 1 2 3