def play_video(eid, server): html = fetch_html('/vids/play/%s/%s' % (eid, server)) urls = joonmedia.extract_video_link(html) if len(urls) > 0: # select first video plugin.log.debug(urls[0]) quality = plugin.get_setting('qualityPref', int) info = getVideoInfo(urls[0], quality=quality, resolve_redirects=True) if info is None: plugin.log.warning('Fail to extract') return None streams = info.streams() plugin.log.debug("num of streams: %d" % len(streams)) from xbmcswift2 import xbmc, xbmcgui pl = xbmc.PlayList( xbmc.PLAYLIST_VIDEO ) pl.clear() for stream in streams: li = xbmcgui.ListItem(stream['title'], iconImage="DefaultVideo.png") li.setInfo( 'video', { "Title": stream['title'] } ) pl.add(stream['xbmc_url'], li) xbmc.Player().play(pl) else: plugin.log.warning('Unsupported') return plugin.finish(None, succeeded=False) # immediate return
def play(vid): videos = api.get_videos(vid) items = [ { 'label': video.title, 'label2': video.subtitle, 'icon': video.thumb, 'thumbnail': video.thumb, 'path': plugin.url_for('play', vid=str(video.id)), # video.url, 'is_playable': True, 'info': { 'date': video.date, 'plot': video.plot, 'plotoutline': video.plot, 'title': video.title, 'id': video.id }, 'stream_info': { 'duration': video.duration, } } for video in videos ] if len(items) > 1: plugin.log.debug('playlist found, adding %s items: %s' % (len(items), [i['info']['id'] for i in items])) xbmc.PlayList(1).clear() plugin.add_to_playlist(items) item = items[0] _id = item['info']['id'] plugin.log.debug('setting resolved url for first item %s' % _id) item['path'] = api.resolve_video_url(_id) plugin.set_resolved_url(item, 'video/mp4')
def list_parts(category, video, part): playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() for item in bili.get_video_parts2(category, video, part): playlist.add(item['link']) xbmc.Player().play(playlist)
def _play_video_by_list(urls_info, show_comments='0'): _print_info('Play without subtitle') playlist = xbmc.PlayList(1) playlist.clear() i = 1 _print_info(str(len(urls_info[0])) + ' parts found!') player = BiliPlayer() for url in urls_info[0]: list_item = xbmcgui.ListItem(u'播放') list_item.setInfo(type='video', infoLabels={"Title": "第"+str(i)+"/"+str(len(urls_info[0]))+" 节"}) i += 1 playlist.add(url, listitem=list_item) player.showSubtitles(False) player.show_subtitle = False player.play(playlist)
def disc_play_all(disc_id): data = api.request( 'disc.getInfo', { 'id': disc_id, 'video_sources': _get_supported_sources(), 'video_status': 1 }) items = [ _make_video_item(video) for video in data['disc']['videos']['video'] ] playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() for item in items: listitem = ListItem.from_dict(**item) playlist.add(item['path'], listitem.as_xbmc_listitem()) player = xbmc.Player() player.playPlaylist(playlist)
def _play_video(urls_info, show_comments='1'): playlist = xbmc.PlayList(1) playlist.clear() list_item = xbmcgui.ListItem(u'播放') list_item.setInfo(type='video', infoLabels={"Title": u"播放"}) _print_info(str(len(urls_info[0])) + ' parts found') stack_url = 'stack://' + ' , '.join(urls_info[0]) playlist.add(stack_url, list_item) player = BiliPlayer() if show_comments == '1': _print_info('Play with subtitle') player.setSubtitle(get_tmp_dir() + '/' + urls_info[1]) else: _print_info('Play without subtitle') player.showSubtitles(False) player.show_subtitle = False player.play(playlist) #while(not xbmc.abortRequested): xbmc.sleep(100)
def play_video(url): plugin.log.debug(url) quality = plugin.get_setting('qualityPref', int) info = getVideoInfo(url, quality=quality, resolve_redirects=True) if info: streams = info.streams() plugin.log.debug("num of streams: %d" % len(streams)) from xbmcswift2 import xbmc, xbmcgui pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) pl.clear() for stream in streams: li = xbmcgui.ListItem(stream['title'], iconImage="DefaultVideo.png") li.setInfo('video', {"Title": stream['title']}) pl.add(stream['xbmc_url'], li) xbmc.Player().play(pl) else: plugin.log.warning('Fail to extract') plugin.play_video({'path': url, 'is_playable': True}) return plugin.finish(None, succeeded=False)
def playmovie(cid, vid, name): if vid != '0': urls = video_from_vid(vid) else: urls = bilivideo_from_vid(cid) stack_url = 'stack://' + ' , '.join(urls) danmu = plugin.addon.getSetting('danmu') playlist = xbmc.PlayList(1) playlist.clear() list_item = xbmcgui.ListItem(name) if danmu == 'true': bilibili.parse_subtitle(cid) player.setSubtitle(bilibili._get_tmp_dir() + '/tmp.ass') playlist.add(stack_url, list_item) player.play(playlist) #while(not xbmc.abortRequested): xbmc.sleep(500) else: plugin.set_resolved_url(stack_url)
def add_to_playlist(self, items, playlist='video'): '''Adds the provided list of items to the specified playlist. Available playlists include *video* and *music*. ''' playlists = {'music': 0, 'video': 1} assert playlist in playlists.keys(), ('Playlist "%s" is invalid.' % playlist) selected_playlist = xbmc.PlayList(playlists[playlist]) _items = [] for item in items: if not hasattr(item, 'as_xbmc_listitem'): if 'info_type' in item.keys(): log.warning('info_type key has no affect for playlist ' 'items as the info_type is inferred from the ' 'playlist type.') # info_type has to be same as the playlist type item['info_type'] = playlist item = xbmcswift2.ListItem.from_dict(**item) _items.append(item) selected_playlist.add(item.get_path(), item.as_xbmc_listitem()) return _items
def list_videos(category, video): videos = bili.get_video_paths(category, video) if len(videos) > 1: dir_list = [{ 'label': item['title'], 'thumbnail': item['thumbnail'], 'path': plugin.url_for('list_parts', category=category, video=item['published'], part=item['part']) } for item in videos] else: playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() for item in bili.get_video_parts(category, video, '直接播放'): playlist.add(item['link']) xbmc.Player().play(playlist) return dir_list
def video_url(url): proxy = None if plugin.get_setting('useProxy', bool): proxy = plugin.get_setting('proxyServer', unicode) print "Proxy=" + proxy data = gomm.parseProg(url, proxy=proxy) if data is None: if not gomtv_login(): return data = gomm.parseProg(url, proxy=proxy) if data is None: xbmcgui.Dialog().ok(_L(30010), _L(30013)) return if len(data) == 1: video = data[0] url = video['url'] + "|Referer=" + url li = xbmcgui.ListItem(video['title'], iconImage="DefaultVideo.png") li.setInfo('video', {"Title": video['title']}) xbmc.Player().play(url, li) elif plugin.get_setting('plistDir', bool): items = [{ 'label': item['title'], 'path': item['url'] + "|Referer=" + url, 'thumbnail': "DefaultVideo.png", 'is_playable': True } for item in data] return plugin.finish(items) else: pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) pl.clear() for item in data: li = xbmcgui.ListItem(item['title'], iconImage="DefaultVideo.png") li.setInfo('video', {"Title": item['title']}) pl.add(item['url'] + "|Referer=" + url, li) xbmc.Player().play(pl) return plugin.finish(None, succeeded=False)
def action_cancel(clear_playlist=True): if clear_playlist: xbmc.PlayList(xbmc.PLAYLIST_VIDEO).clear() plugin.set_resolved_url() xbmc.executebuiltin('Dialog.Close(okdialog, true)')
def onInit(self): self.list = self.getControl( STATION_LIST_ID ) #items = [] station_list = [] Streams = stations.getStations(_sort_stations) idx = 0 print (xbmc.PLAYLIST_VIDEO) print (xbmc.PLAYLIST_MUSIC) audio_playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC) video_playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) audio_playlist.clear() video_playlist.clear() for Station in Streams: Address = Station['Address'] Country = Station['Country'] Director= Station['Director'] Email = Station['Email'] Icon = Station['Icon'] Name = Station['Name'] Phone = Station['Phone'] Schedule= Station['Schedule'] Url = Station['Url'] Verified= Station['Verified'] WebPage = Station['WebPage'] Video = Station['Video'] if 'false' == Verified: continue order = str(idx).zfill(2) li = xbmcgui.ListItem(order + ") " + Name, Name) li.setInfo('music', {'Title': Name}) li.setProperty('Address', Address) li.setProperty('Country', Country) li.setProperty('Director', Director) li.setProperty('Email', Email) li.setProperty('Icon', Icon) li.setProperty('Name', Name) li.setProperty('Phone', Phone) li.setProperty('Url', Url) li.setProperty('WebPage', WebPage) li.setProperty('Schedule', Schedule) li.setProperty('Id', str(idx)) li.setProperty('Video', Video) xlistitem = xbmcgui.ListItem(Name, iconImage=Icon, path=Url) if ("true" == Video): xlistitem.setInfo( "video", { "Title": Name } ) video_playlist.add(Url, xlistitem) else: xlistitem.setInfo( "audio", { "Title": Name } ) audio_playlist.add(Url, xlistitem) station_list.append(li) idx = idx + 1; self.list.addItems( station_list ) self.focusedID = _last_station_id self.stationsCount = len(Streams) self.list.selectItem(self.focusedID) #self.player = xbmc.Player(xbmc.PLAYER_CORE_AUTO) self.player = xbmc.Player() if (_auto_start): self.runPlayer(_last_station_id) else: self.list.selectItem(_last_focused_station_id)