def onAVStarted(self): self._up_next = None self._callback = None self._playlist = None if self.isPlayingVideo(): self._playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) else: self._playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC) up_next = get_kodi_string('_slyguy_play_next') if up_next: set_kodi_string('_slyguy_play_next') up_next = json.loads(up_next) if up_next['playing_file'] == self.getPlayingFile(): if up_next['next_file']: self._playlist.remove(up_next['next_file']) self._playlist.add(up_next['next_file'], index=self._playlist.getposition() + 1) if up_next['time']: self._up_next = up_next callback = get_kodi_string('_slyguy_play_callback') if callback: set_kodi_string('_slyguy_play_callback') callback = json.loads(callback) if callback['playing_file'] == self.getPlayingFile( ) and callback['callback']: self._callback = callback if self._up_next or self._callback: self._thread = Thread(target=self.playback, args=(self.getPlayingFile(), )) self._thread.start()
def onAVStarted(self): self._callback = None self._play_skips = [] self._playing_file = self.getPlayingFile() if self.isPlayingVideo(): self._playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) else: self._playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC) play_skips = [] up_next = get_kodi_string('_slyguy_play_next') if up_next: set_kodi_string('_slyguy_play_next') up_next = json.loads(up_next) if up_next['playing_file'] == self._playing_file: if up_next['next_file']: self._playlist.remove(up_next['next_file']) self._playlist.add(up_next['next_file'], index=self._playlist.getposition() + 1) #legacy if up_next['time']: play_skips.append({'from': up_next['time'], 'to': 0}) _skips = get_kodi_string('_slyguy_play_skips') if _skips: set_kodi_string('_slyguy_play_skips') data = json.loads(_skips) if data['playing_file'] == self._playing_file: play_skips.extend(data['skips']) for skip in play_skips: if not skip.get('to'): skip['to'] = int(self.getTotalTime()) + 1 else: if skip['to'] < 0: self.seekTime(self.getTotalTime() + skip['to'] - 3) continue skip['to'] -= 3 if not skip.get('from'): continue self._play_skips.append(skip) callback = get_kodi_string('_slyguy_play_callback') if callback: set_kodi_string('_slyguy_play_callback') callback = json.loads(callback) if callback['playing_file'] == self._playing_file and callback[ 'callback']: self._callback = callback if self._callback or self._play_skips: self._thread = Thread(target=self.playback) self._thread.start()
def onAVStarted(self): self._up_next = None self._callback = None self._playlist = None if self.isPlayingVideo(): self._playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) else: self._playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC) up_next = get_kodi_string('_slyguy_play_next') if up_next: set_kodi_string('_slyguy_play_next') up_next = json.loads(up_next) if up_next['playing_file'] == self.getPlayingFile(): if up_next['next_file']: self._playlist.remove(up_next['next_file']) self._playlist.add(up_next['next_file'], index=self._playlist.getposition()+1) if up_next['time']: self._up_next = up_next callback = get_kodi_string('_slyguy_play_callback') if callback: set_kodi_string('_slyguy_play_callback') callback = json.loads(callback) if callback['playing_file'] == self.getPlayingFile() and callback['callback']: self._callback = callback if self._up_next or self._callback: self._thread = Thread(target=self.playback, args=(self.getPlayingFile(),)) self._thread.start() # def onPlayBackEnded(self): # vid_playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) # music_playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC) # position = vid_playlist.getposition()+1 # if (vid_playlist.size() <= 1 or vid_playlist.size() == position) and (music_playlist.size() <= 1 or music_playlist.size() == position): # self.onPlayBackStopped() # def onPlayBackStopped(self): # set_kodi_string('_slyguy_last_quality') # def onPlayBackStarted(self): # pass # def onPlayBackPaused(self): # print("AV PAUSED") # def onPlayBackResumed(self): # print("AV RESUME") # def onPlayBackError(self): # self.onPlayBackStopped()
def _get_url(self, method): url = self.path.lstrip('/').strip('\\') log.debug('{} IN: {}'.format(method, url)) self._headers = {} for header in self.headers: if header.lower() not in REMOVE_IN_HEADERS: self._headers[header.lower()] = self.headers[header] length = int(self._headers.get('content-length', 0)) self._post_data = self.rfile.read(length) if length else None self._session = PROXY_GLOBAL['session'] try: proxy_data = json.loads(get_kodi_string('_slyguy_quality')) if self._session.get('session_id') != proxy_data['session_id']: self._session = {} self._session.update(proxy_data) set_kodi_string('_slyguy_quality', '') except: pass PROXY_GLOBAL['session'] = self._session url = self._session.get('path_subs', {}).get(url) or url if url.lower().startswith('plugin'): url = self._update_urls(url, self._plugin_request(url)) return url
def onAVStarted(self): try: play_data = json.loads(get_kodi_string('_slyguy_play_data')) except: return set_kodi_string('_slyguy_play_data') self._callback = None self._play_skips = [] self._playing_file = self.getPlayingFile() if play_data['playing_file'] != self._playing_file: return if self.isPlayingVideo(): self._playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) else: self._playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC) play_skips = play_data['skips'] if play_data['next']['next_file']: self._playlist.remove(play_data['next']['next_file']) self._playlist.add(play_data['next']['next_file'], index=self._playlist.getposition() + 1) #legacy if play_data['next']['time']: play_skips.append({'from': play_data['next']['time'], 'to': 0}) for skip in play_skips: if not skip.get('to'): skip['to'] = int(self.getTotalTime()) + 1 else: if skip['to'] < 0: self.seekTime(self.getTotalTime() + skip['to'] - 3) continue skip['to'] -= 3 if not skip.get('from'): continue self._play_skips.append(skip) ## Workaround for suspect IA bug: https://github.com/xbmc/inputstream.adaptive/issues/821 # if int(self.getTime()) < 0: # self.seekTime(0) if play_data['callback']['callback']: self._callback = play_data['callback'] if self._callback or self._play_skips: self._thread = Thread(target=self.playback) self._thread.start()
def _reload_service(): database.close() with gui.progress(_.RELOAD_SERVICE, percent=100) as progress: set_kodi_string('_gpio_reload', '1') for i in range(5): xbmc.sleep(1000) if not get_kodi_string('_gpio_reload'): break
def start(): http = HTTP() monitor = xbmc.Monitor() restart_queued = False boot_merge = settings.getBool('boot_merge', False) set_kodi_string('_iptv_merge_force_run') while not monitor.waitForAbort(1): http.start() if settings.getBool('http_api', False) else http.stop() forced = get_kodi_string('_iptv_merge_force_run') or 0 if forced or boot_merge or (settings.getBool('auto_merge', True) and time.time() - userdata.get('last_run', 0) > settings.getInt('reload_time_hours', 12) * 3600): set_kodi_string('_iptv_merge_force_run', '1') url = router.url_for('run_merge', forced=int(forced)) dirs, files = xbmcvfs.listdir(url) result, msg = int(files[0][0]), unquote_plus(files[0][1:]) if result: restart_queued = True userdata.set('last_run', int(time.time())) set_kodi_string('_iptv_merge_force_run') if restart_queued and settings.getBool('restart_pvr', False): if forced: progress = gui.progressbg(heading='Reloading IPTV Simple Client') if KODI_VERSION > 18: restart_queued = False try: xbmcaddon.Addon(IPTV_SIMPLE_ID).setSetting('m3uPathType', '0') except Exception as e: pass elif forced or (not xbmc.getCondVisibility('Pvr.IsPlayingTv') and not xbmc.getCondVisibility('Pvr.IsPlayingRadio')): restart_queued = False kodi_rpc('Addons.SetAddonEnabled', {'addonid': IPTV_SIMPLE_ID, 'enabled': False}) wait_delay = 4 for i in range(wait_delay): if monitor.waitForAbort(1): break if forced: progress.update((i+1)*int(100/wait_delay)) kodi_rpc('Addons.SetAddonEnabled', {'addonid': IPTV_SIMPLE_ID, 'enabled': True}) if forced: progress.update(100) progress.close() boot_merge = False http.stop()
def _get_url(self): url = self.path.lstrip('/').strip('\\') self._headers = {} self._plugin_headers = {} for header in self.headers: if header.lower() not in REMOVE_IN_HEADERS: self._headers[header.lower()] = self.headers[header] self._headers['accept-encoding'] = 'gzip, deflate, br' length = int(self._headers.get('content-length', 0)) self._post_data = self.rfile.read(length) if length else None self._session = PROXY_GLOBAL['session'] try: proxy_data = json.loads(get_kodi_string('_slyguy_quality')) if self._session.get('session_id') != proxy_data['session_id']: self._session = {} self._session.update(proxy_data) set_kodi_string('_slyguy_quality', '') except: pass PROXY_GLOBAL['session'] = self._session url = self._session.get('path_subs', {}).get(url) or url if url.lower().startswith('plugin'): new_url = self._plugin_request(url) if url == self._session.get('license_url'): self._session['license_url'] = new_url url = new_url return url
def merge(**kwargs): if get_kodi_string('_iptv_merge_force_run'): raise PluginError(_.MERGE_IN_PROGRESS) else: set_kodi_string('_iptv_merge_force_run', '1')
def service(): def setup_buttons(): log.debug('Setting up buttons') try: database.connect() Button.update(status=Button.Status.INACTIVE, error=None).where(Button.enabled == True).execute() Button.update(status=Button.Status.DISABLED, error=None).where(Button.enabled == False).execute() btns = list(Button.select().where(Button.enabled == True)) buttons = [] for btn in btns: if not btn.has_callbacks(): continue try: button = gpiozero.Button(btn.pin, pull_up=btn.pull_up, bounce_time=btn.bounce_time or None, hold_time=btn.hold_time, hold_repeat=btn.hold_repeat) if btn.when_pressed: button.when_pressed = lambda function=btn.when_pressed: callback( function) if btn.when_released: button.when_released = lambda function=btn.when_released: callback( function) if btn.when_held: button.when_held = lambda function=btn.when_held: callback( function) except Exception as e: log.exception(e) btn.status = Button.Status.ERROR btn.error = e else: btn.status = Button.Status.ACTIVE buttons.append(button) btn.save() return buttons except Exception as e: log.debug(e) return [] finally: database.close() monitor = xbmc.Monitor() while not monitor.abortRequested(): buttons = setup_buttons() set_kodi_string('_gpio_reload') while not monitor.abortRequested(): if not monitor.waitForAbort(1) and get_kodi_string('_gpio_reload'): break for button in buttons: button.close() gpiozero.Device.pin_factory.close()