main.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:GetSubtitles 作者: gyh1621 项目源码 文件源码
def choose_subtitle(self, sub_dict):

        """ ????????
            ????????????????????????
            ????????????????????????? """

        if not self.query:
            chosen_sub = list(sub_dict.keys())[0]
            link = sub_dict[chosen_sub]['link']
            return chosen_sub, link

        for i, key in enumerate(sub_dict.keys()):
            if i == self.sub_num:
                break
            lang_info = ''
            lang_info += '???' if 4 & sub_dict[key]['lan'] else '      '
            lang_info += '???' if 2 & sub_dict[key]['lan'] else '      '
            lang_info += '???' if 1 & sub_dict[key]['lan'] else '      '
            lang_info += '???' if 8 & sub_dict[key]['lan'] else '      '
            a_sub_info = ' %3s) %s  %s' % (i + 1, lang_info, key)
            if py == 2:
                a_sub_info = a_sub_info.decode('utf8')
                a_sub_info = a_sub_info.encode(GetSubtitles.output_encode)
            a_sub_info = prefix + a_sub_info
            print(a_sub_info)

        indexes = range(len(sub_dict.keys()))
        choice = None
        while not choice:
            try:
                print(prefix)
                choice = int(input(prefix + '  choose subtitle: '))
            except ValueError:
                print(prefix + '  Error: only numbers accepted')
                continue
            if not choice - 1 in indexes:
                print(prefix + '  Error: numbers not within the range')
                choice = None
        chosen_sub = list(sub_dict.keys())[choice - 1]
        link = sub_dict[chosen_sub]['link']
        return chosen_sub, link
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号