def onPlayBackStopped(self): addon_log('----------------------->STOP') addon_log(self.stream_online) #xbmc.executebuiltin('Container.Refresh()') addon_log(self.callback) try: if (self.callback != None): self.callback() except: pass #online notif if (self.stream_online != True): mark = mark_stream(ch_id=self.ch_id) mark.mark_offline() self.stream_online = False xbmc.executebuiltin("Dialog.Close(busydialog)") if SETTINGS.NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30057), "", 1)) #Channel is offline #addon.setSetting('player_status', 'stop') self.player_status = 'stop'
def onPlayBackEnded(self): addon_log('----------------------->END') addon_log(self.stream_online); #xbmc.executebuiltin('Container.Refresh()') try: if(self.callback != None): self.callback() except: pass if(self.stream_online!=True) : #online notif mark = mark_stream(ch_id=self.ch_id) mark.mark_offline() self.stream_online = False #addon.setSetting('player_status', 'end') self.player_status = 'end';
def onPlayBackStopped(self): addon_log('----------------------->STOP') addon_log(self.stream_online); #xbmc.executebuiltin('Container.Refresh()') addon_log(self.callback) try: if(self.callback != None): self.callback() except: pass #online notif if(self.stream_online!=True) : mark = mark_stream(ch_id=self.ch_id) mark.mark_offline() self.stream_online = False xbmc.executebuiltin( "Dialog.Close(busydialog)" ) if SETTINGS.NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30057), "",1)) #Channel is offline #addon.setSetting('player_status', 'stop') self.player_status = 'stop';
def onPlayBackStarted(self): addon_log('START') addon_log(xbmc.getInfoLabel('VideoPlayer.VideoCodec')) addon_log(xbmc.getInfoLabel('VideoPlayer.AudioCodec')) ## this will kill the sopcast if we changed the media #if xbmc.Player(xbmc.PLAYER_CORE_AUTO).getPlayingFile() != SETTINGS.LOCAL_URL: # try: stop_spsc(self.spsc_pid) # except: pass xbmc.executebuiltin( "Dialog.Close(busydialog)" ) #online notif mark = mark_stream(ch_id=self.ch_id) mark.mark_online() self.stream_online = True if SETTINGS.DISABLE_SCHEDULE!='true': #display schedule active event active_event = load_active_event(self.name) if active_event: xbmc.executebuiltin("Notification(%s,%s,%i)" % (active_event, "", 10000))
def onPlayBackStarted(self): addon_log('START') addon_log(xbmc.getInfoLabel('VideoPlayer.VideoCodec')) addon_log(xbmc.getInfoLabel('VideoPlayer.AudioCodec')) ## this will kill the sopcast if we changed the media #if xbmc.Player(xbmc.PLAYER_CORE_AUTO).getPlayingFile() != SETTINGS.LOCAL_URL: # try: stop_spsc(self.spsc_pid) # except: pass xbmc.executebuiltin("Dialog.Close(busydialog)") #online notif mark = mark_stream(ch_id=self.ch_id) mark.mark_online() self.stream_online = True if SETTINGS.DISABLE_SCHEDULE != 'true': #display schedule active event active_event = load_active_event(self.name) active_event = active_event.encode('utf8') if active_event: xbmc.executebuiltin("Notification(%s,%s,%i)" % (active_event, "", 10000))
def ace_read(self): for line in self.read_lines(self.sock): if ((self.start_time!=None) and ((time.time() - self.start_time) > self.timeout)): self.shutdown() xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30057), "", 10000)) addon_log(line) if line.startswith("HELLOTS"): self.auth(line) elif line.startswith("AUTH"): self.request_id = self.ch_open() elif line.startswith("LOADRESP"): response = line.split()[2:] response = ' '.join(response) response = json.loads(response) infohash = response.get('infohash') #self.sock.send('GETADURL width = 1328 height = 474 infohash = ' + infohash + ' action = load'+"\r\n") #self.sock.send('GETADURL width = 1328 height = 474 infohash = ' + infohash + ' action = pause'+"\r\n") if response.get('status') == 100: addon_log("LOADASYNC returned error with message: %s" % response.get('message')) else: #self.filename = urllib2.unquote(response.get('files')[0][0]) self.filename = urllib.unquote(response.get('files')[0][0].encode('ascii')).decode('utf-8') addon_log(self.filename) self.ch_start() elif line.startswith("START"): self.start_time = None try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass try: player_url = line.split()[1] addon_log (player_url) self.player.callback = self.shutdown self.listitem.setInfo('video', {'Title': self.filename}) self.player.play(player_url, self.listitem) self.player_started = True except IndexError as e: player_url = None #p = re.compile('(http://)[\w\W]+?(\:[0-9]+/)') #player_url = url #player_url = p.sub(r"\1" + self.ace_host + r"\2", url) #addon_log (player_url) #self.player.play(player_url, self.listitem) #self.sock.send("PAUSE"+"\r\n") #self.sock.send("RESUME"+"\r\n") #self.sock.send("STOP"+"\r\n") #self.sock.send("SHUTDOWN"+"\r\n") elif line.startswith("SHUTDOWN"): self.sock.close() #offline notif #if player was not started #addon_log('player_started='); #addon_log(self.player_started); if(self.player_started != True): mark = mark_stream(ch_id=self.player.ch_id) mark.mark_offline() break #INFO 1;Cannot find active peers elif line.startswith("INFO"): tmp = line.split(';') info_status = tmp[0].split()[1] if(info_status == '1'): #INFO 1;Cannot find active peers info_msg = tmp[1] self.shutdown() xbmc.executebuiltin("Notification(%s,%s,%i)" % (info_msg, "", 10000)) elif line.startswith("EVENT"): #print line pass
def ace_read(self): for line in self.read_lines(self.sock): if ((self.start_time != None) and ((time.time() - self.start_time) > self.timeout)): self.shutdown() xbmc.executebuiltin( "Notification(%s,%s,%i)" % (addon.getLocalizedString(30057), "", 10000)) addon_log(line) if line.startswith("HELLOTS"): self.auth(line) elif line.startswith("AUTH"): self.request_id = self.ch_open() elif line.startswith("LOADRESP"): response = line.split()[2:] response = ' '.join(response) response = json.loads(response) infohash = response.get('infohash') #self.sock.send('GETADURL width = 1328 height = 474 infohash = ' + infohash + ' action = load'+"\r\n") #self.sock.send('GETADURL width = 1328 height = 474 infohash = ' + infohash + ' action = pause'+"\r\n") if response.get('status') == 100: addon_log("LOADASYNC returned error with message: %s" % response.get('message')) else: #self.filename = urllib2.unquote(response.get('files')[0][0]) self.filename = urllib.unquote( response.get('files')[0][0].encode('ascii')).decode( 'utf-8') addon_log(self.filename) self.ch_start() elif line.startswith("START"): self.start_time = None try: xbmc.executebuiltin("Dialog.Close(all,true)") except: pass try: player_url = line.split()[1] addon_log(player_url) self.player.callback = self.shutdown self.listitem.setInfo('video', {'Title': self.filename}) self.player.play(player_url, self.listitem) self.player_started = True except IndexError as e: player_url = None #p = re.compile('(http://)[\w\W]+?(\:[0-9]+/)') #player_url = url #player_url = p.sub(r"\1" + self.ace_host + r"\2", url) #addon_log (player_url) #self.player.play(player_url, self.listitem) #self.sock.send("PAUSE"+"\r\n") #self.sock.send("RESUME"+"\r\n") #self.sock.send("STOP"+"\r\n") #self.sock.send("SHUTDOWN"+"\r\n") elif line.startswith("SHUTDOWN"): self.sock.close() #offline notif #if player was not started #addon_log('player_started='); #addon_log(self.player_started); if (self.player_started != True): mark = mark_stream(ch_id=self.player.ch_id) mark.mark_offline() break #INFO 1;Cannot find active peers elif line.startswith("INFO"): tmp = line.split(';') info_status = tmp[0].split()[1] if (info_status == '1'): #INFO 1;Cannot find active peers info_msg = tmp[1] self.shutdown() xbmc.executebuiltin("Notification(%s,%s,%i)" % (info_msg, "", 10000)) elif line.startswith("EVENT"): #print line pass
def start(self): if xbmc.getCondVisibility('System.Platform.Android'): xbmc.executebuiltin( 'XBMC.StartAndroidActivity("com.devaward.soptohttp","android.intent.action.VIEW","",' + self.sopurl + ')') else: 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 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