KodiHelper.py 文件源码

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

项目:plugin.video.netflix 作者: asciidisco 项目源码 文件源码
def showtitle_to_id(self, title):
        query = {
            "jsonrpc": "2.0",
            "method": "VideoLibrary.GetTVShows",
            "params": {
                "properties": ["title", "genre"]
            },
            "id": "libTvShows"
        }
        try:
            rpc_result = xbmc.executeJSONRPC(
                jsonrpccommand=json.dumps(query, encoding='utf-8'))
            json_result = json.loads(rpc_result)
            if 'result' in json_result and 'tvshows' in json_result['result']:
                json_result = json_result['result']['tvshows']
                for tvshow in json_result:
                    # Switch to ascii/lowercase and
                    # remove special chars and spaces
                    # to make sure best possible compare is possible
                    titledb = tvshow['label'].encode('ascii', 'ignore')
                    titledb = re.sub(
                        pattern=r'[?|$|!|:|#|\.|\,|\'| ]',
                        repl=r'',
                        string=titledb).lower().replace('-', '')
                    if '(' in titledb:
                        titledb = titledb.split('(')[0]
                    titlegiven = title.encode('ascii', 'ignore')
                    titlegiven = re.sub(
                        pattern=r'[?|$|!|:|#|\.|\,|\'| ]',
                        repl=r'',
                        string=titlegiven).lower().replace('-', '')
                    if '(' in titlegiven:
                        titlegiven = titlegiven.split('(')[0]
                    if titledb == titlegiven:
                        return tvshow['tvshowid'], tvshow['genre']
            return '-1', ''
        except Exception:
            return '-1', ''
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号