scutils.py 文件源码

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

项目:plugin.video.stream-cinema 作者: bbaronSVK 项目源码 文件源码
def saveSubtitle(self, content, lang, convert=True):
        codePageDict = {'ara': 'cp1256', 'ar': 'cp1256', 'cs': 'cp1250', 'ell': 'cp1253', 
            'el': 'cp1253', 'heb': 'cp1255', 'he': 'cp1255', 'sk': 'cp1250', 'tur': 'cp1254', 
            'tr': 'cp1254', 'rus': 'cp1251', 'ru': 'cp1251'}

        subtitle = xbmc.validatePath(xbmc.translatePath('special://temp/'))
        subtitle = os.path.join(subtitle, 'AutomatickeTitulky.%s.srt' % lang)

        codepage = codePageDict.get(lang, '')
        if codepage and self.getSetting('subtitles.utf') == 'true':
            try:
                content_encoded = codecs.decode(content, codepage)
                content = codecs.encode(content_encoded, 'utf-8')
            except Exception, e:
                util.debug("[SC] chyba ukladania titulkov....")
                pass

        file = xbmcvfs.File(subtitle, 'w')
        file.write(str(content))
        file.close()
        return subtitle
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号