jurialmunkey / plugin.video.themoviedb.helper

GNU General Public License v3.0
199 stars 95 forks source link

[Bug] Select Artwork Time error ? #532

Closed DaisyF8 closed 3 years ago

DaisyF8 commented 3 years ago

I can't select any/different artwork for Movies or TvShows.

When using TMDBhelper Options/Manage Artwork/Select artwork/poster I see the previews of possible artwork. But when I select one I get a TMDBhelper error (check log).

http://paste.kodi.tv/azisapojac

I started noticing when correctly identified anime (AniDB.net MOD) only had an occasional clearart associated with them but nothing else. But changing anything for movies or regular tvshows gives the above error.

jurialmunkey commented 3 years ago

Hmm that's weird, haven't encountered that before. The cache expiry date calculation is causing an overflow error - most likely one of the cache object dates got corrupted (maybe a crash whilst one was still writing).

Can you try closing Kodi, then deleting the cache and see if that helps? .kodi\userdata\addon_data\plugin.video.themoviedb.helper\database\FanartTV.db

(note to self - I really have to add some cache management options!)

DaisyF8 commented 3 years ago

I don't think deleting the Fanart database did anything. No change. http://paste.kodi.tv/ejicoyowev

jurialmunkey commented 3 years ago

Can you try deleting the entire database folder (i.e. the actual folder not just the .db files inside)? Make sure Kodi is closed properly because otherwise it might still be trying to write out to the cache (so you delete it but then Kodi just rewrites it if it is still doing exit cleanup)

There's a weird CACHE: Exception while initializing _database: disk I/O error in that log which pretty much is definitely file corruption.

Other possibility is left over journal file in the folder - nuking the entire folder should (hopefully) solve it either way.

DaisyF8 commented 3 years ago

Deleting the folder also didn't change anything. http://paste.kodi.tv/ivaqabicew

Then I turned debugging on and I saw 404 errors before the error. http://paste.kodi.tv/uqabusezav

Then I checked my personal fanart.tv api_key if it was correct. Also checked if my routers Adguard Home wasn't blocking fanart.tv but it wasn't. Restarted without and again with. Still 404 errors but I don't knoww they are related. In the preview window for picking the poster_fanart I keep seeing thumbs of the results I can choose from. http://paste.kodi.tv/ibehisasek

And every time above I also deleted the whole database folder (doesn't hurt).

edit about adguard home

DaisyF8 commented 3 years ago

Ah... I found something. A difference between the handling of Stargate Atlantis and anime SSSS.Gridman. Just giving you every bit of info I can, don't know if this is relevant.

Using "TMDBhelper Options/Manage Artwork/Select artwork/poster" gives in both cases the time-error. I use this menu while in Library, TV-Show overview.

For Stargate, if I pick Info, then Manage, I get "Select Art (Kodi)". Then I can Choose Art, Poster (or Landscape, Banner, ...), and pick between Current Art and 5 different Remote Art, No Art and Browse. This works for setting another image for Poster.

For SSSS.Gridman, if I take the same route, in Choose art I can only choose between No Art and Browse. No summing up of Poster, Landscape, Banner ... in that window.

Edit... thinking about it, this is just Kodi vs TMDBhelper handling Artwork. The time-error isn't related to this difference.

henryjfry commented 3 years ago

I had this problem when I tried to change one of the pieces of art in a TMDB Helper screen, i resolved it as follows:

~/.kodi/addons/plugin.video.themoviedb.helper/resources/lib/addon/simplecache.py

    def set(self, endpoint, data, checksum="", expiration=datetime.timedelta(days=30)):
        '''
            set data in cache
        '''
        with self.busy_tasks(u'set.{}'.format(endpoint)):
            checksum = self._get_checksum(checksum)
            #expires = self._get_timestamp(datetime.datetime.now() + expiration)
            try:
                expires = self._get_timestamp(datetime.datetime.now() + expiration)
            except:
                import time
                expires = time.time() + 1000*24*60*60
            self._set_mem_cache(endpoint, checksum, expires, data)
            if not self._mem_only:
                self._set_db_cache(endpoint, checksum, expires, data)

The problem appears to be with "expires = self._get_timestamp(datetime.datetime.now() + expiration)" so the fix was to return the timestamp in an alternate way with the expiration of 1000 days (which is what it was returning when I interogated what the original "expires = ..." line was doing).

jurialmunkey commented 3 years ago

Bad idea to set cache expiration to 1000 days. Expiration varies depending on data source. Artwork cache is 90 days. Lists are 24hrs. If you cache a list for a 1000 days then you will never get a new list.

Better to find out what the issue is with datetime module and why you need to revert to using time module instead. If there is some unsolvable issue using datetime on some systems then an alternative method of setting a specific cache expiry needs to be done not some fixed value.

henryjfry commented 3 years ago

Hey, yeah I realised that that the 1000 days was only for the artwork refresh which was causing the overflow error, i changed the exception to use the actual period "expiration" instead

jurialmunkey commented 3 years ago

Just realised that this issue is a Y2038 bug.

After the discussion about the Select Artwork cache being 1000 days, I noticed that it is actually 10,000 days. So the end date goes past 2038-Jan-19 which is the upper limit for 32bit unix timestamps.

I didn't twig at first because Python 3 allows integers larger than 32bits, so Y2038 shouldn't be an issue anyway. However, since mktime uses floating point numbers, likely there is some underlying C+ module which mktime relies upon which can't handle 64bit floating point operations on some systems (e.g. running Kodi on a Smart TV like DaisyF8 is).

Anyway, latest git version should fix the issue. @DaisyF8 - could you test and confirm if that solves the issue for you?

henryjfry commented 3 years ago

Ahh, yeah that sounds like thats the problem. Although im running OSMC on a pi4/vero 4k (not sure which system I had the issue on) so its not just smart TV's that it appears to effect.

DaisyF8 commented 3 years ago

Your update 4.3.35 solved the issue on my Sony SmartTV (and also I think on my Shield TV) :)

edit : Seems like I can't change Artwork for the movies and series on my nas ... "Manage Artwork" does work for media in for example Trakt/TV/InProgress which isn't stored locally. But if an entry in that list is also in my Kodi Library the artwork differs from my library-artwork but can't be changed..

edit2 : removed "(indexed with local information)" and explainded about list some more. I realise this is beyond the scope of this issue

jurialmunkey commented 3 years ago

Excellent thanks for testing.

Yeah if you have local info and the setting enabled, that gets added last so it will overwrite any online info. In those cases you'd need to change the artwork in your library instead (or disable the TMDbH setting to merge local info)