def keep_allive(player): xbmc.sleep(500) #KEEP SCRIPT ALLIVE #while player.isPlaying(): while (addon.getSetting('player_status')=='play'): addon_log('ALLIVE') xbmc.sleep(500) #xbmc.sleep(1000) try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass
def engine_connect(self): try: self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((SETTINGS.ACE_HOST, SETTINGS.ACE_PORT)) except Exception as inst: addon_log(inst) try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass DEBUG = addon.getSetting('debug') if DEBUG == 'true': xbmc.executebuiltin("Notification(%s,%s,%i)" % (str(type(inst)), str(inst), 5)) return False self.send("HELLOBG version=3") self.ace_read()
def keep_allive(player): xbmc.sleep(500) #KEEP SCRIPT ALLIVE #while player.isPlaying(): while (addon.getSetting('player_status') == 'play'): addon_log('ALLIVE') xbmc.sleep(500) #xbmc.sleep(1000) try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass
def sop_sleep(self, time): counter=0 increment=200 #path="/proc/%s" % str(spsc_pid) #addon_log('proc exists') #addon_log(os.path.exists(path)) try: #while counter < time and spsc_pid>0 and not xbmc.abortRequested and os.path.exists(path): while counter < time and self.spsc_pid>0 and not xbmc.abortRequested and self.sop_pid_exists(): counter += increment xbmc.sleep(increment) except Exception as inst: addon_log(inst) DEBUG = addon.getSetting('debug') if DEBUG == 'true': xbmc.executebuiltin("Notification(%s,%s,%i)" % (str(type(inst)), str(inst), 5)) return True if counter < time: return False else: return True
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)")
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)")
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
import xbmc, xbmcgui, xbmcplugin, xbmcaddon import sys, os, os.path, subprocess, stat import urllib, urllib2, socket, re import json, sqlite3 from urlparse import urlparse from posixpath import basename, dirname import time from datetime import datetime, timedelta from glob import addon_log, addon, ADDON_PATH, ADDON_VERSION, Downloader DISABLE_SCHEDULE = addon.getSetting('disable_schedule') if DISABLE_SCHEDULE != 'true': from schedule import grab_schedule, load_schedule, load_active_event from play_vk_com import grab_vk_stream from play_fastupload_ro import grab_fu_stream try: try: raise import xml.etree.cElementTree as ElementTree except: from xml.etree import ElementTree except: try: from xml.etree.ElementTree import Element from xml.etree.ElementTree import SubElement from elementtree import ElementTree except: dlg = xbmcgui.Dialog()
def start( self ): try: if(SETTINGS.ARM): self.spsc = subprocess.Popen(self.cmd, shell=False, bufsize=SETTINGS.BUFER_SIZE, stdin=None, stdout=None, stderr=None) else: env = os.environ env['LD_LIBRARY_PATH'] = SETTINGS.SPSC_LIB self.spsc = subprocess.Popen(self.cmd, shell=False, bufsize=SETTINGS.BUFER_SIZE, stdin=None, stdout=None, stderr=None, env=env) self.spsc_pid = self.spsc.pid 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 self.sop_pid_exists(): xbmc.executebuiltin( "ActivateWindow(busydialog)" ) xbmc.sleep(400) counter -= 1 try: addon_log(SETTINGS.LOCAL_URL); urllib2.urlopen(SETTINGS.LOCAL_URL) counter=0 res=self.sop_sleep(200) break except Exception as inst: addon_log(inst) addon_log(res) offline = None if res: #START PLAY self.player.callback = self.stop_spsc self.player.play(SETTINGS.LOCAL_URL, self.listitem) elif not self.sop_pid_exists(): try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass try: urllib2.urlopen(SETTINGS.TEST_URL) if SETTINGS.NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30057), "",1)) #Channel is offline offline = True except: if SETTINGS.NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30058), "",1)) #Network is offline elif SETTINGS.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 offline = True try: self.stop_spsc() except: pass if offline: mark = mark_stream(ch_id=self.player.ch_id) mark.mark_offline() 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
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
class SETTINGS(object): ADDON_PATH = addon.getAddonInfo('path') LANGUAGE = 'en' CHAN_LIST_URL = addon.getSetting('chan_list_url') parse_object = urlparse(CHAN_LIST_URL) f_name = basename(parse_object[2]) #file name of the channel list CHAN_LIST = os.path.join(ADDON_PATH, f_name) #full path of the channel list CHAN_LIST_EXPIRE = int(addon.getSetting('chan_list_expire')) * 60 * 60 CHANNELS_DB = os.path.join(ADDON_PATH, 'channels.sqlite') #DISABLE_SCHEDULE = addon.getSetting('disable_schedule') SHOW_OFFLINE_CH = addon.getSetting('show_offline_ch') NOTIFY_OFFLINE = "true" DISABLE_SCHEDULE = addon.getSetting('disable_schedule') SCHEDULE_PATH = os.path.join(ADDON_PATH, 'schedule.sqlite') ########################################## sopcast SPSC_BINARY = "sp-sc-auth" #raspberry pi QEMU = "qemu-i386" #for raspberry pi to issue kill command ARM = False if (os.uname()[4][:3] == 'arm'): ARM = True if ARM == False: SPSC = os.path.join(ADDON_PATH, 'bin/linux_x86/sopcast', SPSC_BINARY) SPSC_LIB = os.path.join(ADDON_PATH, 'bin/linux_x86/sopcast') #make executables is_exe(SPSC) elif ARM == True: SOPCAST_ARM_PATH = addon.getSetting('sopcast_arm_path') if (SOPCAST_ARM_PATH == ''): SOPCAST_ARM_PATH = os.path.join(ADDON_PATH, 'bin/arm/sopcast') #make executables is_exe(os.path.join(SOPCAST_ARM_PATH, QEMU)) is_exe(os.path.join(SOPCAST_ARM_PATH, "lib/ld-linux.so.2")) QEMU_SPSC = [ os.path.join(SOPCAST_ARM_PATH, QEMU), os.path.join(SOPCAST_ARM_PATH, "lib/ld-linux.so.2"), "--library-path", os.path.join(SOPCAST_ARM_PATH, "lib") ] SPSC = os.path.join(SOPCAST_ARM_PATH, SPSC_BINARY) #/storage/sopcast/qemu-i386 /storage/sopcast/lib/ld-linux.so.2 --library-path /storage/sopcast/lib /storage/sopcast/sp-sc-auth 2>&- $1 $2 $3 LOCAL_PORT = addon.getSetting('local_port') VIDEO_PORT = addon.getSetting('video_port') BUFER_SIZE = int(addon.getSetting('buffer_size')) LOCAL_URL = "http://localhost:" + str(VIDEO_PORT) + "/?" TEST_URL = "http://www.google.com" ########################################################## ########################################################## acestream #PRODUCT_KEY='kjYX790gTytRaXV04IvC-xZH3A18sj5b1Tf3I-J5XVS1xsj-j0797KwxxLpBl26HPvWMm' #free PRODUCT_KEY = 'n51LvQoTlJzNGaFxseRK-uvnvX-sD4Vm5Axwmc4UcoD-jruxmKsuJaH0eVgE' #aceproxy ACE_HOST = addon.getSetting('ace_host') ACE_PORT = int(addon.getSetting('ace_port'))