示例#1
0
def get_scene_exception_by_name_multiple(show_name):
    """
    Given a show name, return the indexerid of the exception, None if no exception
    is present.
    """

    # try the obvious case first
    exception_result = cache_db.CacheDB().select(
            "SELECT indexer_id, season FROM scene_exceptions WHERE LOWER(show_name) = ? ORDER BY season ASC",
            [show_name.lower()])
    if exception_result:
        return [(int(x[b"indexer_id"]), int(x[b"season"])) for x in exception_result]

    out = []
    all_exception_results = cache_db.CacheDB().select("SELECT show_name, indexer_id, season FROM scene_exceptions")

    for cur_exception in all_exception_results:

        cur_exception_name = cur_exception[b"show_name"]
        cur_indexer_id = int(cur_exception[b"indexer_id"])
        cur_season = int(cur_exception[b"season"])

        if show_name.lower() in (
                cur_exception_name.lower(),
                sanitizeSceneName(cur_exception_name).lower().replace('.', ' ')):
            sickrage.srLogger.debug("Scene exception lookup got indexer id " + str(cur_indexer_id) + ", using that")
            out.append((cur_indexer_id, cur_season))

    if out:
        return out

    return [(None, None)]
示例#2
0
文件: btn.py 项目: ipmcc/SiCKRAGE
    def _get_episode_search_strings(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[b'name'] = date_str.replace('-', '.')
        elif ep_obj.show.anime:
            search_params[b'name'] = "%i" % int(ep_obj.scene_absolute_number)
        else:
            # Do a general name search for the episode, formatted like SXXEYY
            search_params[b'name'] = "S%02dE%02d" % (ep_obj.scene_season, ep_obj.scene_episode)

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

        return to_return
示例#3
0
    def _get_episode_search_strings(self, ep_obj, add_string=''):

        search_string = {'Episode': []}

        if not ep_obj:
            return []

        for show_name in set(show_names.allPossibleShowNames(self.show)):
            for sep in ' ', ' - ':
                ep_string = sanitizeSceneName(show_name) + sep
                if self.show.air_by_date:
                    ep_string += str(ep_obj.airdate).replace('-', '|')
                elif self.show.sports:
                    ep_string += str(ep_obj.airdate).replace('-', '|') + '|' + ep_obj.airdate.strftime('%b')
                elif self.show.anime:
                    ep_string += '%i' % int(ep_obj.scene_absolute_number)
                else:
                    ep_string += sickrage.srConfig.NAMING_EP_TYPE[2] % {'seasonnumber': ep_obj.scene_season,
                                                                       'episodenumber': ep_obj.scene_episode}

                if add_string:
                    ep_string += ' %s' % add_string

                search_string['Episode'].append(re.sub(r'\s+', ' ', ep_string.replace('.', ' ').strip()))

        return [search_string]
示例#4
0
文件: btn.py 项目: ipmcc/SiCKRAGE
    def _get_season_search_strings(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[b'name'] = str(ep_obj.airdate).split('-')[0]
        elif ep_obj.show.is_anime:
            current_params[b'name'] = "%d" % ep_obj.scene_absolute_number
        else:
            current_params[b'name'] = 'Season ' + str(ep_obj.scene_season)

        # search
        if ep_obj.show.indexer == 1:
            current_params[b'tvdb'] = ep_obj.show.indexerid
            search_params.append(current_params)
        else:
            name_exceptions = list(
                    set(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[b'series'] = sanitizeSceneName(name)
                search_params.append(current_params)

        return search_params
示例#5
0
    def _get_episode_search_strings(self, ep_obj, add_string=""):
        to_return = []
        params = {}
        if not ep_obj:
            return to_return

        params[b"maxage"] = (datetime.now() - datetime.combine(ep_obj.airdate, datetime.min.time())).days + 1
        params[b"tvdbid"] = ep_obj.show.indexerid

        if ep_obj.show.air_by_date or ep_obj.show.sports:
            date_str = str(ep_obj.airdate)
            params[b"season"] = date_str.partition("-")[0]
            params[b"ep"] = date_str.partition("-")[2].replace("-", "/")
        else:
            params[b"season"] = ep_obj.scene_season
            params[b"ep"] = ep_obj.scene_episode

        # add new query strings for exceptions
        name_exceptions = list(set([ep_obj.show.name] + get_scene_exceptions(ep_obj.show.indexerid)))
        for cur_exception in name_exceptions:
            params[b"q"] = sanitizeSceneName(cur_exception)
            if add_string:
                params[b"q"] += " " + add_string

            to_return.append(dict(params))

        return to_return
示例#6
0
    def _get_season_search_strings(self, ep_obj):

        to_return = []
        params = {}
        if not ep_obj:
            return to_return

        params[b"maxage"] = (datetime.now() - datetime.combine(ep_obj.airdate, datetime.min.time())).days + 1
        params[b"tvdbid"] = ep_obj.show.indexerid

        # season
        if ep_obj.show.air_by_date or ep_obj.show.sports:
            date_str = str(ep_obj.airdate).split("-")[0]
            params[b"season"] = date_str
            params[b"q"] = date_str.replace("-", ".")
        else:
            params[b"season"] = str(ep_obj.scene_season)

        save_q = " " + params[b"q"] if "q" in params else ""

        # add new query strings for exceptions
        name_exceptions = list(set([ep_obj.show.name] + get_scene_exceptions(ep_obj.show.indexerid)))
        for cur_exception in name_exceptions:
            params[b"q"] = sanitizeSceneName(cur_exception) + save_q
            to_return.append(dict(params))

        return to_return
示例#7
0
    def _get_episode_search_strings(self, ep_obj, add_string=''):

        search_string = {'Episode': []}

        if not ep_obj:
            return []

        for show_name in set(show_names.allPossibleShowNames(self.show)):
            for sep in ' ', ' - ':
                ep_string = sanitizeSceneName(show_name) + sep
                if self.show.air_by_date:
                    ep_string += str(ep_obj.airdate).replace('-', '|')
                elif self.show.sports:
                    ep_string += str(ep_obj.airdate).replace(
                        '-', '|') + '|' + ep_obj.airdate.strftime('%b')
                elif self.show.anime:
                    ep_string += '%i' % int(ep_obj.scene_absolute_number)
                else:
                    ep_string += sickrage.srConfig.NAMING_EP_TYPE[2] % {
                        'seasonnumber': ep_obj.scene_season,
                        'episodenumber': ep_obj.scene_episode
                    }

                if add_string:
                    ep_string += ' %s' % add_string

                search_string['Episode'].append(
                    re.sub(r'\s+', ' ',
                           ep_string.replace('.', ' ').strip()))

        return [search_string]
示例#8
0
文件: btn.py 项目: tioxxx/SiCKRAGE-1
    def _get_season_search_strings(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[b'name'] = str(ep_obj.airdate).split('-')[0]
        elif ep_obj.show.is_anime:
            current_params[b'name'] = "%d" % ep_obj.scene_absolute_number
        else:
            current_params[b'name'] = 'Season ' + str(ep_obj.scene_season)

        # search
        if ep_obj.show.indexer == 1:
            current_params[b'tvdb'] = ep_obj.show.indexerid
            search_params.append(current_params)
        else:
            name_exceptions = list(
                set(
                    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[b'series'] = sanitizeSceneName(name)
                search_params.append(current_params)

        return search_params
示例#9
0
文件: btn.py 项目: tioxxx/SiCKRAGE-1
    def _get_episode_search_strings(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[b'name'] = date_str.replace('-', '.')
        elif ep_obj.show.anime:
            search_params[b'name'] = "%i" % int(ep_obj.scene_absolute_number)
        else:
            # Do a general name search for the episode, formatted like SXXEYY
            search_params[b'name'] = "S%02dE%02d" % (ep_obj.scene_season,
                                                     ep_obj.scene_episode)

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

        return to_return
示例#10
0
def get_scene_exception_by_name_multiple(show_name):
    """
    Given a show name, return the indexerid of the exception, None if no exception
    is present.
    """

    # try the obvious case first
    exception_result = cache_db.CacheDB().select(
        "SELECT indexer_id, season FROM scene_exceptions WHERE LOWER(show_name) = ? ORDER BY season ASC",
        [show_name.lower()])
    if exception_result:
        return [(int(x[b"indexer_id"]), int(x[b"season"]))
                for x in exception_result]

    out = []
    all_exception_results = cache_db.CacheDB().select(
        "SELECT show_name, indexer_id, season FROM scene_exceptions")

    for cur_exception in all_exception_results:

        cur_exception_name = cur_exception[b"show_name"]
        cur_indexer_id = int(cur_exception[b"indexer_id"])
        cur_season = int(cur_exception[b"season"])

        if show_name.lower() in (
                cur_exception_name.lower(),
                sanitizeSceneName(cur_exception_name).lower().replace(
                    '.', ' ')):
            sickrage.srLogger.debug("Scene exception lookup got indexer id " +
                                    str(cur_indexer_id) + ", using that")
            out.append((cur_indexer_id, cur_season))

    if out:
        return out

    return [(None, None)]