当前位置: 首页>>代码示例>>Python>>正文


Python show_name_helpers.sceneToNormalShowNames函数代码示例

本文整理汇总了Python中sickbeard.show_name_helpers.sceneToNormalShowNames函数的典型用法代码示例。如果您正苦于以下问题:Python sceneToNormalShowNames函数的具体用法?Python sceneToNormalShowNames怎么用?Python sceneToNormalShowNames使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sceneToNormalShowNames函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _test_sceneToNormalShowNames

    def _test_sceneToNormalShowNames(self, name, expected):
        result = show_name_helpers.sceneToNormalShowNames(name)
        self.assertTrue(len(set(expected).intersection(set(result))) == len(expected))

        dot_result = show_name_helpers.sceneToNormalShowNames(name.replace(' ', '.'))
        dot_expected = [x.replace(' ', '.') for x in expected]
        self.assertTrue(len(set(dot_expected).intersection(set(dot_result))) == len(dot_expected))
开发者ID:3ne,项目名称:SickRage,代码行数:7,代码来源:scene_helpers_tests.py

示例2: _test_scene_to_norm_show_name

    def _test_scene_to_norm_show_name(self, name, expected):
        """
        Test scene to normal show names

        :param name:
        :param expected:
        :return:
        """
        result = show_name_helpers.sceneToNormalShowNames(name)
        self.assertTrue(len(set(expected).intersection(set(result))) == len(expected))

        dot_result = show_name_helpers.sceneToNormalShowNames(name.replace(' ', '.'))
        dot_expected = [x.replace(' ', '.') for x in expected]
        self.assertTrue(len(set(dot_expected).intersection(set(dot_result))) == len(dot_expected))
开发者ID:feld,项目名称:SickRage,代码行数:14,代码来源:scene_helpers_tests.py

示例3: _get_show_id

    def _get_show_id(self, series_name):
        """Find and return show ID by searching exceptions, then DB"""

        show_names = show_name_helpers.sceneToNormalShowNames(series_name)

        logger.log(u"show_names: " + str(show_names), logger.DEBUG)

        for show_name in show_names:
            exception = scene_exceptions.get_scene_exception_by_name(show_name)
            if exception is not None:
                return exception

        for show_name in show_names:
            found_info = helpers.searchDBForShow(show_name)
            if found_info is not None:
                return(found_info[1])

        return None
开发者ID:albcool,项目名称:SickBeard-TVRage,代码行数:18,代码来源:failedProcessor.py

示例4: _analyze_name

    def _analyze_name(self, name, file=True):
        """
        Takes a name and tries to figure out a show, season, and episode from it.
        
        name: A string which we want to analyze to determine show info from (unicode)
        
        Returns a (tvdb_id, season, [episodes]) tuple. The first two may be None and episodes may be []
        if none were found.
        """

        logger.log(u"Analyzing name "+repr(name))
    
        to_return = (None, None, [])
    
        if not name:
            return to_return
    
        # parse the name to break it into show name, season, and episode
        np = NameParser(file)
        parse_result = np.parse(name)
        self._log("Parsed "+name+" into "+str(parse_result).decode('utf-8'), logger.DEBUG)

        if parse_result.air_by_date:
            season = -1
            episodes = [parse_result.air_date]
        else:
            season = parse_result.season_number
            episodes = parse_result.episode_numbers 

        to_return = (None, season, episodes)
    
        # do a scene reverse-lookup to get a list of all possible names
        name_list = show_name_helpers.sceneToNormalShowNames(parse_result.series_name)

        if not name_list:
            return (None, season, episodes)
        
        def _finalize(parse_result):
            self.release_group = parse_result.release_group
            
            # remember whether it's a proper
            if parse_result.extra_info:
                self.is_proper = re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', parse_result.extra_info, re.I) != None
            
            # if the result is complete then remember that for later
            if parse_result.series_name and parse_result.season_number != None and parse_result.episode_numbers and parse_result.release_group:
                test_name = os.path.basename(name)
                if test_name == self.nzb_name:
                    self.good_results[self.NZB_NAME] = True
                elif test_name == self.folder_name:
                    self.good_results[self.FOLDER_NAME] = True
                elif test_name == self.file_name:
                    self.good_results[self.FILE_NAME] = True
                else:
                    logger.log(u"Nothing was good, found "+repr(test_name)+" and wanted either "+repr(self.nzb_name)+", "+repr(self.folder_name)+", or "+repr(self.file_name))
            else:
                logger.log("Parse result not suficent(all folowing have to be set). will not save release name", logger.DEBUG)
                logger.log("Parse result(series_name): " + str(parse_result.series_name), logger.DEBUG)
                logger.log("Parse result(season_number): " + str(parse_result.season_number), logger.DEBUG)
                logger.log("Parse result(episode_numbers): " + str(parse_result.episode_numbers), logger.DEBUG)
                logger.log("Parse result(release_group): " + str(parse_result.release_group), logger.DEBUG)
                
        # for each possible interpretation of that scene name
        for cur_name in name_list:
            self._log(u"Checking scene exceptions for a match on "+cur_name, logger.DEBUG)
            scene_id = scene_exceptions.get_scene_exception_by_name(cur_name)
            if scene_id:
                self._log(u"Scene exception lookup got tvdb id "+str(scene_id)+u", using that", logger.DEBUG)
                _finalize(parse_result)
                return (scene_id, season, episodes)

        # see if we can find the name directly in the DB, if so use it
        for cur_name in name_list:
            self._log(u"Looking up "+cur_name+u" in the DB", logger.DEBUG)
            db_result = helpers.searchDBForShow(cur_name)
            if db_result:
                self._log(u"Lookup successful, using tvdb id "+str(db_result[0]), logger.DEBUG)
                _finalize(parse_result)
                return (int(db_result[0]), season, episodes)
        
        # see if we can find the name with a TVDB lookup
        for cur_name in name_list:
            try:
                t = tvdb_api.Tvdb(custom_ui=classes.ShowListUI, **sickbeard.TVDB_API_PARMS)
    
                self._log(u"Looking up name "+cur_name+u" on TVDB", logger.DEBUG)
                showObj = t[cur_name]
            except (tvdb_exceptions.tvdb_exception):
                # if none found, search on all languages
                try:
                    # There's gotta be a better way of doing this but we don't wanna
                    # change the language value elsewhere
                    ltvdb_api_parms = sickbeard.TVDB_API_PARMS.copy()

                    ltvdb_api_parms['search_all_languages'] = True
                    t = tvdb_api.Tvdb(custom_ui=classes.ShowListUI, **ltvdb_api_parms)

                    self._log(u"Looking up name "+cur_name+u" in all languages on TVDB", logger.DEBUG)
                    showObj = t[cur_name]
                except (tvdb_exceptions.tvdb_exception, IOError):
#.........这里部分代码省略.........
开发者ID:brinbois,项目名称:Sick-Beard,代码行数:101,代码来源:postProcessor.py

示例5: _analyze_name

    def _analyze_name(self, name, file=True):
        """
        Takes a name and tries to figure out a show, season, and episode from it.

        name: A string which we want to analyze to determine show info from (unicode)

        Returns a (indexer_id, season, [episodes]) tuple. The first two may be None and episodes may be []
        if none were found.
        """

        logger.log(u"Analyzing name " + repr(name))

        to_return = (None, None, [])

        if not name:
            return to_return

        # parse the name to break it into show name, season, and episode
        np = NameParser(file)
        parse_result = np.parse(name).convert()

        self._log("Parsed " + name + " into " + str(parse_result).decode('utf-8'), logger.DEBUG)

        if parse_result.air_by_date:
            season = -1
            episodes = [parse_result.air_date]
        else:
            season = parse_result.season_number
            episodes = parse_result.episode_numbers

        to_return = (None, season, episodes)

        # do a scene reverse-lookup to get a list of all possible names
        name_list = show_name_helpers.sceneToNormalShowNames(parse_result.series_name)

        if not name_list:
            return (None, season, episodes)

        def _finalize(parse_result):
            self.release_group = parse_result.release_group

            # remember whether it's a proper
            if parse_result.extra_info:
                self.is_proper = re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', parse_result.extra_info,
                                           re.I) != None

            # if the result is complete then remember that for later
            if parse_result.series_name and parse_result.season_number != None and parse_result.episode_numbers and parse_result.release_group:
                test_name = os.path.basename(name)
                if test_name == self.nzb_name:
                    self.good_results[self.NZB_NAME] = True
                elif test_name == self.folder_name:
                    self.good_results[self.FOLDER_NAME] = True
                elif test_name == self.file_name:
                    self.good_results[self.FILE_NAME] = True
                else:
                    logger.log(u"Nothing was good, found " + repr(test_name) + " and wanted either " + repr(
                        self.nzb_name) + ", " + repr(self.folder_name) + ", or " + repr(self.file_name))
            else:
                logger.log(u"Parse result not sufficient(all following have to be set). Will not save release name",
                           logger.DEBUG)
                logger.log("Parse result(series_name): " + str(parse_result.series_name), logger.DEBUG)
                logger.log("Parse result(season_number): " + str(parse_result.season_number), logger.DEBUG)
                logger.log("Parse result(episode_numbers): " + str(parse_result.episode_numbers), logger.DEBUG)
                logger.log("Parse result(release_group): " + str(parse_result.release_group), logger.DEBUG)

        # for each possible interpretation of that scene name
        for cur_name in name_list:
            showObj = helpers.get_show_by_name(cur_name)
            if showObj:
                _finalize(parse_result)
                return (showObj.indexerid, season, episodes)

        _finalize(parse_result)
        return to_return
开发者ID:WoLpH,项目名称:SickBeard-TVRage,代码行数:75,代码来源:postProcessor.py

示例6: _analyze_name

    def _analyze_name(self, name, file=True):
        """
        Takes a name and tries to figure out a show, season, and episode from it.

        name: A string which we want to analyze to determine show info from (unicode)

        Returns a (indexer_id, season, [episodes]) tuple. The first two may be None and episodes may be []
        if none were found.
        """

        logger.log(u"Analyzing name " + repr(name))

        to_return = (None, None, [])

        if not name:
            return to_return

        # parse the name to break it into show name, season, and episode
        np = NameParser(file)
        parse_result = np.parse(name)

        self._log("Parsed " + name + " into " + str(parse_result).decode('utf-8'), logger.DEBUG)

        if parse_result.air_by_date:
            season = -1
            episodes = [parse_result.air_date]
        else:
            season = parse_result.season_number
            episodes = parse_result.episode_numbers

        to_return = (None, season, episodes)

        # do a scene reverse-lookup to get a list of all possible names
        name_list = show_name_helpers.sceneToNormalShowNames(parse_result.series_name)

        if not name_list:
            return (None, season, episodes)

        def _finalize(parse_result):
            self.release_group = parse_result.release_group

            # remember whether it's a proper
            if parse_result.extra_info:
                self.is_proper = re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', parse_result.extra_info,
                                           re.I) != None

            # if the result is complete then remember that for later
            if parse_result.series_name and parse_result.season_number != None and parse_result.episode_numbers and parse_result.release_group:
                test_name = os.path.basename(name)
                if test_name == self.nzb_name:
                    self.good_results[self.NZB_NAME] = True
                elif test_name == self.folder_name:
                    self.good_results[self.FOLDER_NAME] = True
                elif test_name == self.file_name:
                    self.good_results[self.FILE_NAME] = True
                else:
                    logger.log(u"Nothing was good, found " + repr(test_name) + " and wanted either " + repr(
                        self.nzb_name) + ", " + repr(self.folder_name) + ", or " + repr(self.file_name))
            else:
                logger.log(u"Parse result not sufficient(all following have to be set). Will not save release name",
                           logger.DEBUG)
                logger.log("Parse result(series_name): " + str(parse_result.series_name), logger.DEBUG)
                logger.log("Parse result(season_number): " + str(parse_result.season_number), logger.DEBUG)
                logger.log("Parse result(episode_numbers): " + str(parse_result.episode_numbers), logger.DEBUG)
                logger.log("Parse result(release_group): " + str(parse_result.release_group), logger.DEBUG)

        # for each possible interpretation of that scene name
        for cur_name in name_list:
            self._log(u"Checking scene exceptions for a match on " + cur_name, logger.DEBUG)
            scene_id = scene_exceptions.get_scene_exception_by_name(cur_name)
            if scene_id:
                self._log(u"Scene exception lookup got a indexer id " + str(scene_id) + ", using that", logger.DEBUG)
                _finalize(parse_result)
                return (scene_id, season, episodes)

        # see if we can find the name directly in the DB, if so use it
        for cur_name in name_list:
            self._log(u"Looking up " + cur_name + u" in the DB", logger.DEBUG)
            db_result = helpers.searchDBForShow(cur_name)
            if db_result:
                self._log(u"Lookup successful, using " + sickbeard.indexerApi(db_result[0]).name + " id " + str(
                    db_result[1]),
                          logger.DEBUG)
                _finalize(parse_result)
                return (int(db_result[1]), season, episodes)

        # see if we can find the name on the Indexer
        for cur_name in name_list:
            foundInfo = helpers.searchIndexerForShowID(cur_name, self.indexer)
            if foundInfo:
                indexer_id = foundInfo[1]
                self._log(
                    u"Lookup successful, using " + sickbeard.indexerApi(self.indexer).name + " id " + str(indexer_id),
                    logger.DEBUG)
                _finalize(parse_result)
                return (indexer_id, season, episodes)

        _finalize(parse_result)
        return to_return
开发者ID:lotusje,项目名称:SickBeard-TVRage,代码行数:99,代码来源:postProcessor.py

示例7: _analyze_name

    def _analyze_name(self, name, file=True):
        """
        Takes a name and tries to figure out a show, season, and episode from it.
        
        Returns a (tvdb_id, season, [episodes]) tuple. The first two may be None and episodes may be []
        if none were found.
        """

        logger.log(u"Analyzing name " + repr(name))

        to_return = (None, None, [])

        if not name:
            return to_return

        # parse the name to break it into show name, season, and episode
        np = NameParser(file)
        parse_result = np.parse(name)
        self._log("Parsed " + name + " into " + str(parse_result).decode("utf-8"), logger.DEBUG)

        if parse_result.air_by_date:
            season = -1
            episodes = [parse_result.air_date]
        else:
            season = parse_result.season_number
            episodes = parse_result.episode_numbers

        to_return = (None, season, episodes)

        # do a scene reverse-lookup to get a list of all possible names
        name_list = show_name_helpers.sceneToNormalShowNames(parse_result.series_name)

        if not name_list:
            return (None, season, episodes)

        def _finalize(parse_result):
            self.release_group = parse_result.release_group
            if parse_result.extra_info:
                self.is_proper = (
                    re.search("(^|[\. _-])(proper|repack)([\. _-]|$)", parse_result.extra_info, re.I) != None
                )

        # for each possible interpretation of that scene name
        for cur_name in name_list:
            self._log(u"Checking scene exceptions for a match on " + cur_name, logger.DEBUG)
            scene_id = scene_exceptions.get_scene_exception_by_name(cur_name)
            if scene_id:
                self._log(u"Scene exception lookup got tvdb id " + str(scene_id) + u", using that", logger.DEBUG)
                _finalize(parse_result)
                return (scene_id, season, episodes)

        # see if we can find the name directly in the DB, if so use it
        for cur_name in name_list:
            self._log(u"Looking up " + cur_name + u" in the DB", logger.DEBUG)
            db_result = helpers.searchDBForShow(cur_name)
            if db_result:
                self._log(u"Lookup successful, using tvdb id " + str(db_result[0]), logger.DEBUG)
                _finalize(parse_result)
                return (int(db_result[0]), season, episodes)

        # see if we can find the name with a TVDB lookup
        for cur_name in name_list:
            try:
                t = tvdb_api.Tvdb(custom_ui=classes.ShowListUI, **sickbeard.TVDB_API_PARMS)

                self._log(u"Looking up name " + cur_name + u" on TVDB", logger.DEBUG)
                showObj = t[cur_name]
            except (tvdb_exceptions.tvdb_exception):
                # if none found, search on all languages
                try:
                    # There's gotta be a better way of doing this but we don't wanna
                    # change the language value elsewhere
                    ltvdb_api_parms = sickbeard.TVDB_API_PARMS.copy()

                    ltvdb_api_parms["search_all_languages"] = True
                    t = tvdb_api.Tvdb(custom_ui=classes.ShowListUI, **ltvdb_api_parms)

                    self._log(u"Looking up name " + cur_name + u" in all languages on TVDB", logger.DEBUG)
                    showObj = t[cur_name]
                except (tvdb_exceptions.tvdb_exception, IOError):
                    pass

                continue
            except (IOError):
                continue

            self._log(u"Lookup successful, using tvdb id " + str(showObj["id"]), logger.DEBUG)
            _finalize(parse_result)
            return (int(showObj["id"]), season, episodes)

        _finalize(parse_result)
        return to_return
开发者ID:kacy,项目名称:Sick-Beard,代码行数:92,代码来源:postProcessor.py


注:本文中的sickbeard.show_name_helpers.sceneToNormalShowNames函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。