コード例 #1
0
ファイル: name_cache.py プロジェクト: TATUMTOT/SickRage
    def buildNameCache(self, show=None):
        """Build internal name cache

        :param show: Specify show to build name cache for, if None, just do all shows
        """

        if self.shouldUpdate():
            if not show:
                retrieve_exceptions()
                for show in sickrage.showList:
                    sickrage.LOGGER.info("Building internal name cache for all shows")
                    self.buildNameCache(show)
            else:
                self.lastUpdate = datetime.datetime.fromtimestamp(
                        int(time.mktime(datetime.datetime.today().timetuple()))
                )

                sickrage.LOGGER.debug("Building internal name cache for [{}]".format(show.name))
                self.clearCache(show.indexerid)
                for curSeason in [-1] + get_scene_seasons(show.indexerid):
                    for name in list(set(get_scene_exceptions(
                            show.indexerid, season=curSeason) + [show.name])):

                        name = full_sanitizeSceneName(name)
                        if name not in self.cache:
                            self.cache[name] = int(show.indexerid)

                sickrage.LOGGER.debug("Internal name cache for [{}] set to: [{}]".format(
                        show.name, [key for key, value in self.cache.items() if value == show.indexerid][0]))
コード例 #2
0
ファイル: name_cache.py プロジェクト: robrossuk/SiCKRAGE
    def build(self, show):
        """Build internal name cache

        :param show: Specify show to build name cache for, if None, just do all shows
        """

        retrieve_exceptions()

        if self.should_update(show):
            self.last_update[show.name] = datetime.fromtimestamp(
                int(time.mktime(datetime.today().timetuple())))

            self.clear(show.indexerid)

            show_names = []
            for curSeason in [-1] + get_scene_seasons(show.indexerid):
                for name in list(
                        set(
                            get_scene_exceptions(show.indexerid,
                                                 season=curSeason) +
                            [show.name])):
                    show_names.append(name)
                    show_names.append(strip_accents(name))
                    show_names.append(strip_accents(name).replace("'", " "))

            for show_name in set(show_names):
                self.clear(show_name)
                self.put(show_name, show.indexerid)
コード例 #3
0
ファイル: name_cache.py プロジェクト: scottanderson/SiCKRAGE
    def build(self, show=None, force=False):
        """Build internal name cache

        :param show: Specify show to build name cache for, if None, just do all shows
        """

        if not show:
            retrieve_exceptions()
            for show in sickrage.srCore.SHOWLIST:
                self.build(show)
        elif self.should_update(show):
            self.lastUpdate[show.name] = datetime.fromtimestamp(
                int(time.mktime(datetime.today().timetuple())))

            sickrage.srCore.srLogger.debug(
                "Building internal name cache for [{}]".format(show.name))
            self.clear(show.indexerid)
            for curSeason in [-1] + get_scene_seasons(show.indexerid):
                for name in list(
                        set(
                            get_scene_exceptions(show.indexerid,
                                                 season=curSeason) +
                            [show.name])):
                    self.put(name, show.indexerid)

            sickrage.srCore.srLogger.debug(
                "Internal name cache for [{}] set to: [{}]".format(
                    show.name, [
                        key for key, value in self.cache.items()
                        if value == show.indexerid
                    ][0]))
コード例 #4
0
    def test_sceneExceptionsResetNameCache(self):
        # clear the exceptions
        cache_db.CacheDB().action("DELETE FROM scene_exceptions")

        # put something in the cache
        sickrage.NAMECACHE.addNameToCache('Cached Name', 0)

        # updating should not clear the cache this time since our exceptions didn't change
        retrieve_exceptions()
        self.assertEqual(sickrage.NAMECACHE.retrieveNameFromCache('Cached Name'), 0)
コード例 #5
0
    def test_sceneExceptionsResetNameCache(self):
        # clear the exceptions
        cache_db.CacheDB().action("DELETE FROM scene_exceptions")

        # put something in the cache
        sickrage.NAMECACHE.addNameToCache('Cached Name', 0)

        # updating should not clear the cache this time since our exceptions didn't change
        retrieve_exceptions()
        self.assertEqual(
            sickrage.NAMECACHE.retrieveNameFromCache('Cached Name'), 0)
コード例 #6
0
ファイル: name_cache.py プロジェクト: gborri/SiCKRAGE
    def build(self, show):
        """Build internal name cache

        :param show: Specify show to build name cache for, if None, just do all shows
        """

        retrieve_exceptions()

        if self.should_update(show):
            self.last_update[show.name] = datetime.fromtimestamp(int(time.mktime(datetime.today().timetuple())))

            self.clear(show.indexerid)
            for curSeason in [-1] + get_scene_seasons(show.indexerid):
                for name in list(set(get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])):
                    self.put(name, show.indexerid)
コード例 #7
0
ファイル: name_cache.py プロジェクト: jas31085/SiCKRAGE
    def build(self, show):
        """Build internal name cache

        :param show: Specify show to build name cache for, if None, just do all shows
        """

        retrieve_exceptions()

        if self.should_update(show):
            self.last_update[show.name] = datetime.fromtimestamp(
                int(time.mktime(datetime.today().timetuple())))

            self.clear(show.indexerid)

            show_names = []
            for curSeason in [-1] + get_scene_seasons(show.indexerid):
                for name in list(
                        set(
                            get_scene_exceptions(show.indexerid,
                                                 season=curSeason) +
                            [show.name])):
                    show_names.append(name)

                    # strip accents
                    try:
                        try:
                            name.decode('ascii')
                        except UnicodeEncodeError:
                            pass

                        show_names.append(
                            unicodedata.normalize('NFKD', name).encode(
                                'ASCII', 'ignore'))
                        show_names.append(
                            unicodedata.normalize('NFKD', name).encode(
                                'ASCII', 'ignore').replace("'", " "))
                    except UnicodeDecodeError:
                        pass

            for show_name in set(show_names):
                self.put(show_name, show.indexerid)
コード例 #8
0
    def build(self, show=None, force=False):
        """Build internal name cache

        :param show: Specify show to build name cache for, if None, just do all shows
        """

        if not show:
            retrieve_exceptions()
            for show in sickrage.srCore.SHOWLIST:
                self.build(show)
        elif self.should_update(show):
            self.last_update[show.name] = datetime.fromtimestamp(int(time.mktime(datetime.today().timetuple())))

            sickrage.srCore.srLogger.debug("Building internal name cache for [{}]".format(show.name))
            self.clear(show.indexerid)
            for curSeason in [-1] + get_scene_seasons(show.indexerid):
                for name in list(set(get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])):
                    self.put(name, show.indexerid)

            sickrage.srCore.srLogger.debug("Internal name cache for [{}] set to: [{}]".format(
                show.name, [key for key, value in self.cache.items() if value == show.indexerid][0]))
コード例 #9
0
ファイル: name_cache.py プロジェクト: becian/SickRage-1
    def buildNameCache(self, show=None):
        """Build internal name cache

        :param show: Specify show to build name cache for, if None, just do all shows
        """

        if self.shouldUpdate():
            if not show:
                retrieve_exceptions()
                for show in sickrage.showList:
                    sickrage.LOGGER.info(
                        "Building internal name cache for all shows")
                    self.buildNameCache(show)
            else:
                self.lastUpdate = datetime.datetime.fromtimestamp(
                    int(time.mktime(datetime.datetime.today().timetuple())))

                sickrage.LOGGER.debug(
                    "Building internal name cache for [{}]".format(show.name))
                self.clearCache(show.indexerid)
                for curSeason in [-1] + get_scene_seasons(show.indexerid):
                    for name in list(
                            set(
                                get_scene_exceptions(show.indexerid,
                                                     season=curSeason) +
                                [show.name])):

                        name = full_sanitizeSceneName(name)
                        if name not in self.cache:
                            self.cache[name] = int(show.indexerid)

                sickrage.LOGGER.debug(
                    "Internal name cache for [{}] set to: [{}]".format(
                        show.name, [
                            key for key, value in self.cache.items()
                            if value == show.indexerid
                        ][0]))
コード例 #10
0
 def setUp(self):
     super(SceneExceptionTestCase, self).setUp()
     scene_exceptions.retrieve_exceptions()
コード例 #11
0
 def setUp(self, **kwargs):
     super(SceneExceptionTestCase, self).setUp()
     retrieve_exceptions()
コード例 #12
0
 def build_all(self):
     retrieve_exceptions(force=True)
     for show in get_show_list():
         self.build(show)
コード例 #13
0
 def setUp(self, **kwargs):
     super(SceneExceptionTestCase, self).setUp()
     retrieve_exceptions()
コード例 #14
0
 def setUp(self):
     super(SceneExceptionTestCase, self).setUp()
     scene_exceptions.retrieve_exceptions()