Exemplo n.º 1
0
 def clearCache(self, age=None):
     try:
         with closing(Shove('sqlite:///' + self.db_name, compress=True)) as fs:
             fc = cache.Cache(fs)
             fc.purge(age)
     except Exception as e:
         logger.log(u"RSS error clearing cache: " + ex(e), logger.DEBUG)
Exemplo n.º 2
0
    def getFeed(self, url, post_data=None, request_headers=None):
        parsed = list(urlparse.urlparse(url))
        parsed[2] = re.sub("/{2,}", "/",
                           parsed[2])  # replace two or more / with one

        if post_data:
            url += urllib.urlencode(post_data)

        try:
            with closing(Shove('sqlite:///' + self.db_name,
                               compress=True)) as fs:
                fc = cache.Cache(fs)
                feed = fc.fetch(url, False, False, request_headers)

                if feed:
                    if 'entries' in feed:
                        return feed
                    elif 'error' in feed.feed:
                        err_code = feed.feed['error']['code']
                        err_desc = feed.feed['error']['description']

                        logger.log(
                            u"RSS ERROR:[%s] CODE:[%s]" % (err_desc, err_code),
                            logger.DEBUG)
                else:
                    logger.log(u"RSS error loading url: " + url, logger.DEBUG)

        except Exception as e:
            logger.log(u"RSS error: " + ex(e), logger.DEBUG)
Exemplo n.º 3
0
    def getRSSFeed(self, url, post_data=None):
        # create provider storaqe cache
        storage = Shove('sqlite:///' + ek.ek(os.path.join, sickbeard.CACHE_DIR, self.provider.name) + '.db')
        fc = cache.Cache(storage)

        parsed = list(urlparse.urlparse(url))
        parsed[2] = re.sub("/{2,}", "/", parsed[2])  # replace two or more / with one

        if post_data:
            url += urllib.urlencode(post_data)

        f = fc.fetch(url)

        if not f:
            logger.log(u"Error loading " + self.providerID + " URL: " + url, logger.ERROR)
            return None
        elif 'error' in f.feed:
            logger.log(u"Newznab ERROR:[%s] CODE:[%s]" % (f.feed['error']['description'], f.feed['error']['code']),
                       logger.DEBUG)
            return None
        elif not f.entries:
            logger.log(u"No items found on " + self.providerID + " using URL: " + url, logger.WARNING)
            return None

        storage.close()

        return f