Kodi Community Forum
HOWTO - Force refresh of all library art - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: HOWTO - Force refresh of all library art (/showthread.php?tid=323954)

Pages: 1 2


HOWTO - Force refresh of all library art - pathartl - 2017-11-13

I recently changed the destination in my library for all my media from a mapped network drive (e.g. M:\Media\Movies) to a smb URI (smb://pathartl-server/Media/Movies). This however had some side effects that I was not expecting. Most of the art for everything started turning up blank. Running Artwork Downloader and updating the library would not resolve the issue. I did however notice that I was able to use the manual download feature of AD to replace the missing art. I figured the paths had to be cached somehow.

Normally people say to just delete your database and start anew. Since my database has been evolving over the past 4-5 years, losing stuff like watch status and manual movie sets was just not acceptable for me.

Within the Kodi database there is a table called 'art'. Put simply, if you truncate this table and run Artwork Downloader, all of your art should be refreshed.

For a more in depth guide:
  1. Close Kodi on all applicable devices
  2. Connect to your database
    1. If you are using shared libraries via MySQL, use some sort of MySQL client to connect to the database. Make sure to "use MyVideos<DBNUM>;" on the correct database. If you are unsure which version this is, check your kodi.log file.
    2. If you are using local databases, download a SQLite client (I like DB Browser for SQLite)
  3. Unless you're middle name is Danger, back up your database
  4. Select your database and run the SQL query 
    sql:
    truncate table 'art';
  5. Delete the Thumbnails folder under the userdata folder
  6. Delete the Textures<DBNUM>.db file from the userdata/Databases folder
  7. Start Kodi
  8. Run Artwork Downloader

This worked mostly-perfectly for me. There are a few caveats:
  • Any manually assigned local art will probably get unassigned from the media. You'll have to go and assign it via Kodi again unless it fits Artwork Downloader's requirements.
  • Movie sets will most likely lose their cover art.
  • If you've used Artwork Downloader to choose a certain remote art, you will have to go back and reassign it.



RE: HOWTO - Force refresh of all library art - samhayne - 2021-12-31

2021 this still works perfectly. Thanks for that!

Moved my library to a new PC only exporting movie data but not the artwork files.

Just running Artwork Downloader didn’t do the trick.
After removing all entries in the art table of MyVideos db all movies have covers again.

Caveat: All movie folders are littered with the artworks now.

A possibly working alternative I could imagine:
Mass process all .nfo files with a tool like grepwin and replace “<thumb aspect” with something like “<dumb aspect” and </thumb> with </dumb>. Clearing and rescaping the library may then download new thumbs instead of trying to download/reference old artwork which is no longer available online by now.
(But this is just an idea while the upper method definitely works)


RE: HOWTO - Force refresh of all library art - samhayne - 2023-01-31

And as of 2023 and Kodi 19 this still works nicely.

I accidently had my hard drive detached, hit the wrong button and boom - library gone.
After importing it again most artwork was blank due to orphaned 404 links.
Tried to fix it with Artwork Dump - but doesn't look like it's the right tool for that case.

The method described here also worked for this case!!


Two hints for total Kodi hobbyists like me:
- How I did the database art wiping:
  1. Downloaded "DB Browser for SQLite" from https://sqlitebrowser.org
  2. Opened the DB in C:\Users\[user]\AppData\Roaming\Kodi\userdata\Database\MyVideos119.db 
  3. Clicked the "Browse Data" tab, selected the 'art' table, hit 'ctrl+a' to select all entries and deleted them with the "delete the current record" button. (For whatever reason I couldn't execute "truncate table 'art'".
- If you struggle like me adding Artwork Downloader from its repo: Click the link to the left, hit the green "Code" button and "Download as zip". In Kodi find "Add-Ons" and "Install from zip file".


After running Artwork Downloader 99.9% of my movies had artwork again. Very few I had to refresh to download their artwork.

Really a pity that there's no built-in function in Kodi to fix orphaned artwork links.


RE: HOWTO - Force refresh of all library art - black_eagle - 2023-01-31

(2023-01-31, 16:13)samhayne Wrote: For whatever reason I couldn't execute "truncate table 'art

You just need to execute DELETE FROM art; in the Execute SQL tab and then write the changes.  That will nuke all the art in the art table.


RE: HOWTO - Force refresh of all library art - nazarux - 2023-09-13

My problem is related but somehow different. I had a maintenance addon with a service included that, among other things, deleted all thumbnails by both deleting them and connecting to Textures13.db removing it’s entries WITHOUT restarting Kodi. My point, to use it as a service, was doing it without restarts. Then, when browsing files again the thumbnails were regenerated. This still works on Kodi 18. But with Kodi 20, by browsing the files, the thumbnail are not repopulated. This code removes them from the Textures13.db but Kodi only repopulate thumbnails after restart, what was not needed with Kodi 18. After all, it would be easier to just delete the Textures13.db and restart but I wrote this to reset the thumbnails without restart – that’s my point:

Code:
def clearTextures13DB():
    import sqlite3
    import csv

    db = xbmcvfs.translatePath('special://database/Textures13.db')
    conn = sqlite3.connect(db)
    cur = conn.cursor()

    cur.execute("DELETE FROM texture;")
    cur.execute("DELETE FROM path;")
    cur.execute("DELETE FROM sizes;")

    conn.commit()
    cur.execute("VACUUM;")
    conn.close()

This still works to empty the 3 tables but thumbs are not repopulated when browsing and in version 18, it did. Is there some python function to force the refresh?


RE: HOWTO - Force refresh of all library art - jbinkley60 - 2023-09-13

(2023-09-13, 02:34)nazarux Wrote: This still works to empty the 3 tables but thumbs are not repopulated when browsing and in version 18, it did. Is there some python function to force the refresh?

Here's code I've been using on Kodi 19 and 20 and it will regenerate / refresh thumbnails.  Instead of deleting the table entries I set the lastahshchecked time back 3 days.


Thanks,

Jeff


RE: HOWTO - Force refresh of all library art - nazarux - 2023-09-13

(2023-09-13, 02:56)jbinkley60 Wrote: Instead of deleting the table entries I set the lastahshchecked time back 3 days.

Thanks for your answer.
I my case this actually doesn’t work .

I can do the lasthashcheck time back using your idea and code but, in fact, only customized and addons icons have lasthashcheck entries. Movie thumbnails don’t.
Removing chachedurl entries doesn’t help either.
Remember that the thumbnails files are physically removed (that’s the goal) but Kodi keeps ‘hoping’ to find them, that’s why my approach was to remove their entries from Textures13.db and it worked until version 18 (never tried with19).
But I believe that somehow, the database is kept in memory until restart and there must be a function to force the reading/updating, as it does when restarting.

I’m running Kodi on linux.

Image


RE: HOWTO - Force refresh of all library art - jbinkley60 - 2023-09-13

(2023-09-13, 20:29)nazarux Wrote: Thanks for your answer.
I my case this actually doesn’t work .

I can do the lasthashcheck time back using your idea and code but, in fact, only customized and addons icons have lasthashcheck entries. Movie thumbnails don’t.
Removing chachedurl entries doesn’t help either.
Remember that the thumbnails files are physically removed (that’s the goal) but Kodi keeps ‘hoping’ to find them, that’s why my approach was to remove their entries from Textures13.db and it worked until version 18 (never tried with19).
But I believe that somehow, the database is kept in memory until restart and there must be a function to force the reading/updating, as it does when restarting.

I’m running Kodi on linux.

I am not 100% following what you want to do.  So you are deleting the artwork files.  Are you replacing them with a new file ?  If so, with the same artwork file name or different ?  If the artwork file name is different then there is no issue in doing nothing  If the artwork file name is the same then my method should work.  You may need to remove the "URL LIKE ? " in the WHERE clause in the SQL statement to set the lasthashcheck entry for all entries in the texture table.  From my testing when the lasthashcheck entry is blank Kodi resorts to some unknown recheck timer (unknown by me) which is why I set the blanks to a date 3 days ago,  I have found that causes Kodi to recheck the next time the file is accessed.


Thanks,

Jeff


RE: HOWTO - Force refresh of all library art - izprtxqkft - 2023-09-13

(2023-09-13, 21:14)jbinkley60 Wrote: when the lasthashcheck entry is blank Kodi resorts to some unknown recheck timer (unknown by me)

allow me ...

check date is here - https://github.com/xbmc/xbmc/blob/master/xbmc/TextureDatabase.cpp#L254
will not set and therefor not return details.hash based on time frame and validity

when details.hash is empty it triggers other processes

like "needsRecaching" here - https://github.com/xbmc/xbmc/blob/master/xbmc/TextureCache.cpp#L110

needsRecaching is used here - https://github.com/xbmc/xbmc/blob/master/xbmc/TextureCacheJob.cpp#L63


RE: HOWTO - Force refresh of all library art - jbinkley60 - 2023-09-13

(2023-09-13, 21:30)jepsizofye Wrote: allow me ...

check date is here - https://github.com/xbmc/xbmc/blob/master...e.cpp#L254
will not set and therefor not return details.hash based on time frame and validity

when details.hash is empty it triggers other processes

like "needsRecaching" here - https://github.com/xbmc/xbmc/blob/master...e.cpp#L110

needsRecaching is used here - https://github.com/xbmc/xbmc/blob/master...ob.cpp#L63

I agree that when lasthashcheck is empty Kodi will eventually recheck.  What is unclear is the time interval for this recheck.  With my approach I have found it is always on next access.  I played with different time intervals a few years back and probably figured it out.  What I did instead is just set it back 3 days and that always forces a recheck.  But I haven't officially tested this with Kodi 20 and higher but I've never seen an issue with 19 and my anecdotal evidence with Kodi 20 is that when I make a change to the artwork file (same file name) it is reflected on next access.  I've not seen an issue during normal Kodi usage.


Thanks,

Jeff


RE: HOWTO - Force refresh of all library art - izprtxqkft - 2023-09-13

(2023-09-13, 21:42)jbinkley60 Wrote: What is unclear is the time interval for this recheck. 

it's in the first link lastCheck + CDateTimeSpan(1,0,0,0) < CDateTime::GetCurrentDateTime()

if (lastCheck + one day) is less than current date


RE: HOWTO - Force refresh of all library art - jbinkley60 - 2023-09-13

(2023-09-13, 21:46)jepsizofye Wrote: it's in the first link lastCheck + CDateTimeSpan(1,0,0,0) < CDateTime::GetCurrentDateTime()

if (lastCheck + one day) is less than current date

I thought so but my C++ is a bit rusty.  it's been 30 years since I did C++ programming.  That seems to align with what I recall testing, hence the 3 days to make absolutely certain.


Thanks,

Jeff


RE: HOWTO - Force refresh of all library art - izprtxqkft - 2023-09-13

(2023-09-13, 21:49)jbinkley60 Wrote: That seems to align with what I recall testing, hence the 3 days to make absolutely certain.

i concur, really just trying to fill in some information for you, i had a good look at the textures mechanism since i use android and it tends to be bloated

-----

fun fact : you can create an sqlite trigger "AFTER INSERT" to "DELETE FROM texture" in the textures database which effectively breaks caching

it will still cache files but will never retrieve from cache so it grows the cache very quickly


RE: HOWTO - Force refresh of all library art - izprtxqkft - 2023-09-13

more-so on topic

@nazarux i am able to refresh textures, without restarting kodi, on debian linux Kodi v21

this works -
DELETE FROM texture;

but requires -
Container.Refresh()

or -
ReloadSkin()


any attempts to change the data in textures then refresh instead of deleting resulted in the necessity of a "kill -9"


to issue either of those commands from python use xbmc.executebuiltin("")

or just load them to F5 into your keymap as i have done


RE: HOWTO - Force refresh of all library art - jbinkley60 - 2023-09-13

(2023-09-13, 22:43)jepsizofye Wrote: any attempts to change the data in textures then refresh instead of deleting resulted in the necessity of a "kill -9"

Even using my approach of setting the lasthashchecked date back 3 days ?  If so, that shouldn't happen.


Jeff