def make_channel_list(): utils.log("url-make-channel" + sys.argv[0]) try: channels = api.get_channels() ok = True for c in channels: listitem = xbmcgui.ListItem(label=c['name']) listitem.setInfo('video', {'title': c['name']}) listitem.setIconImage('https://manstv.lattelecom.tv/' + c['logo']) listitem.setThumbnailImage('https://manstv.lattelecom.tv/' + c['thumb']) listitem.setProperty('IsPlayable', "true") # Build the URL for the program, including the list_info url = "%s?play=true&data_url=%s" % (sys.argv[0], c['id']) # Add the program item to the list ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False, totalItems=len(channels)) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok) xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes') except: d = xbmcgui.Dialog() msg = utils.dialog_error("Unable to fetch listing") d.ok(*msg) utils.log_error()
def play(params): __addon__ = xbmcaddon.Addon() p = utils.get_url(params) # Show a dialog d = xbmcgui.DialogProgress() d.create(config.NAME, "Starting %s..." % p['name']) try: thumb = os.path.join(__addon__.getAddonInfo('path'), "resources", "img", "%s.jpg" % p['id']) labels = { "title": p['name'], "artist": "AFL Radio", "genre": "Sport" } listitem = xbmcgui.ListItem(p['name']) listitem.setInfo(type='music', infoLabels=labels) listitem.setThumbnailImage(thumb) # PAPlayer or AUTO fails here for some absurd reason xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(p['url'], listitem) except: # user cancelled dialog or an error occurred d = xbmcgui.Dialog() message = utils.dialog_error("Unable to play %s" % p['name']) d.ok(*message) utils.log_error();
def play(url): # Show a dialog d = xbmcgui.DialogProgress() d.create(config.NAME, '') d.update(20, 'Fetching video parameters...') v = classes.Video() v.parse_xbmc_url(url) try: d.update(40, 'Fetching video URL...') base_url = get_url(v.id) d.update(60, 'Fetching video URL...') video_url = quality_url(base_url) d.update(80, 'Building playlist...') listitem = xbmcgui.ListItem(label=v.get_title(), iconImage=v.get_thumbnail(), thumbnailImage=v.get_thumbnail()) listitem.setInfo('video', v.get_xbmc_list_item()) d.update(99, 'Starting video...') xbmc.Player().play(video_url, listitem) except: # user cancelled dialog or an error occurred d = xbmcgui.Dialog() message = utils.dialog_error("Unable to play video") d.ok(*message) utils.log_error();
def make_series_list(url): params = utils.get_url(url) try: iview_config = comm.get_config() series_list = comm.get_programme(iview_config, params["category_id"]) series_list.sort() ok = True for s in series_list: url = "%s?series_id=%s" % (sys.argv[0], s.id) thumbnail = s.get_thumbnail() listitem = xbmcgui.ListItem(s.get_list_title(), iconImage=thumbnail, thumbnailImage=thumbnail) listitem.setInfo('video', { 'plot' : s.get_description() }) # add the item to the media list ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=True) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok) xbmcplugin.setContent(handle=int(sys.argv[1]), content='tvshows') except: d = xbmcgui.Dialog() message = utils.dialog_error("Unable to fetch listing") d.ok(*message) utils.log_error();
def play(url): iview_config = comm.get_config() auth = comm.get_auth(iview_config) p = classes.Program() p.parse_xbmc_url(url) try: # Playpath shoud look like this: # Akamai: mp4:flash/playback/_definst_/itcrowd_10_03_02 playpath = auth['playpath_prefix'] + p.url if playpath.split('.')[-1] == 'mp4': playpath = 'mp4:' + playpath # Strip off the .flv or .mp4 playpath = playpath.split('.')[0] # rtmp://cp53909.edgefcs.net/ondemand?auth=daEbjbeaCbGcgb6bedYacdWcsdXc7cWbDda-bmt0Pk-8-slp_zFtpL&aifp=v001 # playpath=mp4:flash/playback/_definst_/kids/astroboy_10_01_22 swfurl=http://www.abc.net.au/iview/images/iview.jpg swfvfy=true rtmp_url = "%s?auth=%s playpath=%s swfurl=%s swfvfy=true" % (auth['rtmp_url'], auth['token'], playpath, config.swf_url) listitem=xbmcgui.ListItem(label=p.get_list_title(), iconImage=p.thumbnail, thumbnailImage=p.thumbnail) listitem.setInfo('video', p.get_xbmc_list_item()) xbmc.Player().play(rtmp_url, listitem) except: # oops print error message d = xbmcgui.Dialog() message = utils.dialog_error("Unable to play video") d.ok(*message) utils.log_error();
def make_programs_list(url): try: params = utils.get_url(url) iview_config = comm.get_config() programs = comm.get_series_items(iview_config, params["series_id"]) ok = True for p in programs: listitem = xbmcgui.ListItem(label=p.get_list_title(), iconImage=p.get_thumbnail(), thumbnailImage=p.get_thumbnail()) listitem.setInfo('video', p.get_xbmc_list_item()) if hasattr(listitem, 'addStreamInfo'): listitem.addStreamInfo('audio', p.get_xbmc_audio_stream_info()) listitem.addStreamInfo('video', p.get_xbmc_video_stream_info()) # Build the URL for the program, including the list_info url = "%s?play=true&%s" % (sys.argv[0], p.make_xbmc_url()) # Add the program item to the list ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False, totalItems=len(programs)) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok) xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes') except: d = xbmcgui.Dialog() msg = utils.dialog_error("Unable to fetch listing") d.ok(*msg) utils.log_error();
def fill_programs_list(programs): try: ok = True for prog in programs: p = prog #p = comm.get_program(prog.url_path) item_info = p.get_xbmc_list_item() item_url = p.make_xbmc_url() listitem = xbmcgui.ListItem(label=p.get_list_title(), iconImage=p.get_thumbnail(), thumbnailImage=p.get_thumbnail()) listitem.setInfo('video', item_info) # Build the URL for the program, including the list_info url = "%s?play=true&%s" % (sys.argv[0], item_url) # Add the program item to the list ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False, totalItems=len(programs)) except: # user cancelled dialog or an error occurred d = xbmcgui.Dialog() title = "%s Error" % config.NAME msg = utils.dialog_error("Unable to fetch listing") d.ok(*msg) utils.log_error() ok = False return ok
def play(url, nid): utils.log('play: ' + urllib.quote(url)) if nid == 'live': meta = utils.get_metadata(nid) # this is usually the live stream isn't currently active if 'error_msg' in meta: utils.log('cannot play stream: %s, %s' % (url, meta['error_msg'])) utils.dialog_error(meta['error_msg']) return """ # XXX disabled as not currently working? # permission dance. if we're already logged in (have a valid cookie), no need to log in again perms = utils.get_perms(nid) if not perms: # login and recheck video permissions if not utils.wsbk_login(): return perms = utils.get_perms(nid) if not perms: # we really mustn't have permission utils.log('no permission for video %s' % nid) utils.dialog_error('No permission to access this video. Check login details in plugin settings.') return """ (stream_url, meta) = utils.get_stream_url(nid) listitem = xbmcgui.ListItem(label=meta['title'], iconImage=meta['thumbnail_url'], thumbnailImage=meta['thumbnail_url']) utils.log("Playing stream: %s" % stream_url) try: xbmc.Player().play(stream_url, listitem) except: utils.dialog_error("Cannot play video")
def make_programs_list(url): params = utils.get_url(url) try: programs = get_programs(params["series_id"]) # fill media list ok = fill_programs_list(programs) except: # oops print error message d = xbmcgui.Dialog() msg = utils.dialog_error("Unable to fetch listing") d.ok(*msg) utils.log_error(); ok = False # send notification we're finished, successfully or unsuccessfully xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
def make_series_list(): try: series_list = comm.get_index() series_list.sort() # fill media list ok = fill_series_list(series_list) except: # oops print error message d = xbmcgui.Dialog() message = utils.dialog_error("Unable to fetch listing") d.ok(*message) utils.log_error(); ok = False # send notification we're finished, successfully or unsuccessfully xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
def make_programs_list(url): params = utils.get_url(url) try: program_list = comm.get_series(params["series_id"]) # fill media list ok = fill_programs_list(program_list) except: # oops print error message d = xbmcgui.Dialog() msg = utils.dialog_error("Unable to fetch listing") d.ok(*msg) utils.log_error(); ok = False # send notification we're finished, successfully or unsuccessfully xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
def make_category_list(): try: category_list = get_categories() category_list = sorted(category_list, key=lambda k: k['name'].lower()) category_list.insert(0, {'name':'All', 'keyword':'0-z'}) # fill media list ok = fill_category_list(category_list) except: d = xbmcgui.Dialog() message = utils.dialog_error("Unable to fetch listing") d.ok(*message) utils.log_error(); ok = False # send notification we're finished, successfully or unsuccessfully xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
def make_series_list(url): params = utils.get_url(url) try: series_list = get_series(params["category_id"]) series_list.sort() # fill media list ok = fill_series_list(series_list) except: d = xbmcgui.Dialog() message = utils.dialog_error("Unable to fetch listing") d.ok(*message) utils.log_error(); ok = False # send notification we're finished, successfully or unsuccessfully xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
def make_series_list(url): params = utils.get_url(url) try: series_list = get_series(params["category_id"]) series_list.sort() # fill media list ok = fill_series_list(series_list) except: d = xbmcgui.Dialog() message = utils.dialog_error("Unable to fetch listing") d.ok(*message) utils.log_error() ok = False # send notification we're finished, successfully or unsuccessfully xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
def play(url): try: iview_config = comm.get_config() auth = comm.get_auth(iview_config) # We don't support Adobe HDS yet, Fallback to RTMP streaming server if auth['rtmp_url'].startswith('http://'): auth['rtmp_url'] = iview_config['rtmp_url'] or config.akamai_fallback_server auth['playpath_prefix'] = config.akamai_playpath_prefix utils.log("Adobe HDS Not Supported, using fallback server %s" % auth['rtmp_url']) p = classes.Program() p.parse_xbmc_url(url) # Playpath shoud look like this: # Akamai: mp4:flash/playback/_definst_/itcrowd_10_03_02 playpath = auth['playpath_prefix'] + p.url if playpath.split('.')[-1] == 'mp4': playpath = 'mp4:' + playpath # Strip off the .flv or .mp4 playpath = playpath.split('.')[0] # rtmp://cp53909.edgefcs.net/ondemand?auth=daEbjbeaCbGcgb6bedYacdWcsdXc7cWbDda-bmt0Pk-8-slp_zFtpL&aifp=v001 # playpath=mp4:flash/playback/_definst_/kids/astroboy_10_01_22 swfurl=http://www.abc.net.au/iview/images/iview.jpg swfvfy=true rtmp_url = "%s?auth=%s playpath=%s swfurl=%s swfvfy=true" % (auth['rtmp_url'], auth['token'], playpath, config.swf_url) listitem=xbmcgui.ListItem(label=p.get_list_title(), iconImage=p.thumbnail, thumbnailImage=p.thumbnail) listitem.setInfo('video', p.get_xbmc_list_item()) if hasattr(listitem, 'addStreamInfo'): listitem.addStreamInfo('audio', p.get_xbmc_audio_stream_info()) listitem.addStreamInfo('video', p.get_xbmc_video_stream_info()) xbmc.Player().play(rtmp_url, listitem) except: # oops print error message d = xbmcgui.Dialog() message = utils.dialog_error("Unable to play video") d.ok(*message) utils.log_error();
def fill_video_list(videos): try: ok = True for v in videos: listitem = xbmcgui.ListItem(label=v.get_title(), iconImage=v.get_thumbnail(), thumbnailImage=v.get_thumbnail()) listitem.setInfo('video', v.get_xbmc_list_item()) # Build the URL for the program, including the list_info url = "%s?%s" % (sys.argv[0], v.make_xbmc_url()) # Add the program item to the list ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False) xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes') except: # user cancelled dialog or an error occurred d = xbmcgui.Dialog() msg = utils.dialog_error("Unable to fetch video list") d.ok(*msg) utils.log_error(); return ok
def play(url): params = utils.get_url(url) p = classes.Program() p.parse_xbmc_url(url) program_id = comm.get_program_id(params['url_path']) stream = comm.get_stream(program_id) # Plus7 has returned a specific error if stream.has_key('error'): d = xbmcgui.Dialog() msg = utils.dialog_message("Unable to play video:\n%s" % stream['error']) d.ok(*msg) return try: # RTMP URL isn't available if stream.has_key('rtmp_host'): # Build the final RTMP Url. New syntax for external librtmp # http://trac.xbmc.org/ticket/8971 rtmp_url = "%s playpath=%s swfurl=%s swfvfy=true" % ( stream['rtmp_host'], stream['rtmp_path'], config.swf_url) listitem = xbmcgui.ListItem(label=p.title, iconImage=p.thumbnail, thumbnailImage=p.thumbnail) listitem.setInfo('video', p.get_xbmc_list_item()) xbmc.Player().play(rtmp_url, listitem) else: d = xbmcgui.Dialog() msg = utils.dialog_message( "Unable to play video:\nStream URL not found.") d.ok(*msg) return except: # oops print error message d = xbmcgui.Dialog() message = utils.dialog_error("Unable to play video") d.ok(*message) utils.log_error()
def play(url): try: params = utils.get_url(url) p = comm.get_program(params["program_id"]) listitem = xbmcgui.ListItem(label=p.get_title(), iconImage=p.thumbnail, thumbnailImage=p.thumbnail) listitem.setInfo('video', p.get_xbmc_list_item()) if hasattr(listitem, 'addStreamInfo'): listitem.addStreamInfo('audio', p.get_xbmc_audio_stream_info()) listitem.addStreamInfo('video', p.get_xbmc_video_stream_info()) xbmc.Player().play(p.get_url(), listitem) except: # oops print error message d = xbmcgui.Dialog() message = utils.dialog_error("Unable to play video") d.ok(*message) utils.log_error()
def play_channel(): utils.log("url play channel: " + sys.argv[0]) try: handle = int(sys.argv[1]) params_str = sys.argv[2] params = utils.get_url(params_str) data_url = params['data_url'] rtmp_url = api.get_stream_url(data_url) playitem = xbmcgui.ListItem(path=rtmp_url) playitem.setProperty('inputstreamaddon', 'inputstream.adaptive') playitem.setProperty('inputstream.adaptive.manifest_type', 'hls') playitem.setContentLookup(False) xbmcplugin.setResolvedUrl(handle, True, playitem) except: d = xbmcgui.Dialog() msg = utils.dialog_error("Unable to fetch listing") d.ok(*msg) utils.log_error()
def make_category_list(): try: iview_config = comm.get_config() categories = comm.get_categories(iview_config) categories = sorted(categories, key=lambda k: k['name'].lower()) categories.insert(0, {'name':'All', 'keyword':'0-z'}) ok = True for g in categories: url = "%s?category_id=%s" % (sys.argv[0], g['keyword']) listitem = xbmcgui.ListItem(g['name']) # Add the program item to the list ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=True) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok) xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes') except: d = xbmcgui.Dialog() message = utils.dialog_error("Unable to fetch listing") d.ok(*message) utils.log_error();
def play(url): params = utils.get_url(url) p = classes.Program() p.parse_xbmc_url(url) program_id = comm.get_program_id(params['url_path']) stream = comm.get_stream(program_id) # Plus7 has returned a specific error if stream.has_key('error'): d = xbmcgui.Dialog() msg = utils.dialog_message("Unable to play video:\n%s" % stream['error']) d.ok(*msg) return try: # RTMP URL isn't available if stream.has_key('rtmp_host'): # Build the final RTMP Url. New syntax for external librtmp # http://trac.xbmc.org/ticket/8971 rtmp_url = "%s playpath=%s" % (stream['rtmp_host'], stream['rtmp_path']) listitem=xbmcgui.ListItem(label=p.title, iconImage=p.thumbnail, thumbnailImage=p.thumbnail) listitem.setInfo('video', p.get_xbmc_list_item()) xbmc.Player().play(rtmp_url, listitem) else: d = xbmcgui.Dialog() msg = utils.dialog_message("Unable to play video:\nStream URL not found.") d.ok(*msg) return except: # oops print error message d = xbmcgui.Dialog() message = utils.dialog_error("Unable to play video") d.ok(*message) utils.log_error();
def make_list(): try: # Show a dialog pDialog = xbmcgui.DialogProgress() pDialog.create('AFL Video', 'Getting Team List') pDialog.update(50) for t in config.TEAMS: # Add our resources/lib to the python path try: current_dir = os.path.dirname(os.path.abspath(__file__)) except: current_dir = os.getcwd() thumbnail = os.path.join(current_dir, "..", "..", "resources", "img", t['thumb']) listitem = xbmcgui.ListItem(label=t['name'], iconImage=thumbnail, thumbnailImage=thumbnail) url = "%s?channel=%s" % (sys.argv[0], t['channel']) # Add the item to the list ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=True, totalItems=len(config.TEAMS)) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok) xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes') except: # user cancelled dialog or an error occurred d = xbmcgui.Dialog() msg = utils.dialog_error("Unable to fetch video list") d.ok(*msg) utils.log_error()
def errorDialog(err=""): if IS_XBMC: d = xbmcgui.Dialog() message = utils.dialog_error(err) d.ok(*message)