Example #1
0
    def get_season_search_strings(self, ep_obj):
        search_params = []
        current_params = {"category": "Season"}

        # Search for entire seasons: no need to do special things for air by date or sports shows
        if ep_obj.show.air_by_date or ep_obj.show.sports:
            # Search for the year of the air by date show
            current_params["name"] = str(ep_obj.airdate).split("-")[0]
        else:
            # BTN uses the same format for both Anime and TV
            current_params["name"] = "Season " + str(ep_obj.scene_season)

        # search
        if ep_obj.show.indexer == 1:
            current_params["tvdb"] = ep_obj.show.indexerid
            search_params.append(current_params)
        else:
            name_exceptions = list(
                set(
                    scene_exceptions.get_scene_exceptions(
                        ep_obj.show.indexerid) + [ep_obj.show.name]))
            for name in name_exceptions:
                # Search by name if we don't have tvdb id
                current_params["series"] = sanitizeSceneName(name)
                search_params.append(current_params)

        return search_params
Example #2
0
 def test_scene_ex_babylon_5(self):
     """
     Test scene exceptions for Babylon 5
     """
     assert sorted(scene_exceptions.get_scene_exceptions(70726)) == [
         "Babylon 5", "Babylon5"
     ]
Example #3
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:
        # logger.info("Building internal name cache for all shows")
        for show in settings.showList:
            buildNameCache(show)
    else:
        # logger.debug("Building internal name cache for " + show.name)
        clearCache(show.indexerid)
        for curSeason in [-1] + scene_exceptions.get_scene_seasons(
                show.indexerid):
            for name in set(
                    scene_exceptions.get_scene_exceptions(
                        show.indexerid, season=curSeason) + [show.name]):
                name = helpers.full_sanitizeSceneName(name)
                if name in nameCache:
                    continue

                nameCache[name] = int(show.indexerid)
Example #4
0
    def get_episode_search_strings(self, ep_obj, add_string=""):

        if not ep_obj:
            return [{}]

        to_return = []
        search_params = {"category": "Episode"}

        # episode
        if ep_obj.show.air_by_date or ep_obj.show.sports:
            date_str = str(ep_obj.airdate)

            # BTN uses dots in dates, we just search for the date since that
            # combined with the series identifier should result in just one episode
            search_params["name"] = date_str.replace("-", ".")
        else:
            # BTN uses the same format for both Anime and TV
            # Do a general name search for the episode, formatted like SXXEYY
            search_params["name"] = "{ep}".format(
                ep=episode_num(ep_obj.scene_season, ep_obj.scene_episode))

        # search
        if ep_obj.show.indexer == 1:
            search_params["tvdb"] = ep_obj.show.indexerid
            to_return.append(search_params)
        else:
            # add new query string for every exception
            name_exceptions = list(
                set(
                    scene_exceptions.get_scene_exceptions(
                        ep_obj.show.indexerid) + [ep_obj.show.name]))
            for cur_exception in name_exceptions:
                search_params["series"] = sanitizeSceneName(cur_exception)
                to_return.append(search_params)

        return to_return
Example #5
0
 def test_scene_ex_empty(self):
     """
     Test empty scene exception
     """
     assert scene_exceptions.get_scene_exceptions(0) == []
Example #6
0
 def test_scene_ex_babylon_5(self):
     """
     Test scene exceptions for Babylon 5
     """
     self.assertEqual(sorted(scene_exceptions.get_scene_exceptions(70726)),
                      ['Babylon 5', 'Babylon5'])
Example #7
0
 def test_scene_ex_empty(self):
     """
     Test empty scene exception
     """
     self.assertEqual(scene_exceptions.get_scene_exceptions(0), [])