def presentation(): path = control.transPath( 'special://profile/addon_data/{0}/slideshow/'.format( control.addonInfo('id'))) if not control.exists(control.join(path, '01.jpg')): control.makeFiles(path) control.idle() dp = control.ProgressDialog(heading=control.name()) for i in range(1, 25): dp.update((i + 1) * 4, line1=control.lang(30038)) client.retriever( 'http://mediaportal.anacon.org/faros/{0}.jpg'.format( str(i) if len(str(i)) >= 2 else str('0' + str(i))), control.join( path, (str(i) if len(str(i)) >= 2 else str('0' + str(i))) + '.jpg')) control.execute('Dialog.Close(progressdialog)') control.execute('SlideShow({0},pause)'.format(path))
def wrapper(_list_, limit=5, score=70): results = [] if not _list_: return term = control.inputDialog() if not term: return try: term = term.decode('utf-8') except AttributeError: pass control.busy() titles = [i['title'].encode('unicode-escape') for i in _list_] matches = [ titles.index(l) for l, s in process.extract( term.encode('unicode-escape'), titles, limit=limit ) if s >= score ] for m in matches: results.append(_list_[m]) control.idle() return results
def pin(): control.busy() title = control.infoLabel('ListItem.Title') pin_to_file(PINNED, title) control.infoDialog(control.lang(30338), time=750) control.idle()
def play(url, meta=None, quality=None): if meta: control.busy() stream = resolver(url, quality) try: isa_enabled = control.addon_details('inputstream.adaptive').get( 'enabled') except KeyError: isa_enabled = False dash = ('.mpd' in stream or 'dash' in stream or '.ism' in stream or '.hls' in stream or '.m3u8' in stream) and isa_enabled mimetype = None if isinstance(meta, dict): control.idle() if meta['title'] == 'custom': title = control.inputDialog() meta['title'] = title if dash and control.setting('disable_mpd') == 'false': if '.hls' in stream or 'm3u8' in stream: manifest_type = 'hls' mimetype = 'application/vnd.apple.mpegurl' elif '.ism' in stream: manifest_type = 'ism' else: manifest_type = 'mpd' log_debug('Activating MPEG-DASH for this url: ' + stream) directory.resolve(stream, meta=meta, dash=dash, manifest_type=manifest_type, mimetype=mimetype, resolved_mode=meta is None) else: directory.resolve(stream, meta=meta, resolved_mode=meta is None)
def unpin(): control.busy() title = control.infoLabel('ListItem.Title') unpin_from_file(PINNED, title) control.sleep(100) control.refresh() control.infoDialog(control.lang(30338), time=750) control.idle()
def vod_switcher(self, url): self.data = root(url)[1] translated = [control.lang(int(i)) for i in self.data] choice = control.selectDialog(heading=control.lang(30062), list=translated) if choice <= len(self.data) and not choice == -1: control.setSetting('vod_group', self.data[choice]) control.idle() control.sleep(100) # ensure setting has been saved control.refresh() else: control.execute('Dialog.Close(all)')
def clear(table=None, withyes=False, notify=True, file_=None, label_yes_no=30401, label_success=30402): if file_ is None: if control: file_ = control.cacheFile else: file_ = os.path.join(os.path.curdir, 'cache.db') try: if control: control.idle() if table is None: table = ['rel_list', 'rel_lib'] elif not type(table) == list: table = [table] if withyes and control: try: yes = control.yesnoDialog( control.lang(label_yes_no).encode('utf-8'), '', '') except Exception: yes = control.yesnoDialog(control.lang(label_yes_no), '', '') if not yes: return dbcon = database.connect(file_) dbcur = dbcon.cursor() for t in table: try: dbcur.execute("DROP TABLE IF EXISTS {0}".format(t)) dbcur.execute("VACUUM") dbcon.commit() except Exception: pass if control and notify: control.infoDialog(control.lang(label_success).encode('utf-8')) except Exception: pass
def play(url, meta=None): if meta: control.busy() stream = router(url) if isinstance(meta, dict): control.idle() if meta['title'] == 'custom': title = control.inputDialog() meta['title'] = title directory.resolve(stream, meta=meta, resolved_mode=meta is None)
def switcher(): def seq(choose): control.setSetting('group', choose) control.sleep(50) control.refresh() groups = [control.lang(30016)] + cache.get( constructor, int(control.setting('caching')) if int(control.setting('caching')) > 0 else 0)[1] choice = control.dialog.select(heading=control.lang(30017), list=groups) if choice == 0: seq('ALL') elif choice <= len(groups) and not choice == -1: seq(groups[choice]) else: control.idle()
def clear(table=None, withyes=True): try: control.idle() if table is None: table = ['rel_list', 'rel_lib'] elif not type(table) == list: table = [table] if withyes: try: yes = control.yesnoDialog(control.lang(30401).encode('utf-8'), '', '') except Exception: yes = control.yesnoDialog(control.lang(30401), '', '') if not yes: return else: pass dbcon = database.connect(control.cacheFile) dbcur = dbcon.cursor() for t in table: try: dbcur.execute("DROP TABLE IF EXISTS {0}".format(t)) dbcur.execute("VACUUM") dbcon.commit() except Exception: pass control.infoDialog(control.lang(30402).encode('utf-8')) except Exception: pass
def seq(choose): control.setSetting('papers_group', choose) control.idle() control.sleep(100) control.refresh()
def seq(group): control.setSetting('live_group', str(group)) control.idle() control.sleep(100) control.refresh()