Exemplo n.º 1
0
def all_possible_show_names(series_id, series_provider_id, season=-1):
    """
    Figures out every possible variation of the name for a particular show. Includes TVDB name, TVRage name,
    country codes on the end, eg. "Show Name (AU)", and any scene exception names.

    show: a TVShow object that we should get the names of

    Returns: a list of all the possible show names
    :rtype: list[unicode]
    """

    show = find_show(series_id, series_provider_id)

    show_names = show.get_scene_exceptions_by_season(season=season)[:]
    if not show_names:  # if we dont have any season specific exceptions fallback to generic exceptions
        season = -1
        show_names = show.get_scene_exceptions_by_season(season=season)[:]

    if season in [-1, 1]:
        show_names.append(show.name)

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

    if not show.is_anime:
        new_show_names = []
        country_list = countryList
        country_list.update(dict(zip(countryList.values(),
                                     countryList.keys())))
        for curName in set(show_names):
            if not curName:
                continue

            # if we have "Show Name Australia" or "Show Name (Australia)" this will add "Show Name (AU)" for
            # any countries defined in common.countryList
            # (and vice versa)
            for curCountry in country_list:
                if curName.endswith(' ' + curCountry):
                    new_show_names.append(
                        curName.replace(' ' + curCountry,
                                        ' (' + country_list[curCountry] + ')'))
                elif curName.endswith(' (' + curCountry + ')'):
                    new_show_names.append(
                        curName.replace(' (' + curCountry + ')',
                                        ' (' + country_list[curCountry] + ')'))

            # if we have "Show Name (2013)" this will strip the (2013) show year from the show name
            new_show_names.append(
                re.sub(r'\({}\)'.format(show.startyear), '', curName))

        show_names += new_show_names

    return list(set(show_names))
Exemplo n.º 2
0
def allPossibleShowNames(show, season=-1):
    """
    Figures out every possible variation of the name for a particular show. Includes TVDB name, TVRage name,
    country codes on the end, eg. "Show Name (AU)", and any scene exception names.

    show: a TVShow object that we should get the names of

    Returns: a list of all the possible show names
    :rtype: list[unicode]
    """

    show_names = get_scene_exceptions(show.indexerid, season=season)[:]
    if not show_names:  # if we dont have any season specific exceptions fallback to generic exceptions
        season = -1
        show_names = get_scene_exceptions(show.indexerid, season=season)[:]

    if season in [-1, 1]:
        show_names.append(show.name)

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

    if not show.is_anime:
        new_show_names = []
        country_list = countryList
        country_list.update(dict(zip(countryList.values(), countryList.keys())))
        for curName in set(show_names):
            if not curName:
                continue

            # if we have "Show Name Australia" or "Show Name (Australia)" this will add "Show Name (AU)" for
            # any countries defined in common.countryList
            # (and vice versa)
            for curCountry in country_list:
                if curName.endswith(' ' + curCountry):
                    new_show_names.append(curName.replace(' ' + curCountry, ' (' + country_list[curCountry] + ')'))
                elif curName.endswith(' (' + curCountry + ')'):
                    new_show_names.append(curName.replace(' (' + curCountry + ')', ' (' + country_list[curCountry] + ')'))

                    # # if we have "Show Name (2013)" this will strip the (2013) show year from the show name
                    # new_show_names.append(re.sub('\(\d{4}\)', '', curName))

        show_names += new_show_names

    return list(set(show_names))
Exemplo n.º 3
0
def allPossibleShowNames(show, season=-1):
    """
    Figures out every possible variation of the name for a particular show. Includes TVDB name, TVRage name,
    country codes on the end, eg. "Show Name (AU)", and any scene exception names.

    show: a TVShow object that we should get the names of

    Returns: a list of all the possible show names
    :rtype: list[unicode]
    """

    show_names = get_scene_exceptions(show.indexerid, season=season)[:]
    if not show_names:  # if we dont have any season specific exceptions fallback to generic exceptions
        season = -1
        show_names = get_scene_exceptions(show.indexerid, season=season)[:]

    if season in [-1, 1]:
        show_names.append(show.name)

    try:
        # strip accents
        try:
            show.name.decode('ascii')
        except UnicodeEncodeError:
            pass
        show_names.append(
            unicodedata.normalize('NFKD', show.name).encode('ASCII', 'ignore'))
        show_names.append(
            unicodedata.normalize('NFKD', show.name).encode('ASCII',
                                                            'ignore').replace(
                                                                "'", " "))
    except UnicodeDecodeError:
        pass

    if not show.is_anime:
        new_show_names = []
        country_list = countryList
        country_list.update(dict(zip(countryList.values(),
                                     countryList.keys())))
        for curName in set(show_names):
            if not curName:
                continue

            # if we have "Show Name Australia" or "Show Name (Australia)" this will add "Show Name (AU)" for
            # any countries defined in common.countryList
            # (and vice versa)
            for curCountry in country_list:
                if curName.endswith(' ' + curCountry):
                    new_show_names.append(
                        curName.replace(' ' + curCountry,
                                        ' (' + country_list[curCountry] + ')'))
                elif curName.endswith(' (' + curCountry + ')'):
                    new_show_names.append(
                        curName.replace(' (' + curCountry + ')',
                                        ' (' + country_list[curCountry] + ')'))

                    # # if we have "Show Name (2013)" this will strip the (2013) show year from the show name
                    # new_show_names.append(re.sub('\(\d{4}\)', '', curName))

        show_names += new_show_names

    return list(set(show_names))