Exemplo n.º 1
0
def buildNameCache(show=None):
    """Build internal name cache

    :param show: Specify show to build name cache for, if None, just do all shows
    """
    with nameCacheLock:
        scene_exceptions.retrieve_exceptions()

    if not show:
        logging.info("Building internal name cache for all shows")
        for show in sickbeard.showList:
            buildNameCache(show)
    else:
        logging.debug("Building internal name cache for [{}]".format(show.name))
        clearCache(show.indexerid)
        for curSeason in [-1] + scene_exceptions.get_scene_seasons(show.indexerid):
            for name in list(set(scene_exceptions.get_scene_exceptions(show.indexerid, season=curSeason) + [
                show.name])):
                name = sickbeard.helpers.full_sanitizeSceneName(name)
                if name in nameCache:
                    continue

                nameCache[name] = int(show.indexerid)
        logging.debug("Internal name cache for {} set to: [{}]".format(show.name,
                                                                     [key for key, value in nameCache.items() if
                                                                      value == show.indexerid]))
Exemplo n.º 2
0
    def check_for_new_version(self, force=False):
        """
        Checks the internet for a newer version.
        
        returns: bool, True for new version or False for no new version.
        
        force: if true the VERSION_NOTIFY setting will be ignored and a check will be forced
        """

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()
        ui.notifications.message('Updateing scene exceptions')

        if not sickbeard.VERSION_NOTIFY and not force:
            logger.log(u"Version checking is disabled, not checking for the newest version")
            return False

        logger.log(u"Checking if "+self.install_type+" needs an update")
        if not self.updater.need_update():
            logger.log(u"No update needed")
            if force:
                ui.notifications.message('No update needed')
            return False

        self.updater.set_newest_text()
        return True
Exemplo n.º 3
0
    def run(self, force=False):
        updated = None
        if self.check_for_new_version():
            if sickbeard.AUTO_UPDATE:
                logger.log(
                    u"New update found for SickRage, starting auto-updater ..."
                )
                updated = sickbeard.versionCheckScheduler.action.update()
                if updated:
                    logger.log(
                        u"Update was successfull, restarting SickRage ...")

                    # do a soft restart
                    threading.Timer(2, sickbeard.invoke_restart,
                                    [False]).start()

        if not updated:
            # refresh scene exceptions too
            scene_exceptions.retrieve_exceptions()

            # refresh network timezones
            network_timezones.update_network_dict()

            # sure, why not?
            if sickbeard.USE_FAILED_DOWNLOADS:
                failed_history.trimHistory()
Exemplo n.º 4
0
def buildNameCache(show=None):
    """Build internal name cache

    :param show: Specify show to build name cache for, if None, just do all shows
    """
    with nameCacheLock:
        scene_exceptions.retrieve_exceptions()

    if not show:
        logging.info("Building internal name cache for all shows")
        for show in sickbeard.showList:
            buildNameCache(show)
    else:
        logging.debug("Building internal name cache for [{}]".format(
            show.name))
        clearCache(show.indexerid)
        for curSeason in [-1] + scene_exceptions.get_scene_seasons(
                show.indexerid):
            for name in list(
                    set(
                        scene_exceptions.get_scene_exceptions(
                            show.indexerid, season=curSeason) + [show.name])):
                name = sickbeard.helpers.full_sanitizeSceneName(name)
                if name in nameCache:
                    continue

                nameCache[name] = int(show.indexerid)
        logging.debug("Internal name cache for {} set to: [{}]".format(
            show.name, [
                key
                for key, value in nameCache.items() if value == show.indexerid
            ]))
Exemplo n.º 5
0
    def check_for_new_version(self, force=False):
        """
        Checks the internet for a newer version.
        
        returns: bool, True for new version or False for no new version.
        
        force: if true the VERSION_NOTIFY setting will be ignored and a check will be forced
        """

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()
        ui.notifications.message('Updateing scene exceptions')

        if not sickbeard.VERSION_NOTIFY and not force:
            logger.log(
                u"Version checking is disabled, not checking for the newest version"
            )
            return False

        logger.log(u"Checking if " + self.install_type + " needs an update")
        if not self.updater.need_update():
            logger.log(u"No update needed")
            if force:
                ui.notifications.message('No update needed')
            return False

        self.updater.set_newest_text()
        return True
Exemplo n.º 6
0
    def run(self):
        self.check_for_new_version()

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()

        # refresh network timezones
        network_timezones.update_network_dict()
Exemplo n.º 7
0
 def run(self):
     self.check_for_new_version()
     
     # refresh scene exceptions too
     scene_exceptions.retrieve_exceptions()
     
     # refresh network timezones
     network_timezones.update_network_dict()
Exemplo n.º 8
0
    def run(self):
        self.check_for_new_version()

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()

        # sure, why not?
        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.trimHistory()
Exemplo n.º 9
0
    def run(self):
        self.check_for_new_version()

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()

        # sure, why not?
        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.trimHistory()
Exemplo n.º 10
0
    def setUp(self):
        super(SceneExceptionTestCase, self).setUp()

        sickbeard.showList = [
            TVShow(TVINFO_TVDB, 79604),
            TVShow(TVINFO_TVDB, 251085)
        ]
        scene_exceptions.retrieve_exceptions()
        name_cache.buildNameCache()
Exemplo n.º 11
0
 def test_sceneExceptionByNameAnime(self):
     sickbeard.showList = None
     sickbeard.showList = [Show(1, 79604), Show(1, 295243)]
     sickbeard.showList[0].anime = 1
     sickbeard.showList[1].anime = 1
     scene_exceptions.retrieve_exceptions()
     name_cache.buildNameCache()
     self.assertEqual(scene_exceptions.get_scene_exception_by_name(u'ブラック・ラグーン'), [79604, -1])
     self.assertEqual(scene_exceptions.get_scene_exception_by_name(u'Burakku Ragūn'), [79604, -1])
     self.assertEqual(scene_exceptions.get_scene_exception_by_name('Rokka no Yuusha'), [295243, -1])
Exemplo n.º 12
0
 def test_sceneExceptionByNameAnime(self):
     sickbeard.showList = None
     sickbeard.showList = [Show(1, 79604), Show(1, 295243)]
     sickbeard.showList[0].anime = 1
     sickbeard.showList[1].anime = 1
     scene_exceptions.retrieve_exceptions()
     name_cache.buildNameCache()
     self.assertEqual(scene_exceptions.get_scene_exception_by_name(u'ブラック・ラグーン'), [79604, -1])
     self.assertEqual(scene_exceptions.get_scene_exception_by_name(u'Burakku Ragūn'), [79604, -1])
     self.assertEqual(scene_exceptions.get_scene_exception_by_name('Rokka no Yuusha'), [295243, -1])
Exemplo n.º 13
0
    def setUp(self):
        super(SceneExceptionTestCase, self).setUp()

        sickbeard.showList = []
        sickbeard.showDict = {}
        for s in [TVShow(TVINFO_TVDB, 79604), TVShow(TVINFO_TVDB, 251085), TVShow(TVINFO_TVDB, 78744)]:
            sickbeard.showList.append(s)
            sickbeard.showDict[s.sid_int] = s
        scene_exceptions.retrieve_exceptions()
        name_cache.buildNameCache()
Exemplo n.º 14
0
    def test_sceneExceptionsResetNameCache(self):
        # clear the exceptions
        myDB = db.DBConnection("cache.db")
        myDB.action("DELETE FROM scene_exceptions")

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

        # updating should not clear the cache this time since our exceptions didn't change
        scene_exceptions.retrieve_exceptions()
        self.assertEqual(name_cache.retrieveNameFromCache('Cached Name'), 0)
Exemplo n.º 15
0
    def test_sceneExceptionsResetNameCache(self):
        # clear the exceptions
        myDB = db.DBConnection("cache.db")
        myDB.action("DELETE FROM scene_exceptions")

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

        # updating should not clear the cache this time since our exceptions didn't change
        scene_exceptions.retrieve_exceptions()
        self.assertEqual(name_cache.retrieveNameFromCache('Cached Name'), 0)
Exemplo n.º 16
0
    def test_sceneExceptionsResetNameCache(self):
        # clear the exceptions
        my_db = db.DBConnection()
        my_db.action('DELETE FROM scene_exceptions WHERE 1=1')

        # put something in the cache
        name_cache.addNameToCache('Cached Name', prodid=0)

        # updating should not clear the cache this time since our exceptions didn't change
        scene_exceptions.retrieve_exceptions()
        self.assertEqual(name_cache.retrieveNameFromCache('Cached Name'), (0, 0))
Exemplo n.º 17
0
 def test_sceneExceptionByNameAnime(self):
     sickbeard.showList = []
     sickbeard.showDict = {}
     for s in [TVShow(TVINFO_TVDB, 79604), TVShow(TVINFO_TVDB, 295243)]:
         s.anime = 1
         sickbeard.showList.append(s)
         sickbeard.showDict[s.sid_int] = s
     scene_exceptions.retrieve_exceptions()
     name_cache.buildNameCache()
     self.assertEqual(scene_exceptions.get_scene_exception_by_name(u'ブラック・ラグーン'), [1, 79604, -1])
     self.assertEqual(scene_exceptions.get_scene_exception_by_name(u'Burakku Ragūn'), [1, 79604, -1])
     self.assertEqual(scene_exceptions.get_scene_exception_by_name('Rokka no Yuusha'), [1, 295243, -1])
Exemplo n.º 18
0
    def test_scene_ex_reset_name_cache(self):
        """
        Test scene exceptions reset name cache
        """
        # clear the exceptions
        test_cache_db_con = db.DBConnection('cache.db')
        test_cache_db_con.action("DELETE FROM scene_exceptions")

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

        # updating should not clear the cache this time since our exceptions didn't change
        scene_exceptions.retrieve_exceptions()
        self.assertEqual(name_cache.retrieveNameFromCache('Cached Name'), 0)
Exemplo n.º 19
0
    def test_scene_ex_reset_name_cache(self):
        """
        Test scene exceptions reset name cache
        """
        # clear the exceptions
        test_cache_db_con = db.DBConnection('cache.db')
        test_cache_db_con.action("DELETE FROM scene_exceptions")

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

        # updating should not clear the cache this time since our exceptions didn't change
        scene_exceptions.retrieve_exceptions()
        self.assertEqual(name_cache.retrieveNameFromCache('Cached Name'), 0)
Exemplo n.º 20
0
    def run(self, force=False):
        self.amActive = True

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()

        # refresh network timezones
        network_timezones.update_network_dict()

        # sure, why not?
        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.trimHistory()

        self.amActive = False
Exemplo n.º 21
0
    def run(self, force=False):
        self.amActive = True

        # get and update scene exceptions lists
        scene_exceptions.retrieve_exceptions()

        # refresh network timezones
        network_timezones.update_network_dict()

        # sure, why not?
        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.trimHistory()

        self.amActive = False
Exemplo n.º 22
0
    def run(self):
        if self.check_for_new_version():
           if sickbeard.AUTO_UPDATE:
            logger.log(u"New update found for SickBeard, starting auto-updater ...")
            updated = sickbeard.versionCheckScheduler.action.update()
            if updated:
                logger.log(u"Update was successfull, restarting SickBeard ...")
                sickbeard.restart(False)

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()

        # refresh network timezones
        network_timezones.update_network_dict()

        # sure, why not?
        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.trimHistory()
Exemplo n.º 23
0
    def run(self, force=False):
        self.amActive = True

        # clear internal name cache
        name_cache.clearCache()

        # get and update scene exceptions lists
        scene_exceptions.retrieve_exceptions()

        # build internal name cache for searches and parsing
        name_cache.buildNameCache()

        # refresh network timezones
        network_timezones.update_network_dict()

        # sure, why not?
        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.trimHistory()

        self.amActive = False
    def run(self):
        if self.check_for_new_version():
            if sickbeard.AUTO_UPDATE:
                logger.log(
                    u"New update found for SickBeard, starting auto-updater ..."
                )
                updated = sickbeard.versionCheckScheduler.action.update()
                if updated:
                    logger.log(
                        u"Update was successfull, restarting SickBeard ...")
                    sickbeard.restart(False)

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()

        # refresh network timezones
        network_timezones.update_network_dict()

        # sure, why not?
        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.trimHistory()
Exemplo n.º 25
0
    def run(self):
        updated = None
        if self.check_for_new_version():
            if sickbeard.AUTO_UPDATE:
                logger.log(u"New update found for SickRage, starting auto-updater ...")
                updated = sickbeard.versionCheckScheduler.action.update()
                if updated:
                    logger.log(u"Update was successfull, restarting SickRage ...")

                    # do a soft restart
                    threading.Timer(2, sickbeard.invoke_restart, [False]).start()

        if not updated:
            # refresh scene exceptions too
            scene_exceptions.retrieve_exceptions()

            # refresh network timezones
            network_timezones.update_network_dict()

            # sure, why not?
            if sickbeard.USE_FAILED_DOWNLOADS:
                failed_history.trimHistory()
Exemplo n.º 26
0
def buildNameCache(show=None):
    """Build internal name cache

    :param show: Specify show to build name cache for, if None, just do all shows
    """
    with nameCacheLock:
        retrieve_exceptions()

    if not show:
        # logger.log(u"Building internal name cache for all shows", logger.INFO)
        for show in sickbeard.showList:
            buildNameCache(show)
    else:
        # logger.log(u"Building internal name cache for " + show.name, logger.DEBUG)
        clearCache(show.indexerid)
        for curSeason in [-1] + get_scene_seasons(show.indexerid):
            for name in set(get_scene_exceptions(show.indexerid, season=curSeason) + [show.name]):
                name = full_sanitizeSceneName(name)
                if name in nameCache:
                    continue

                nameCache[name] = int(show.indexerid)
        logger.log(u"Internal name cache for " + show.name + " set to: [ " + u', '.join([key for key, value in iteritems(nameCache) if value == show.indexerid]) + " ]", logger.DEBUG)
Exemplo n.º 27
0
    def run(self):
        self.check_for_new_version()

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()
Exemplo n.º 28
0
        sickbeard.showList.append(self.show)

        try:
            self.show.loadEpisodesFromTVDB()
            self.show.setTVRID()

            self.show.writeMetadata()
            self.show.populateCache()

        except Exception, e:
            logger.log(u"Error with TVDB, not creating episode list: " + ex(e),
                       logger.ERROR)
            logger.log(traceback.format_exc(), logger.DEBUG)

        # before we parse local files lets update exceptions
        scene_exceptions.retrieve_exceptions()
        # and get scene numbers
        logger.log(u"Attempting to load scene numbers", logger.DEBUG)
        if self.show.loadEpisodeSceneNumbers():
            logger.log(u"loading scene numbers successfull", logger.DEBUG)
        else:
            logger.log(
                u"loading scene numbers NOT successfull or no scene numbers available",
                logger.DEBUG)

        try:
            self.show.loadEpisodesFromDir()
        except Exception, e:
            logger.log(u"Error searching dir for episodes: " + ex(e),
                       logger.ERROR)
            logger.log(traceback.format_exc(), logger.DEBUG)
Exemplo n.º 29
0
    def setUp(self):
        super(SceneExceptionTestCase, self).setUp()

        sickbeard.showList = [Show(1, 79604), Show(1, 251085)]
        scene_exceptions.retrieve_exceptions()
        name_cache.buildNameCache()
Exemplo n.º 30
0
 def setUp(self):
     """
     Set up tests
     """
     super(SceneExceptionTestCase, self).setUp()
     scene_exceptions.retrieve_exceptions()
Exemplo n.º 31
0
 def setUp(self):
     super(SceneExceptionTestCase, self).setUp()
     scene_exceptions.retrieve_exceptions()
Exemplo n.º 32
0
 def setUp(self):
     """
     Set up tests
     """
     super(SceneExceptionTestCase, self).setUp()
     scene_exceptions.retrieve_exceptions()
Exemplo n.º 33
0
    def run(self):
        self.check_for_new_version()

        # refresh scene exceptions too
        scene_exceptions.retrieve_exceptions()
Exemplo n.º 34
0
        self._test_allPossibleShowNames('Show Name (FCN)', -1, 'TVRage Name', expected=['Show Name (FCN)', 'Show Name (Full Country Name)', 'Exception Test', 'TVRage Name'])

    def test_filterBadReleases(self):
        
        self._test_filterBadReleases('Show.S02.German.Stuff-Grp', False)
        self._test_filterBadReleases('Show.S02.Some.Stuff-Core2HD', False)
        self._test_filterBadReleases('Show.S02.Some.German.Stuff-Grp', False)
        self._test_filterBadReleases('German.Show.S02.Some.Stuff-Grp', True)
        self._test_filterBadReleases('Show.S02.This.Is.German', False)




print 'Loading exceptions...',
db.upgradeDatabase(db.DBConnection("cache.db"), cache_db.InitialSchema)
scene_exceptions.retrieve_exceptions()
print 'done.'

class SceneExceptionTestCase(unittest.TestCase):

    def test_sceneExceptionsEmpty(self):
        self.assertEqual(scene_exceptions.get_scene_exceptions(0), [])

    def test_sceneExceptionsBabylon5(self):
        self.assertEqual(sorted(scene_exceptions.get_scene_exceptions(70726)), ['Babylon 5', 'Babylon5'])

    def test_sceneExceptionByName(self):
        self.assertEqual(scene_exceptions.get_scene_exception_by_name('Babylon5'), 70726)
        self.assertEqual(scene_exceptions.get_scene_exception_by_name('babylon 5'), 70726)
        self.assertEqual(scene_exceptions.get_scene_exception_by_name('Carlos 2010'), 164451)