def follow_creator(slug, **kwargs): with gui.progress(background=True, percent=90): creator = _get_creator(slug) api.follow_creator(creator['_id']) gui.notification(_(_.FOLLOWED_CREATOR, creator=creator['title']), icon=creator['avatar'])
def _device_link(): start = time.time() data = api.device_code() monitor = xbmc.Monitor() poll_time = int(data['retryInterval'] / 1000) max_time = int(data['retryDuration'] / 1000) device_token = data['deviceToken'] code = data['activationCode'] with gui.progress(_(_.DEVICE_LINK_STEPS, url=config.device_link_url, code=code), heading=_.DEVICE_LINK) as progress: while (time.time() - start) < max_time: for i in range(poll_time): if progress.iscanceled() or monitor.waitForAbort(1): return progress.update(int(((time.time() - start) / max_time) * 100)) result = api.device_login(code, device_token) if result: return True elif result == -1: return False
def install_service(**kwargs): with gui.progress(_.INSTALL_SERVICE, percent=100) as progress: restart_required = gpio.install() if restart_required and gui.yes_no(_.RESTART_REQUIRED): plugin.reboot() gui.refresh()
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 _device_link(): monitor = xbmc.Monitor() timeout = 600 with api.device_login() as login_progress: with gui.progress(_(_.DEVICE_LINK_STEPS, code=login_progress.code), heading=_.DEVICE_LINK) as progress: for i in range(timeout): if progress.iscanceled() or not login_progress.is_alive() or monitor.waitForAbort(1): break progress.update(int((i / float(timeout)) * 100)) login_progress.stop() return login_progress.result
def _device_link(): monitor = xbmc.Monitor() serial, code = api.device_code() timeout = 600 with gui.progress(_(_.DEVICE_LINK_STEPS, code=code), heading=_.DEVICE_LINK) as progress: for i in range(timeout): if progress.iscanceled() or monitor.waitForAbort(1): return progress.update(int((i / float(timeout)) * 100)) if i % 5 == 0 and api.device_login(serial, code): return True
def _device_link(): start = time.time() data = api.device_code() monitor = xbmc.Monitor() #qr_code_url = data['ImagePath'] with gui.progress(_(_.DEVICE_LINK_STEPS, code=data['Code']), heading=_.DEVICE_LINK) as progress: while (time.time() - start) < data['ExpireDate']: for i in range(5): if progress.iscanceled() or monitor.waitForAbort(1): return progress.update( int(((time.time() - start) / data['ExpireDate']) * 100)) if api.device_login(data['Code']): return True
def _device_link(): start = time.time() data = api.device_code() monitor = xbmc.Monitor() with gui.progress(_(_.DEVICE_LINK_STEPS, url=data['verification_uri'], code=data['user_code']), heading=_.DEVICE_LINK) as progress: while (time.time() - start) < data['expires_in']: for i in range(data['interval']): if progress.iscanceled() or monitor.waitForAbort(1): return progress.update( int(((time.time() - start) / data['expires_in']) * 100)) if api.device_login(data['device_code']): return True
def _setup(): addon = get_addon(IPTV_SIMPLE_ID, required=True, install=True) with gui.progress(_.SETTING_UP_IPTV) as progress: kodi_rpc('Addons.SetAddonEnabled', {'addonid': IPTV_SIMPLE_ID, 'enabled': False}) output_dir = settings.get('output_dir', '').strip() or ADDON_PROFILE playlist_path = os.path.join(output_dir, PLAYLIST_FILE_NAME) epg_path = os.path.join(output_dir, EPG_FILE_NAME) ## IMPORT ANY CURRENT URL SOURCES ## cur_epg_url = addon.getSetting('epgUrl') cur_epg_type = addon.getSetting('epgPathType') if cur_epg_url: epg = EPG(source_type=EPG.TYPE_URL, path=cur_epg_url, enabled=cur_epg_type == '1') try: epg.save() except: pass cur_m3u_url = addon.getSetting('m3uUrl') cur_m3u_type = addon.getSetting('m3uPathType') start_chno = int(addon.getSetting('startNum') or 1) #user_agent = addon.getSetting('userAgent') if cur_m3u_url: playlist = Playlist(source_type=Playlist.TYPE_URL, path=cur_m3u_url, enabled=cur_m3u_type == '1') if start_chno != 1: playlist.use_start_chno = True playlist.start_chno = start_chno try: playlist.save() except: pass ################################ addon.setSetting('epgPath', epg_path) addon.setSetting('m3uPath', playlist_path) addon.setSetting('epgUrl', '') addon.setSetting('m3uUrl', '') addon.setSetting('m3uPathType', '0') addon.setSetting('epgPathType', '0') monitor = xbmc.Monitor() progress.update(30) monitor.waitForAbort(2) kodi_rpc('Addons.SetAddonEnabled', {'addonid': IPTV_SIMPLE_ID, 'enabled': True}) progress.update(60) monitor.waitForAbort(2) progress.update(100) set_kodi_setting('epg.futuredaystodisplay', 7) # set_kodi_setting('epg.ignoredbforclient', True) set_kodi_setting('pvrmanager.syncchannelgroups', True) set_kodi_setting('pvrmanager.preselectplayingchannel', True) set_kodi_setting('pvrmanager.backendchannelorder', True) set_kodi_setting('pvrmanager.usebackendchannelnumbers', True) set_kodi_string('_iptv_merge_force_run', '1') gui.ok(_.SETUP_IPTV_COMPLETE) return True
def _setup(): addon = get_addon(IPTV_SIMPLE_ID, required=True, install=True) with gui.progress(_.SETTING_UP_IPTV) as progress: kodi_rpc('Addons.SetAddonEnabled', {'addonid': IPTV_SIMPLE_ID, 'enabled': False}) output_dir = xbmc.translatePath(settings.get('output_dir', '').strip() or ADDON_PROFILE) playlist_path = os.path.join(output_dir, PLAYLIST_FILE_NAME) epg_path = os.path.join(output_dir, EPG_FILE_NAME) if not os.path.exists(playlist_path): with open(playlist_path, 'w') as f: f.write('''#EXTM3U #EXTINF:-1 tvg-id="iptv_merge" tvg-chno="1000" tvg-logo="{}",{} {}'''.format(ADDON_ICON, 'IPTV Merge: Click me to run a merge!', plugin.url_for(merge))) if not os.path.exists(epg_path): with open(epg_path, 'w') as f: f.write('''<?xml version="1.0" encoding="utf-8" ?><tv><channel id="iptv_merge"></channel></tv>''') ## IMPORT ANY CURRENT SOURCES ## cur_epg_url = addon.getSetting('epgUrl') cur_epg_path = addon.getSetting('epgPath') cur_epg_type = addon.getSetting('epgPathType') if cur_epg_path != epg_path and os.path.exists(xbmc.translatePath(cur_epg_path)): epg = EPG(source_type=EPG.TYPE_FILE, path=cur_epg_path, enabled=cur_epg_type == '0') epg.auto_archive_type() try: epg.save() except: pass if cur_epg_url: epg = EPG(source_type=EPG.TYPE_URL, path=cur_epg_url, enabled=cur_epg_type == '1') epg.auto_archive_type() try: epg.save() except: pass cur_m3u_url = addon.getSetting('m3uUrl') cur_m3u_path = addon.getSetting('m3uPath') cur_m3u_type = addon.getSetting('m3uPathType') start_chno = int(addon.getSetting('startNum') or 1) #user_agent = addon.getSetting('userAgent') if cur_m3u_path != playlist_path and os.path.exists(xbmc.translatePath(cur_m3u_path)): playlist = Playlist(source_type=Playlist.TYPE_FILE, path=cur_m3u_path, enabled=cur_m3u_type == '0') playlist.auto_archive_type() if start_chno != 1: playlist.use_start_chno = True playlist.start_chno = start_chno try: playlist.save() except: pass if cur_m3u_url: playlist = Playlist(source_type=Playlist.TYPE_URL, path=cur_m3u_url, enabled=cur_m3u_type == '1') playlist.auto_archive_type() if start_chno != 1: playlist.use_start_chno = True playlist.start_chno = start_chno try: playlist.save() except: pass ##### addon.setSetting('epgPath', epg_path) addon.setSetting('m3uPath', playlist_path) addon.setSetting('epgUrl', '') addon.setSetting('m3uUrl', '') addon.setSetting('m3uPathType', '0') addon.setSetting('epgPathType', '0') monitor = xbmc.Monitor() progress.update(30) monitor.waitForAbort(2) kodi_rpc('Addons.SetAddonEnabled', {'addonid': IPTV_SIMPLE_ID, 'enabled': True}) progress.update(60) monitor.waitForAbort(2) progress.update(100) set_kodi_setting('epg.futuredaystodisplay', 7) # set_kodi_setting('epg.ignoredbforclient', True) set_kodi_setting('pvrmanager.syncchannelgroups', True) set_kodi_setting('pvrmanager.preselectplayingchannel', True) set_kodi_setting('pvrmanager.backendchannelorder', True) set_kodi_setting('pvrmanager.usebackendchannelnumbers', True) gui.ok(_.SETUP_IPTV_COMPLETE) return True