zombiB / zombi-addons

47 stars 23 forks source link

Search don't work when cache is enabled #103

Closed zombiB closed 1 year ago

zombiB commented 1 year ago

Search skip many sites with the bug "sqlite objects created.." Problem present when using the all sites search

Mr-7mdan commented 1 year ago

I will check and fix enshallah. Today I added some exclusions but will do a more comprehensive testing soon

bassemhelal18 commented 1 year ago

This solution work if you change this 'def request(self, jsonDecode=False, FetchNew=False): ADDON = addon() CacheStatus = ADDON.getSetting('RequestCache') CacheDur = ADDON.getSetting('RequestCacheDuration')

    sTime = time.time()
    # Supprimee car deconne si url contient ' ' et '+' en meme temps
    url = self.__sUrl#.replace(' ', '+')
    if FetchNew == True:
        VSlog("New Request for: " + url)
        VSlog("Finished request in {s}s".format(s=time.time()-sTime))
        return self.__callRequest(jsonDecode)
    else:
        if CacheStatus == 'true':
            if "https://api.themoviedb.org" or 'php' or 'ajax' or '/?s=' or 'search' or '/?q=' not in url:
                try:            
                    Cached = db.get(url)
                except:
                    Cached = None

                if Cached is None: ##if not in cache
                    VSlog('Matrix : No cache found for [%s]' % (url))
                    resp = self.__callRequest(jsonDecode)
                    forcaching = {"sUrl": url, "val": resp}
                    VSlog("New Request for: " + url)
                    VSlog("Finished request in {s}s".format(s=time.time()-sTime))
                    db.set(forcaching, int(CacheDur)*60*60)
                    VSlog("Saving new cache")

                else:
                    resp = Cached
                    VSlog("Cache Request for: " + url)
                    VSlog("Finished request in {s}s".format(s=time.time()-sTime))
                return resp
            else:
                VSlog("Cache Request is disabled for tmdb and search urls")
                return self.__callRequest(jsonDecode)
        else:
            VSlog("Cache Request is disabled in settings")
            return self.__callRequest(jsonDecode)'

To 'def request(self, jsonDecode=False, FetchNew=False): ADDON = addon() CacheStatus = ADDON.getSetting('RequestCache') CacheDur = ADDON.getSetting('RequestCacheDuration')

    sTime = time.time()
    # Supprimee car deconne si url contient ' ' et '+' en meme temps
    url = self.__sUrl#.replace(' ', '+')
    if FetchNew == True:
        VSlog("New Request for: " + url)
        VSlog("Finished request in {s}s".format(s=time.time()-sTime))
        return self.__callRequest(jsonDecode)
    else:
        if CacheStatus == 'true':
            if "https://api.themoviedb.org" not in url:
                if '?s='  not in url:
                    if 'search'  not in url:
                     if 'find'  not in url:
                      if 'ajax'  not in url:
                       if 'php'  not in url:

                        try:            
                         Cached = db.get(url)
                        except:
                         Cached = None

                        if Cached is None: ##if not in cache
                         VSlog('Matrix : No cache found for [%s]' % (url))
                         resp = self.__callRequest(jsonDecode)
                         forcaching = {"sUrl": url, "val": resp}
                         VSlog("New Request for: " + url)
                         VSlog("Finished request in {s}s".format(s=time.time()-sTime))
                         db.set(forcaching, int(CacheDur)*60*60)
                         VSlog("Saving new cache")

                        else:
                         resp = Cached
                         VSlog("Cache Request for: " + url)
                         VSlog("Finished request in {s}s".format(s=time.time()-sTime))
                        return resp
                       else:
                        VSlog("Cache Request is disabled for this php url")
                        return self.__callRequest(jsonDecode)
                      else:
                        VSlog("Cache Request is disabled for this php url")
                        return self.__callRequest(jsonDecode)  
                     else:
                        VSlog("Cache Request is disabled for this php url")
                        return self.__callRequest(jsonDecode)
                    else:
                        VSlog("Cache Request is disabled for this php url")
                        return self.__callRequest(jsonDecode)
                else:
                    VSlog("Cache Request is disabled for this php url")
                    return self.__callRequest(jsonDecode)
            else:
                VSlog("Cache Request is disabled for tmdb urls")
                return self.__callRequest(jsonDecode)
        else:
            VSlog("Cache Request is disabled in settings")
            return self.__callRequest(jsonDecode)'
Mr-7mdan commented 1 year ago

it is fixed now https://github.com/zombiB/zombi-addons/commit/72c82e3eb0234112cc5b1e8774bc42bbc5430553

Thank you both