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


Python Scanner.add_files_to_db方法代码示例

本文整理汇总了Python中scanner.Scanner.add_files_to_db方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.add_files_to_db方法的具体用法?Python Scanner.add_files_to_db怎么用?Python Scanner.add_files_to_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scanner.Scanner的用法示例。


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

示例1: scan_files

# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import add_files_to_db [as 别名]
    def scan_files(self):
        for video_dir in config.tv_dirs:
            self.progress.setLabelText("Scanning Files from %s into DB..." \
                                       %  (video_dir))
            self.logger.info("Scanning files")
            scanner = Scanner(video_dir)
            scanner.set_series_list()
            self.progress.setMaximum(len(scanner.series_list))
            self.progress.setValue(0)
            self.logger.debug(scanner.series_list)
            for series_name in scanner.series_list:
                self.progress.setValue(scanner.series_list.index(series_name))
                self.progress.show()
                match_list = scanner.get_series_id_list(series_name)
                if len(match_list) == 0:
                    self.logger.info("No matches found on thetvdb.com for '%s'." % (series_name))
                ### FIXME ###
                    series_id = raw_input("Please input the ID for the correct series:")
                elif len(match_list) == 1:
                    self.logger.info("Found match for '%s'." % (series_name))
                    series_id = match_list[0][0]
                else:
                    match = False
                    list = ''
                    for i in range(0,len(match_list)):
                        if match_list[i][1] == series_name:
                            self.logger.info("Found match for '%s'." % (series_name))
                            series_id = match_list[i][0]
                            match = True
                        else:
                            list += "[%d] %s (%s)\n " % (i, match_list[i][1], \
                                                         match_list[i][0])
                    if not match:
                        selection = self.input_dialog.getInt(self, '', \
                                    "Select best match:\n %s" % (list), \
                                    0, 0, len(match_list) - 1)[0]
                        try:
                            series_id = match_list[selection][0]
                        except IndexError:
                            self.logger.info("That is not an option.")
                if config.prefer_local:
                    self.logger.info("Adding info from local nfo files")
                    scanner.add_series_to_db_by_nfo(series_name)
                else:
                    self.logger.info("Adding info from thetvdb.com")
                    scanner.add_series_to_db_by_id(series_id)
                self.logger.info("Adding files to db.")
                scanner.add_files_to_db(series_id, series_name)
            dbTV.remove_shows_with_no_files()
            scanner.__del__()
            self.progress.setValue(len(scanner.series_list))

        self.logger.info("Finished Scanning")
        #Create a dom representing the shows in the database
        shows = dbTV.make_shows_list()
        #Turn that into a model
        model = ShowListModel(shows)
        #Set that as the model for the listView
        self.ui.listView_shows.setModel(model)
开发者ID:joelmeans,项目名称:pymetadatamanager,代码行数:61,代码来源:main_window.py


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