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', ''
评论列表
文章目录