コード例 #1
0
    def load_shows(self):
        threading.currentThread().setName('CORE')

        session = self.main_db.session()

        self.log.info('Loading initial shows list')

        self.loading_shows = True

        self.shows = {}
        for query in session.query(MainDB.TVShow).with_entities(
                MainDB.TVShow.series_id, MainDB.TVShow.series_provider_id,
                MainDB.TVShow.name, MainDB.TVShow.location):
            try:
                # if not os.path.isdir(query.location) and self.config.general.create_missing_show_dirs:
                #     make_dir(query.location)

                self.log.info('Loading show {}'.format(query.name))
                self.shows.update({
                    (query.series_id, query.series_provider_id):
                    TVShow(query.series_id, query.series_provider_id)
                })
            except Exception as e:
                self.log.debug('There was an error loading show: {}'.format(
                    query.name))

        self.loading_shows = False

        self.log.info('Loading initial shows list finished')
コード例 #2
0
ファイル: __init__.py プロジェクト: Entro-pie/SiCKRAGE
    def load_shows(self):
        threading.currentThread().setName('CORE')

        session = self.main_db.session()

        self.log.info('Loading initial shows list')

        self.loading_shows = True

        self.shows = {}
        for query in session.query(MainDB.TVShow).with_entities(
                MainDB.TVShow.indexer_id, MainDB.TVShow.indexer,
                MainDB.TVShow.name):
            try:
                self.log.info('Loading show {} and building caches'.format(
                    query.name))
                self.shows.update({
                    (query.indexer_id, query.indexer):
                    TVShow(query.indexer_id, query.indexer)
                })
                self.quicksearch_cache.add_show(query.indexer_id)
            except Exception as e:
                self.log.debug('There was an error loading show: {}'.format(
                    query.name))

        self.loading_shows = False

        self.log.info('Loading initial shows list finished')
コード例 #3
0
    def _test_allPossibleShowNames(self, name, indexerid=0, expected=[]):
        s = TVShow(1, indexerid)
        s.name = name

        result = show_names.allPossibleShowNames(s)
        self.assertTrue(
            len(set(expected).intersection(set(result))) == len(expected))
コード例 #4
0
        def setUp(self):
            super(ProviderTests.ProviderTest, self).setUp()
            self.show = TVShow(
                1,
                test_string_overrides.get(self.provider.name,
                                          {'ID': 82066})['ID'], "en")
            self.show.name = test_string_overrides.get(
                self.provider.name, {'Name': 'Fringe'})['Name']
            self.show.anime = test_string_overrides.get(
                self.provider.name, {'Anime': False})['Anime']

            self.ep = TVEpisode(
                self.show,
                test_string_overrides.get(self.provider.name,
                                          {'Season': 1})['Season'],
                test_string_overrides.get(self.provider.name,
                                          {'Episode': 1})['Episode'])
            self.ep.absolute_number = test_string_overrides.get(
                self.provider.name, {'ABS': 0})['ABS']
            self.ep.scene_season = self.ep.season
            self.ep.scene_episode = self.ep.episode
            self.ep.scene_absolute_number = self.ep.absolute_number

            self.provider.username = self.username
            self.provider.password = self.password
コード例 #5
0
 def __init__(self, something):
     super(UnicodeTests, self).__init__(something)
     self.setUp()
     self.show = TVShow(1, 1, 'en')
     self.show.name = "The Big Bang Theory"
     self.show.saveToDB()
     self.show.loadFromDB(skipNFO=True)
コード例 #6
0
ファイル: test_pp.py プロジェクト: newrain7803/SiCKRAGE
    def test_process(self):
        show = TVShow(3, 1)
        show.name = self.SHOWNAME
        show.location = self.SHOWDIR
        sickrage.app.showlist = [show]

        self.post_processor = PostProcessor(self.FILEPATH, process_method='move')
        self.post_processor._log = _log
        self.assertTrue(self.post_processor.process)
コード例 #7
0
    def _test_allPossibleShowNames(self, name, indexerid=0, expected=[]):
        s = TVShow(1, indexerid)
        s.name = name
        s.saveToDB()
        s.loadFromDB(skipNFO=True)

        result = show_names.allPossibleShowNames(s)
        self.assertTrue(
            len(set(expected).intersection(set(result))) == len(expected))
コード例 #8
0
    def _test_allPossibleShowNames(self, name, indexer_id=0, expected=None):
        if expected is None:
            expected = []

        s = TVShow(indexer_id, 1)
        s.name = name

        result = show_names.all_possible_show_names(s)
        self.assertTrue(
            len(set(expected).intersection(set(result))) == len(expected))
コード例 #9
0
 def test_getEpisode(self):
     show = TVShow(0o001, 1)
     show.name = "show name"
     show.network = "cbs"
     show.genre = "crime"
     show.runtime = 40
     show.status = "Ended"
     show.default_ep_status = "5"
     show.airs = "monday"
     show.startyear = 1987
     sickrage.app.showlist = [show]
コード例 #10
0
    def get_show(self, name):
        show = None
        show_id = None
        show_names = [name]

        if not all([name, sickrage.app.showlist]):
            return show, show_id

        def cache_lookup(term):
            return sickrage.app.name_cache.get(term)

        def scene_exception_lookup(term):
            return get_scene_exception_by_name(term)[0]

        def indexer_lookup(term):
            show_id1 = int(IndexerApi().searchForShowID(
                full_sanitizeSceneName(term))[2])
            show_id2 = int(srTraktAPI()['search'].query(
                full_sanitizeSceneName(term), 'show')[0].ids['tvdb'])
            return (None, show_id1)[show_id1 == show_id2]

        show_names.append(strip_accents(name))
        show_names.append(strip_accents(name).replace("'", " "))

        for show_name in set(show_names):
            lookup_list = [
                lambda: cache_lookup(show_name),
                lambda: scene_exception_lookup(show_name),
                lambda: indexer_lookup(show_name),
            ]

            # lookup show id
            for lookup in lookup_list:
                try:
                    show_id = int(lookup())
                    if show_id == 0:
                        continue

                    sickrage.app.name_cache.put(show_name, show_id)

                    if not show:
                        if self.validate_show:
                            show = findCertainShow(show_id)
                        else:
                            from sickrage.core.tv.show import TVShow
                            show = TVShow(1, show_id)
                except Exception:
                    pass

            if show_id is None:
                # ignore show name by caching it with a indexerid of 0
                sickrage.app.name_cache.put(show_name, 0)

        return show, show_id or 0
コード例 #11
0
    def _test_allPossibleShowNames(self, name, indexerid=0, expected=None):
        if expected is None:
            expected = []

        s = TVShow(1, indexerid)
        s.name = name
        s.save_to_db()

        result = show_names.allPossibleShowNames(s)
        self.assertTrue(
            len(set(expected).intersection(set(result))) == len(expected))
コード例 #12
0
ファイル: test_pp.py プロジェクト: robrossuk/SiCKRAGE
    def test_process(self):
        show = TVShow(1, 3)
        show.name = self.SHOWNAME
        show.location = self.SHOWDIR
        show.save_to_db()
        sickrage.app.showlist = [show]

        sickrage.app.name_cache.put('show name', 3)
        self.post_processor = PostProcessor(self.FILEPATH, process_method='move')
        self.post_processor._log = _log
        self.assertTrue(self.post_processor.process)
コード例 #13
0
    def get_show(self, name):
        show = None
        show_id = None
        show_names = [name]

        if not all([name, sickrage.app.showlist]):
            return show, show_id

        def cache_lookup(term):
            return sickrage.app.name_cache.get(term)

        def scene_exception_lookup(term):
            return get_scene_exception_by_name(term)[0]

        def showlist_lookup(term):
            try:
                return search_showlist_by_name(term).indexerid
            except MultipleShowObjectsException:
                return None

        show_names.append(strip_accents(name))
        show_names.append(strip_accents(name).replace("'", " "))

        for show_name in set(show_names):
            lookup_list = [
                lambda: cache_lookup(show_name),
                lambda: scene_exception_lookup(show_name),
                lambda: showlist_lookup(show_name),
            ]

            # lookup show id
            for lookup in lookup_list:
                try:
                    show_id = int(lookup())
                    if show_id == 0:
                        continue

                    sickrage.app.name_cache.put(show_name, show_id)

                    if not show:
                        if self.validate_show:
                            show = findCertainShow(show_id)
                        else:
                            from sickrage.core.tv.show import TVShow
                            show = TVShow(1, show_id)
                except Exception:
                    pass

            if show_id is None:
                # ignore show name by caching it with a indexerid of 0
                sickrage.app.name_cache.put(show_name, 0)

        return show, show_id or 0
コード例 #14
0
ファイル: test_pp.py プロジェクト: newrain7803/SiCKRAGE
    def test_process(self):
        show = TVShow(3, 1)
        show.name = self.SHOWNAME
        show.location = self.SHOWDIR
        sickrage.app.showlist = [show]
        ep = TVEpisode(show, self.SEASON, self.EPISODE)
        ep.name = "some ep name"
        ep.save()

        self.post_processor = PostProcessor(self.FILEPATH, process_method='move')
        self.post_processor._log = _log
        self.assertTrue(self.post_processor.process)
コード例 #15
0
 def test_change_indexer_id(self):
     show = TVShow(0o001, 1)
     show.name = "show name"
     show.network = "cbs"
     show.genre = "crime"
     show.runtime = 40
     show.status = "Ended"
     show.default_ep_status = "5"
     show.airs = "monday"
     show.startyear = 1987
     show.indexer_id = 0o002
     self.assertEqual(show.indexer_id, 0o002)
コード例 #16
0
ファイル: __init__.py プロジェクト: sshyran/SiCKRAGE
    def load_shows(self):
        """
        Populates the showlist with shows from the database
        """

        for dbData in [x['doc'] for x in self.main_db.db.all('tv_shows', with_doc=True)]:
            try:
                self.log.debug("Loading data for show: [{}]".format(dbData['show_name']))
                show = TVShow(int(dbData['indexer']), int(dbData['indexer_id']))
                show.nextEpisode()
                self.showlist += [show]
            except Exception as e:
                self.log.error("Show error in [%s]: %s" % (dbData['location'], e.message))
コード例 #17
0
    def test_process(self):
        show = TVShow(1, 3)
        show.name = self.SHOWNAME
        show.location = self.SHOWDIR
        show.saveToDB()
        sickrage.app.showlist = [show]
        ep = TVEpisode(show, self.SEASON, self.EPISODE)
        ep.name = "some ep name"
        ep.saveToDB()

        sickrage.app.name_cache.put('show name', 3)
        self.pp = PostProcessor(self.FILEPATH, process_method='move')
        self.assertTrue(self.pp.process)
コード例 #18
0
    def loadFromDB(self):
        """
        Populates the showList with shows from the database
        """

        for s in [s['doc'] for s in MainDB().db.all('tv_shows', with_doc=True)]:
            try:
                curShow = TVShow(int(s["indexer"]), int(s["indexer_id"]))
                curShow.saveToDB()
                curShow.loadFromDB(skipNFO=True)
                sickrage.srCore.SHOWLIST.append(curShow)
            except Exception as e:
                print "There was an error creating the show"
コード例 #19
0
ファイル: __init__.py プロジェクト: alexanderbsh/SiCKRAGE
    def load_shows(self):
        """
        Populates the showlist with shows from the database
        """

        for dbData in [x['doc'] for x in self.mainDB.db.all('tv_shows', with_doc=True)]:
            try:
                self.srLogger.debug("Loading data for show: [%s]", dbData['show_name'])
                show = TVShow(int(dbData['indexer']), int(dbData['indexer_id']))
                show.nextEpisode()
                self.NAMECACHE.build(show)
                self.SHOWLIST += [show]
            except Exception as e:
                self.srLogger.error("Show error in [%s]: %s" % (dbData['location'], e.message))
コード例 #20
0
ファイル: __init__.py プロジェクト: jas31085/SiCKRAGE
    def load_shows(self):
        """
        Populates the showlist and quicksearch cache with shows and episodes from the database
        """

        self.quicksearch_cache.load()

        for dbData in self.main_db.all('tv_shows'):
            try:
                self.log.debug("Loading data for show: [{}]".format(dbData['show_name']))
                self.showlist.append(TVShow(int(dbData['indexer']), int(dbData['indexer_id'])))
                self.quicksearch_cache.add_show(dbData['indexer_id'])
            except Exception as e:
                self.log.debug("Show error in [%s]: %s" % (dbData['location'], str(e)))
コード例 #21
0
ファイル: test_xem.py プロジェクト: becian/SickRage-1
    def loadFromDB(self):
        """
        Populates the showList with shows from the database
        """

        sqlResults = main_db.MainDB().select("SELECT * FROM tv_shows")

        for sqlShow in sqlResults:
            try:
                curShow = TVShow(int(sqlShow[b"indexer"]),
                                 int(sqlShow[b"indexer_id"]))
                sickrage.showList.append(curShow)
            except Exception as e:
                print "There was an error creating the show"
コード例 #22
0
ファイル: test_pp.py プロジェクト: Jusedawg/SiCKRAGETV
    def test_process(self):
        show = TVShow(1, 3)
        show.name = SHOWNAME
        show.location = SHOWDIR
        show.saveToDB()
        show.loadFromDB(skipNFO=True)
        sickrage.srCore.SHOWLIST = [show]
        ep = TVEpisode(show, SEASON, EPISODE)
        ep.name = "some ep name"
        ep.saveToDB()

        sickrage.srCore.NAMECACHE.addNameToCache('show name', 3)
        self.pp = PostProcessor(FILEPATH, process_method='move')
        self.assertTrue(self.pp.process)
コード例 #23
0
ファイル: test_db.py プロジェクト: ChrisJamesHobbs/SiCKRAGE
    def setUp(self, session=None):
        super(DBBasicTests, self).setUp()
        show = TVShow(**{'indexer': 1, 'indexer_id': 0o0001, 'lang': 'en'})
        session.add(show)
        session.safe_commit()

        ep = TVEpisode(
            **{
                'showid': show.indexer_id,
                'indexer': 1,
                'season': 1,
                'episode': 1,
                'location': ''
            })
        session.add(ep)
        ep.indexer_id = 1
        ep.name = "test episode 1"
        ep.airdate = datetime.date.fromordinal(733832)
        ep.status = UNAIRED
        session.safe_commit()

        ep = TVEpisode(
            **{
                'showid': show.indexer_id,
                'indexer': 1,
                'season': 1,
                'episode': 2,
                'location': ''
            })
        session.add(ep)
        ep.indexer_id = 2
        ep.name = "test episode 2"
        ep.airdate = datetime.date.fromordinal(733832)
        ep.status = UNAIRED
        session.safe_commit()

        ep = TVEpisode(
            **{
                'showid': show.indexer_id,
                'indexer': 1,
                'season': 1,
                'episode': 3,
                'location': ''
            })
        session.add(ep)
        ep.indexer_id = 3
        ep.name = "test episode 3"
        ep.airdate = datetime.date.fromordinal(733832)
        ep.status = UNAIRED
        session.safe_commit()
コード例 #24
0
ファイル: __init__.py プロジェクト: Creone33/SiCKRAGE
    def load_shows(self):
        """
        Populates the showlist with shows from the database
        """

        for dbData in self.main_db.all('tv_shows'):
            try:
                self.log.debug("Loading data for show: [{}]".format(
                    dbData['show_name']))
                self.showlist += [
                    TVShow(int(dbData['indexer']), int(dbData['indexer_id']))
                ]
            except Exception as e:
                self.log.error("Show error in [%s]: %s" %
                               (dbData['location'], e.message))
コード例 #25
0
    def test_isGoodName(self):
        list_of_cases = [('Show.Name.S01E02.Test-Test', 'Show/Name'),
                         ('Show.Name.S01E02.Test-Test', 'Show. Name'),
                         ('Show.Name.S01E02.Test-Test', 'Show- Name'),
                         ('Show.Name.Part.IV.Test-Test', 'Show Name'),
                         ('Show.Name.S01.Test-Test', 'Show Name'),
                         ('Show.Name.E02.Test-Test', 'Show: Name'),
                         ('Show Name Season 2 Test', 'Show: Name')]

        for testCase in list_of_cases:
            scene_name, show_name = testCase
            s = TVShow(1, 0)
            s.name = show_name
            s.saveToDB()
            self._test_isGoodName(scene_name, s)
コード例 #26
0
ファイル: test_xem.py プロジェクト: Jusedawg/SiCKRAGETV
    def loadShowsFromDB(self):
        """
        Populates the showList with shows from the database
        """

        sqlResults = main_db.MainDB().select("SELECT * FROM tv_shows")

        for sqlShow in sqlResults:
            try:
                curShow = TVShow(int(sqlShow["indexer"]),
                                 int(sqlShow["indexer_id"]))
                curShow.saveToDB()
                curShow.loadFromDB(skipNFO=True)
                sickrage.srCore.SHOWLIST.append(curShow)
            except Exception:
                pass
コード例 #27
0
    def load_shows(self):
        """
        Populates the showlist with shows from the database
        """

        for sqlShow in main_db.MainDB().select("SELECT * FROM tv_shows"):
            try:
                curshow = TVShow(int(sqlShow["indexer"]),
                                 int(sqlShow["indexer_id"]))
                self.srLogger.debug("Loading data for show: [{}]".format(
                    curshow.name))
                curshow.nextEpisode()
                self.SHOWLIST += [curshow]
            except Exception as e:
                self.srLogger.error("Show error in [{}]: {}".format(
                    sqlShow["location"], e.message))
コード例 #28
0
ファイル: test_xem.py プロジェクト: mfreshmen/SiCKRAGE-1
    def loadShowsFromDB(self):
        """
        Populates the showList with shows from the database
        """

        for s in [
                s['doc']
                for s in sickrage.app.main_db.db.all('tv_shows', with_doc=True)
        ]:
            try:
                curShow = TVShow(int(s["indexer"]), int(s["indexer_id"]))
                curShow.saveToDB()
                curShow.loadFromDB(skipNFO=True)
                sickrage.app.showlist.append(curShow)
            except Exception:
                pass
コード例 #29
0
    def test_isGoodName(self):
        listOfcases = [('Show.Name.S01E02.Test-Test', 'Show/Name'),
                       ('Show.Name.S01E02.Test-Test', 'Show. Name'),
                       ('Show.Name.S01E02.Test-Test', 'Show- Name'),
                       ('Show.Name.Part.IV.Test-Test', 'Show Name'),
                       ('Show.Name.S01.Test-Test', 'Show Name'),
                       ('Show.Name.E02.Test-Test', 'Show: Name'),
                       ('Show Name Season 2 Test', 'Show: Name'),
                       ]

        for testCase in listOfcases:
            scene_name, show_name = testCase
            s = TVShow(1, 0)
            s.name = show_name
            s.saveToDB()
            s.loadFromDB(skipNFO=True)
            self._test_isGoodName(scene_name, s)
            del s
コード例 #30
0
    def test(self):
        global searchItems
        searchItems = curData["i"]
        show = TVShow(1, tvdbdid)
        show.name = show_name
        show.quality = curData["q"]
        show.saveToDB()
        show.loadFromDB(skipNFO=True)
        sickrage.srCore.SHOWLIST.append(show)
        episode = None

        for epNumber in curData["e"]:
            episode = TVEpisode(show, curData["s"], epNumber)
            episode.status = WANTED
            episode.saveToDB()

        bestResult = searchProviders(show, episode.episode, forceSearch)
        if not bestResult:
            self.assertEqual(curData["b"], bestResult)
        self.assertEqual(curData["b"], bestResult.name)  # first is expected, second is choosen one