def STREAM(name, iconimage, url, protocol, sch_ch_id, ch_id): if (url == None): try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass return False if (sch_ch_id != None) and (SETTINGS.DISABLE_SCHEDULE != 'true'): grab_schedule(sch_ch_id, name) #addon_log(name) #addon_log(iconimage) if not iconimage or iconimage == "": iconimage = "DefaultVideo.png" listitem = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage) #listitem.setLabel(name) listitem.setInfo('video', {'Title': name}) player = streamplayer(xbmc.PLAYER_CORE_AUTO, name=name, protocol=protocol, ch_id=ch_id) #play sopcast stream if protocol == "sop": sop = sopcast(player=player, url=url, listitem=listitem) sop.start() #play acestream elif protocol == 'acestream': ace = acestream(player=player, url=url, listitem=listitem) ace.engine_connect() #play direct stream else: try: player.play(url, listitem) except Exception as inst: xbmcgui.Dialog().ok(addon.getLocalizedString(30060), str(type(inst)), str(inst), "") try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass
def STREAM(name, iconimage, url, protocol, sch_ch_id, ch_id): if(url == None): try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass return False if (sch_ch_id != None) and (SETTINGS.DISABLE_SCHEDULE != 'true'): grab_schedule(sch_ch_id, name) #addon_log(name) #addon_log(iconimage) if not iconimage or iconimage == "": iconimage="DefaultVideo.png" listitem = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage) #listitem.setLabel(name) listitem.setInfo('video', {'Title': name}) player = streamplayer(xbmc.PLAYER_CORE_AUTO, name=name, protocol=protocol, ch_id=ch_id) #play sopcast stream if protocol == "sop": sop = sopcast(player=player, url=url, listitem=listitem) sop.start() #play acestream elif protocol=='acestream': ace = acestream(player=player, url=url, listitem=listitem) ace.engine_connect() #play direct stream else: try: player.play(url, listitem) except Exception as inst: xbmcgui.Dialog().ok(addon.getLocalizedString(30060), str(type(inst)),str(inst),"") try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass
def CHANNEL_LIST(name, cat_id, schedule=False): addon_log(name); try: db_cursor.execute( 'SELECT id, name, country, language, status, \ video_resolution, video_aspect, audio_codec, video_codec, \ address, thumbnail, protocol, \ schedule_id \ FROM channels \ WHERE id_cat = ?', \ (cat_id,) ) rec=db_cursor.fetchall() except Exception as inst: addon_log(inst) xbmcgui.Dialog().ok(addon.getLocalizedString(30300), addon.getLocalizedString(30301), str(inst)) #Cannot parse channel list ! if len(rec)>0: for id, name, country, language, status, \ video_resolution, video_aspect, audio_codec, video_codec, \ address, thumbnail, protocol, \ schedule_id in rec: #filter by country and language #if( (((country != '') and (addon.getSetting('country_'+country) == 'true')) or #((country == '') and (addon.getSetting('country_none') == 'true')) ) and #(((language != '') and (addon.getSetting('lang_'+language) == 'true')) or #((language == '') and (addon.getSetting('lang_none') == 'true')) ) #): chan_name = name chan_url = address.strip() protocol = protocol.strip() if protocol=='sop': protocol_color = '[COLOR lightgreen]'+protocol+'[/COLOR]' else: protocol_color = '[COLOR yellow]'+protocol+'[/COLOR]' chan_thumb = thumbnail.strip() #addon_log(chan_thumb) chan_status = status if (((SETTINGS.SHOW_OFFLINE_CH=='true') and (int(chan_status)==1)) or (int(chan_status)!=1)): #if we show or not offline channels based on settings logo_name = chan_name.replace(' ', '').lower() logo_name = logo_name.encode('utf8') chan_name_formatted ="[B][COLOR blue]"+chan_name+"[/COLOR][/B]" chan_name_formatted += " ("+protocol_color if(video_codec != ''): chan_name_formatted += " "+video_codec chan_name_formatted += ")" if int(chan_status)==1: chan_name_formatted += " [COLOR red]"+addon.getLocalizedString(30063)+"[/COLOR]" #Offline thumb_path="" if chan_thumb and chan_thumb != "": fileName, fileExtension = os.path.splitext(chan_thumb) fileName=fileName.split("/")[-1] if fileName != "": #thumb_path=os.path.join(ADDON_PATH,"logos",fileName+fileExtension) fileExtension = fileExtension.encode('utf8') thumb_path=os.path.join(SETTINGS.ADDON_PATH,"logos",logo_name+fileExtension) if not os.path.isfile(thumb_path): if fileName != "": try: Downloader(chan_thumb, thumb_path, fileName+fileExtension, addon.getLocalizedString(30055)) #Downloading Channel Logo except Exception as inst: pass; #schedule if (schedule_id != 0) and \ (schedule or (addon.getSetting('schedule_ch_list') == 'true')) \ and (SETTINGS.DISABLE_SCHEDULE != 'true'): if (schedule): #update all by context menu update_all = True elif(addon.getSetting('schedule_ch_list') == 'true'): #update all when we display channel list update_all = False grab_schedule(schedule_id, chan_name, update_all=update_all) if (SETTINGS.DISABLE_SCHEDULE != 'true') and (int(cat_id) < 200): schedule_txt = load_schedule(chan_name) chan_name_formatted += " " + schedule_txt addLink(id, chan_name_formatted, chan_name, chan_url, protocol, str(schedule_id), name, cat_id, 2, thumb_path, "", len(rec)) xbmc.executebuiltin("Container.SetViewMode(51)")
if cat_id == "200" : url = grab_vk_stream(name, url) if cat_id == "201" or cat_id == "202" : url = grab_fu_stream(name, url) STREAM(name, iconimage, url, protocol, sch_ch_id, ch_id) else: #stop_spsc() xbmc.executebuiltin( "ActivateWindow(busydialog)" ) if cat_id == "200" : url = grab_vk_stream(name, url) if cat_id == "201" or cat_id == "202" : url = grab_fu_stream(name, url) STREAM(name, iconimage, url, protocol, sch_ch_id, ch_id) elif mode==3: #refresh schedule if sch_ch_id != None: grab_schedule(sch_ch_id, name, force=True) xbmc.executebuiltin('Container.Refresh()') elif mode==4: #refresh channel list CAT_LIST(force=True) xbmc.executebuiltin('Container.Refresh()') elif mode==5: #refresh all schedules CHANNEL_LIST(name, cat_id, schedule=True) xbmc.executebuiltin('Container.Refresh()') #elif mode==6: #EPG # addon_log('epg'); # mydisplay = EPG("custom_help.xml",ADDON_PATH) # mydisplay.doModal() # del mydisplay db_connection.close()
def CHANNEL_LIST(name, cat_id, schedule=False): addon_log(name) try: db_cursor.execute( 'SELECT id, name, country, language, status, \ video_resolution, video_aspect, audio_codec, video_codec, \ address, thumbnail, protocol, \ schedule_id \ FROM channels \ WHERE id_cat = ?' , \ (cat_id,) ) rec = db_cursor.fetchall() except Exception as inst: addon_log(inst) xbmcgui.Dialog().ok(addon.getLocalizedString(30300), addon.getLocalizedString(30301), str(inst)) #Cannot parse channel list ! if len(rec) > 0: for id, name, country, language, status, \ video_resolution, video_aspect, audio_codec, video_codec, \ address, thumbnail, protocol, \ schedule_id in rec: #filter by country and language #if( (((country != '') and (addon.getSetting('country_'+country) == 'true')) or #((country == '') and (addon.getSetting('country_none') == 'true')) ) and #(((language != '') and (addon.getSetting('lang_'+language) == 'true')) or #((language == '') and (addon.getSetting('lang_none') == 'true')) ) #): chan_name = name chan_url = address.strip() protocol = protocol.strip() if protocol == 'sop': protocol_color = '[COLOR lightgreen]' + protocol + '[/COLOR]' else: protocol_color = '[COLOR yellow]' + protocol + '[/COLOR]' chan_thumb = thumbnail.strip() #addon_log(chan_thumb) chan_status = status if (((SETTINGS.SHOW_OFFLINE_CH == 'true') and (int(chan_status) == 1)) or (int(chan_status) != 1)): #if we show or not offline channels based on settings logo_name = chan_name.replace(' ', '').lower() logo_name = logo_name.encode('utf8') chan_name_formatted = "[B][COLOR blue]" + chan_name + "[/COLOR][/B]" chan_name_formatted += " (" + protocol_color if (video_codec != ''): chan_name_formatted += " " + video_codec chan_name_formatted += ")" if int(chan_status) == 1: chan_name_formatted += " [COLOR red]" + addon.getLocalizedString( 30063) + "[/COLOR]" #Offline thumb_path = "" if chan_thumb and chan_thumb != "": fileName, fileExtension = os.path.splitext(chan_thumb) fileName = fileName.split("/")[-1] if fileName != "": #thumb_path=os.path.join(ADDON_PATH,"logos",fileName+fileExtension) fileExtension = fileExtension.encode('utf8') thumb_path = os.path.join(SETTINGS.ADDON_PATH, "logos", logo_name + fileExtension) if not os.path.isfile(thumb_path): if fileName != "": try: Downloader( chan_thumb, thumb_path, fileName + fileExtension, addon.getLocalizedString( 30055)) #Downloading Channel Logo except Exception as inst: pass #schedule if (schedule_id != 0) and \ (schedule or (addon.getSetting('schedule_ch_list') == 'true')) \ and (SETTINGS.DISABLE_SCHEDULE != 'true'): if (schedule): #update all by context menu update_all = True elif (addon.getSetting('schedule_ch_list') == 'true' ): #update all when we display channel list update_all = False grab_schedule(schedule_id, chan_name, update_all=update_all) if (SETTINGS.DISABLE_SCHEDULE != 'true') and (int(cat_id) < 200): schedule_txt = load_schedule(chan_name) chan_name_formatted += " " + schedule_txt addLink(id, chan_name_formatted, chan_name, chan_url, protocol, str(schedule_id), name, cat_id, 2, thumb_path, "", len(rec)) xbmc.executebuiltin("Container.SetViewMode(51)")
if cat_id == "200": url = grab_vk_stream(name, url) if cat_id == "201" or cat_id == "202": url = grab_fu_stream(name, url) STREAM(name, iconimage, url, protocol, sch_ch_id, ch_id) else: #stop_spsc() xbmc.executebuiltin("ActivateWindow(busydialog)") if cat_id == "200": url = grab_vk_stream(name, url) if cat_id == "201" or cat_id == "202": url = grab_fu_stream(name, url) STREAM(name, iconimage, url, protocol, sch_ch_id, ch_id) elif mode == 3: #refresh schedule if sch_ch_id != None: grab_schedule(sch_ch_id, name, force=True) xbmc.executebuiltin('Container.Refresh()') elif mode == 4: #refresh channel list CAT_LIST(force=True) xbmc.executebuiltin('Container.Refresh()') elif mode == 5: #refresh all schedules CHANNEL_LIST(name, cat_id, schedule=True) xbmc.executebuiltin('Container.Refresh()') #elif mode==6: #EPG # addon_log('epg'); # mydisplay = EPG("custom_help.xml",ADDON_PATH) # mydisplay.doModal() # del mydisplay db_connection.close()
def STREAM(name, iconimage, url, sch_ch_id): if (url == None): try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass return False if (sch_ch_id != None) and (DISABLE_SCHEDULE != 'true'): grab_schedule(sch_ch_id, name) #addon_log(name) #addon_log(iconimage) if not iconimage or iconimage == "": iconimage = "DefaultVideo.png" listitem = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage) listitem.setLabel(name) listitem.setInfo('video', {'Title': name}) if url[0:6] == "sop://": #play sopcast stream try: cmd = [ SPSC, url, str(LOCAL_PORT), str(VIDEO_PORT), "> /dev/null &" ] if (ARM): cmd = QEMU_SPSC + cmd #addon_log(cmd) spsc = subprocess.Popen(cmd, shell=False, bufsize=BUFER_SIZE, stdin=None, stdout=None, stderr=None) xbmc.sleep(int(addon.getSetting('wait_time'))) res = False counter = 50 #while counter > 0 and os.path.exists("/proc/"+str(spsc.pid)): while counter > 0 and sop_pid_exists(spsc.pid): xbmc.executebuiltin("ActivateWindow(busydialog)") xbmc.sleep(400) counter -= 1 try: addon_log(LOCAL_URL) urllib2.urlopen(LOCAL_URL) counter = 0 res = sop_sleep(200, spsc.pid) break except: pass addon_log(res) if res: player = streamplayer(xbmc.PLAYER_CORE_AUTO, spsc_pid=spsc.pid, name=name) addon.setSetting('player_status', 'play') player.play(LOCAL_URL, listitem) keep_allive(player) #watching sop process and restarting the player if it dies #watch_sop_thread(spsc.pid, name, listitem) #elif not os.path.exists("/proc/"+str(spsc.pid)): elif not sop_pid_exists(spsc.pid): try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass try: urllib2.urlopen("http://www.google.com") if NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30057), "", 1)) #Channel is offline except: if NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30058), "", 1)) #Network is offline elif NOTIFY_OFFLINE == "true": try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30059), "", 1)) #Channel initialization failed try: stop_spsc(spsc.pid) except: pass except Exception as inst: xbmcgui.Dialog().ok(addon.getLocalizedString(30060), str(type(inst)), str(inst), "") addon_log(str(inst)) try: stop_spsc() except: pass try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass else: #play direct stream try: player = streamplayer(xbmc.PLAYER_CORE_AUTO, name=name) addon.setSetting('player_status', 'play') player.play(url, listitem) keep_allive(player) except Exception as inst: xbmcgui.Dialog().ok(addon.getLocalizedString(30060), str(type(inst)), str(inst), "") try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass
def STREAM(name, iconimage, url, sch_ch_id): if(url == None): try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass return False if (sch_ch_id != None) and (DISABLE_SCHEDULE != 'true'): grab_schedule(sch_ch_id, name) #addon_log(name) #addon_log(iconimage) if not iconimage or iconimage == "": iconimage="DefaultVideo.png" listitem = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage) listitem.setLabel(name) listitem.setInfo('video', {'Title': name}) if url[0:6]=="sop://": #play sopcast stream try: cmd = [SPSC, url, str(LOCAL_PORT), str(VIDEO_PORT), "> /dev/null &"] if(ARM): cmd = QEMU_SPSC + cmd #addon_log(cmd) spsc = subprocess.Popen(cmd, shell=False, bufsize=BUFER_SIZE, stdin=None, stdout=None, stderr=None) xbmc.sleep(int(addon.getSetting('wait_time'))) res=False counter=50 #while counter > 0 and os.path.exists("/proc/"+str(spsc.pid)): while counter > 0 and sop_pid_exists(spsc.pid): xbmc.executebuiltin( "ActivateWindow(busydialog)" ) xbmc.sleep(400) counter -= 1 try: addon_log(LOCAL_URL); urllib2.urlopen(LOCAL_URL) counter=0 res=sop_sleep(200 , spsc.pid) break except:pass addon_log(res) if res: player = streamplayer(xbmc.PLAYER_CORE_AUTO , spsc_pid=spsc.pid, name=name) addon.setSetting('player_status', 'play') player.play(LOCAL_URL, listitem) keep_allive(player) #watching sop process and restarting the player if it dies #watch_sop_thread(spsc.pid, name, listitem) #elif not os.path.exists("/proc/"+str(spsc.pid)): elif not sop_pid_exists(spsc.pid): try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass try: urllib2.urlopen("http://www.google.com") if NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30057), "",1)) #Channel is offline except: if NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30058), "",1)) #Network is offline elif NOTIFY_OFFLINE == "true": try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30059), "", 1)) #Channel initialization failed try: stop_spsc(spsc.pid) except: pass except Exception as inst: xbmcgui.Dialog().ok(addon.getLocalizedString(30060), str(type(inst)),str(inst),"") addon_log(str(inst)) try: stop_spsc() except: pass try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass else: #play direct stream try: player = streamplayer(xbmc.PLAYER_CORE_AUTO, name=name) addon.setSetting('player_status', 'play') player.play(url, listitem) keep_allive(player) except Exception as inst: xbmcgui.Dialog().ok(addon.getLocalizedString(30060), str(type(inst)),str(inst),"") try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass