def selectQuality(stream_url, quality): msg = u'Wybierz jakość video [albo ustaw automat w opcjach]' stream_selected = '' if type(stream_url) is list: qualityList = [x[0] for x in stream_url] if quality > 0: user_selection = [ '', 'Najlepsza', '1080p', '720p', '480p', '360p' ][quality] if user_selection == 'Najlepsza' and stream_url[0][1]: stream_selected = cda.getVideoUrls( stream_url[0][1], 4) # najepsza - pierwszy link elif user_selection in qualityList: stream_selected = cda.getVideoUrls( stream_url[qualityList.index(user_selection)][1], 4) else: msg = u'Problem z automatycznym wyborem ... wybierz jakosc' if not stream_selected: if len(stream_url) == 1 and stream_url[0][1] == '': msg = '[COLOR red]Problem ...[/COLOR]' selection = xbmcgui.Dialog().select(msg, qualityList) if selection > -1: stream_selected = cda.getVideoUrls(stream_url[selection][1], 4) if isinstance(stream_selected, list): stream_selected = '' else: stream_selected = '' else: stream_selected = stream_url return stream_selected
def playVideoRemote(ex_link): xbmcgui.Dialog().notification('Remote video requested', ex_link , xbmcgui.NOTIFICATION_INFO, 5000) stream_url = cda.getVideoUrls(ex_link) if type(stream_url) is list: qualityList = [x[0] for x in stream_url] selection = xbmcgui.Dialog().select("Quality [can be set default]", qualityList) if selection>-1: stream_url = cda.getVideoUrls(stream_url[selection][1],4) else: stream_url='' if not stream_url: return False liz=xbmcgui.ListItem('Remote video') liz.setInfo( type="Video", infoLabels={ "Title": 'Remote video', } ) try: # videoList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) # videoList.clear() # videoList.add(stream_url) # xbmc.Player().play(videoList) xbmcPlayer = xbmc.Player() xbmcPlayer.play(stream_url, liz) #xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path=stream_url)) except Exception as ex: xbmcgui.Dialog().ok('Problem z odtworzeniem.', 'Wystąpił nieznany błąd', str(ex)) return 1
def decodeVideo(ex_link): stream_url = cda.getVideoUrls(ex_link) if type(stream_url) is list: qualityList = [x[0] for x in stream_url] selection = xbmcgui.Dialog().select("Quality [can be set default]", qualityList) if selection>-1: stream_url = cda.getVideoUrls(stream_url[selection][1],4) else: stream_url='' print stream_url if stream_url: xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path=stream_url))
def playVideoRemote(ex_link): xbmcgui.Dialog().notification('Remote video requested', ex_link, xbmcgui.NOTIFICATION_INFO, 5000) stream_url = cda.getVideoUrls(ex_link) quality = my_addon.getSetting('quality_remote') stream_url = selectQuality(stream_url, int(quality)) if not stream_url: return False out = cda.grabInforFromLink(ex_link) if not out: out['title'] = 'Remote video' liz = xbmcgui.ListItem(out.get('title'), iconImage=out.get('img', 'DefaultVideo.png')) liz.setInfo(type="Video", infoLabels=out) try: # videoList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) # videoList.clear() # videoList.add(stream_url) # xbmc.Player().play(videoList) xbmcPlayer = xbmc.Player() xbmcPlayer.play(stream_url, liz) #xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path=stream_url)) except Exception as ex: xbmcgui.Dialog().ok('Problem z odtworzeniem.', 'Wystąpił nieznany błąd', str(ex)) return 1
def playVideoRemote(ex_link): xbmcgui.Dialog().notification('Remote video requested', ex_link , xbmcgui.NOTIFICATION_INFO, 5000) stream_url = cda.getVideoUrls(ex_link) quality = my_addon.getSetting('quality_remote') stream_url = selectQuality(stream_url,int(quality)) if not stream_url: return False out = cda.grabInforFromLink(ex_link) if not out: out['title']='Remote video' liz=xbmcgui.ListItem(out.get('title'), iconImage=out.get('img','DefaultVideo.png')) liz.setInfo( type="Video", infoLabels=out) try: # videoList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) # videoList.clear() # videoList.add(stream_url) # xbmc.Player().play(videoList) xbmcPlayer = xbmc.Player() xbmcPlayer.play(stream_url, liz) #xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path=stream_url)) except Exception as ex: xbmcgui.Dialog().ok('Problem z odtworzeniem.', 'Wystąpił nieznany błąd', str(ex)) return 1
def decodeVideo(ex_link): # tmp_COOKIE = cda.COOKIEFILE # cda.COOKIEFILE = '' stream_url = cda.getVideoUrls(ex_link) if 'drmheader' in stream_url: play_item = drmlistitem(stream_url) if play_item: xbmcplugin.setResolvedUrl(addon_handle, True, listitem=play_item) else: xbmcgui.Dialog().notification( 'Błąd', 'Video DRM - nie udało się odtworzyć', xbmcgui.NOTIFICATION_INFO, 5000) xbmcplugin.setResolvedUrl(addon_handle, False, xbmcgui.ListItem(path='')) else: quality = my_addon.getSetting('quality') stream_url = selectQuality(stream_url, int(quality)) # cda.COOKIEFILE = tmp_COOKIE if 'cda.pl/video/show/' in stream_url: xbmcplugin.setResolvedUrl(addon_handle, False, xbmcgui.ListItem(path='')) url = build_url({'mode': 'cdaSearch', 'ex_link': stream_url}) xbmc.executebuiltin('XBMC.Container.Refresh(%s)' % url) elif stream_url: xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path=stream_url)) else: xbmcplugin.setResolvedUrl(addon_handle, False, xbmcgui.ListItem(path=''))
def decodeVideo(ex_link): stream_url = cda.getVideoUrls(ex_link) quality = my_addon.getSetting('quality') stream_url = selectQuality(stream_url,int(quality)) # print '$'*10 # print stream_url if stream_url: xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path=stream_url))
def selectQuality(stream_url, quality): msg = u'Wybierz jako\u015b\u0107 video [albo ustaw automat w opcjach]' vid_url = '' if type(stream_url) is list: qualityList = [x[0] for x in stream_url] if quality > 0: user_selection = [ '', 'Najlepsza', '1080p', '720p', '480p', '360p' ][quality] if user_selection == 'Najlepsza' and stream_url[0][1]: vid_url = cda.getVideoUrls(stream_url[0][1], 4) elif user_selection in qualityList: vid_url = cda.getVideoUrls( stream_url[qualityList.index(user_selection)][1], 4) else: msg = u'Problem z automatycznym wyborem ... wybierz jako\u015b\u0107' if not vid_url: if len(stream_url) == 1 and stream_url[0][1] == '': msg = u'[COLOR red]%s[/COLOR]\n' % (unicode( stream_url[0][0], 'utf-8')) title = cda.replacePLch(fname.split('[')[0]) yes = xbmcgui.Dialog().yesno( '[COLOR red]Problem[/COLOR]', msg + u'Problem do [COLOR lightblue]%s[/COLOR]' % title, 'Szukaj nowego \xc5\xbar\xc3\xb3d\xc5\x82a?') if yes: vid_url = 'https://www.cda.pl/video/show/' + cda.replacePLch( title.replace(' ', '_')) else: selection = xbmcgui.Dialog().select(msg, qualityList) if selection > -1: vid_url = cda.getVideoUrls(stream_url[selection][1], 4) if isinstance(vid_url, list): vid_url = '' else: vid_url = '' else: vid_url = stream_url return vid_url
def selectQuality(stream_url,quality): msg = u'Wybierz jakość video [albo ustaw automat w opcjach]' stream_selected='' if type(stream_url) is list: qualityList = [x[0] for x in stream_url] if quality > 0: user_selection = ['','Najlepsza','1080p','720p','480p','360p'][quality] if user_selection=='Najlepsza': stream_selected = cda.getVideoUrls(stream_url[0][1],4) # najepsza - pierwszy link elif user_selection in qualityList: stream_selected = cda.getVideoUrls(stream_url[qualityList.index(user_selection)][1],4) else: msg = u'Problem z automatycznym wyborem ... wybierz jakosc' if not stream_selected: selection = xbmcgui.Dialog().select(msg, qualityList) if selection>-1: stream_selected = cda.getVideoUrls(stream_url[selection][1],4) else: stream_selected='' else: stream_selected = stream_url return stream_selected
def decodeVideo(ex_link): tmp_COOKIE = cda.COOKIEFILE cda.COOKIEFILE = '' print decodeVideo stream_url = cda.getVideoUrls(ex_link) print stream_url quality = my_addon.getSetting('quality') print stream_url stream_url = selectQuality(stream_url, int(quality)) print '$' * 10 print stream_url cda.COOKIEFILE = tmp_COOKIE if stream_url: xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path=stream_url)) else: xbmcplugin.setResolvedUrl(addon_handle, False, xbmcgui.ListItem(path=stream_url))
def playVideoRemote(ex_link, wart=1): stream_url = cda.getVideoUrls(ex_link) quality = my_addon.getSetting('quality_remote') stream_url = selectQuality(stream_url, int(quality) * wart) if not stream_url: return False out = cda.grabInforFromLink(ex_link) if not out: out['title'] = 'Remote video' liz = xbmcgui.ListItem(out.get('title'), iconImage=out.get('img', 'DefaultVideo.png')) liz.setInfo(*mkinfo(type='Video', infoLabels=out)) try: Player = xbmc.Player() Player.play(stream_url, liz) except Exception as ex: xbmcgui.Dialog().ok( 'Problem z odtworzeniem.', 'Wyst\xc4\x85pi\xc5\x82 nieznany b\xc5\x82\xc4\x85d', str(ex)) return 1
def playVideoRemote2(ex_link): found = eval(ex_link) tmp_COOKIE = cda.COOKIEFILE cda.COOKIEFILE = '' for href in found.get('url', []): stream_url = cda.getVideoUrls(href) stream_url = selectQuality(stream_url, int(my_addon.getSetting('quality'))) if not 'cda.pl/video/show/' in stream_url: break cda.COOKIEFILE = tmp_COOKIE if 'cda.pl/video/show/' in stream_url: xbmcplugin.setResolvedUrl(addon_handle, False, xbmcgui.ListItem(path='')) url = build_url({'mode': 'cdaSearch', 'ex_link': stream_url}) xbmc.executebuiltin('XBMC.RunPlugin(%s)' % url) elif stream_url: li = Set_ListItem(found) li.setPath(path=stream_url) xbmcplugin.setResolvedUrl(addon_handle, True, li) else: xbmcplugin.setResolvedUrl(addon_handle, False, xbmcgui.ListItem(path=''))