def play_transcode_video(userid, path, name, md5, select_type=False): player = myplayer.Player() listitem = xbmcgui.ListItem(name) listitem.setInfo(type="Video", infoLabels={'Title': name}) api = get_api(userid) if select_type: choice = xbmcutils.select('请选转码格式', TRANSCODE_TYPES) if choice < 0: return transcode_type = TRANSCODE_TYPES[choice] else: transcode_type = plugin.get_setting('transcode_type', str) params = dict((k, v[0]) for k, v in plugin.request.args.items()) subtitle = params.get('subtitle') if subtitle: subtitle = [subtitle] else: subtitle = [] api_res = api.get_subtitle(md5, name or '', path) if api_res['total_num'] > 0: for sub_record in api_res['records']: subtitle.append(sub_record['file_path']) player.play(api.get_transcode_url(path, transcode_type), listitem, sublist=subtitle)
def play_stream(url, name=None): params = dict((k, v[0]) for k, v in plugin.request.args.items()) subtitle = params.get('subtitle') if subtitle: subtitle += '|User-Agent=Mozilla/5.0%20%28Windows%20NT%206.1%3B%20rv%3A25.0%29%20Gecko/20100101%20Firefox/25.0&Referer=http%3A//pan.baidu.com/disk/home' # noqa url += '|User-Agent=Mozilla/5.0%20%28Windows%20NT%206.1%3B%20rv%3A25.0%29%20Gecko/20100101%20Firefox/25.0&Referer=http%3A//pan.baidu.com/disk/home' # noqa if name is None: plugin.set_resolved_url(url, subtitle) elif is_torrent(name): plugin.redirect(plugin.url_for('play_torrent', url=url)) else: listitem = xbmcgui.ListItem(name) player = myplayer.Player() player.play(url, listitem, sublist=subtitle)
def play_path(userid, path, md5, name=None): params = dict((k, v[0]) for k, v in plugin.request.args.items()) subtitle = params.get('subtitle') if subtitle: subtitle = [ get_dlink(userid, subtitle) + '|User-Agent=AppleCoreMedia/1.0.0.9B206 (iPad; U; CPU OS 5_1_1 like Mac OS X; zh_cn)' ] # noqa else: subtitle = [] # api = get_api(userid) # item = api.get_filemetas(path)['info'][0] # url = item['dlink'] + '|User-Agent=AppleCoreMedia/1.0.0.9B206 (iPad; U; CPU OS 5_1_1 like Mac OS X; zh_cn)' # noqa url = get_dlink( userid, path ) + '|User-Agent=AppleCoreMedia/1.0.0.9B206 (iPad; U; CPU OS 5_1_1 like Mac OS X; zh_cn)' # noqa api = get_api(userid) api_res = api.get_subtitle(md5, name or '', path) if api_res['total_num'] > 0: for sub_record in api_res['records']: subtitle.insert(0, sub_record['file_path']) params = dict((k, v[0]) for k, v in plugin.request.args.items()) if 'resolved' in params: plugin.set_resolved_url(url) if subtitle: player = xbmc.Player() for _ in xrange(30): if player.isPlaying(): break time.sleep(1) else: raise Exception('No video playing. Aborted after 30 seconds.') for surl in subtitle: # print '$'*50, surl player.setSubtitles(surl) # player.setSubtitleStream(0) else: listitem = xbmcgui.ListItem(name) player = myplayer.Player() player.play(url, listitem, sublist=subtitle)