def views(self): try: control.idle() items = [ (control.lang(32001).encode('utf-8'), 'movies'), (control.lang(32002).encode('utf-8'), 'tvshows'), (control.lang(32054).encode('utf-8'), 'seasons'), (control.lang(32038).encode('utf-8'), 'episodes') ] select = control.selectDialog([i[0] for i in items], control.lang(32049).encode('utf-8')) if select == -1: return content = items[select][1] title = control.lang(32059).encode('utf-8') url = '%s?action=addView&content=%s' % (sys.argv[0], content) poster, banner, fanart = control.addonPoster(), control.addonBanner(), control.addonFanart() item = control.item(label=title) item.setInfo(type='Video', infoLabels = {'title': title}) item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner}) item.setProperty('Fanart_Image', fanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) control.content(int(sys.argv[1]), content) control.directory(int(sys.argv[1]), cacheToDisc=True) from resources.lib.addon import views views.setView(content, {}) except: return
def listamount(self): try: control.idle() items = [ ('10', '10'), ('20', '20'), ('30', '30'), ('40', '40'), ('50', '50'), ('60', '60'), ('70', '70'), ('80', '80'), ('90', '90'), ('100', '100') ] select = control.selectDialog([i[0] for i in items], 'Items per Page') if select == -1: return items = items[select][1] control.setSetting('useramount','%s' % items) control.refresh() except: return
def sortby(self): try: control.idle() items = [ ('Popularity', 'moviemeter'), ('Alphabetical', 'alpha'), ('IMDb Rating', 'user_rating'), ('Number of Votes', 'num_votes'), ('US Box Office by Gross', 'boxoffice_gross_us'), ('By Year', 'year'), ('By Release Date', 'release_date') ] select = control.selectDialog([i[0] for i in items], 'Sort Lists By') if select == -1: return items = items[select][1] control.setSetting('uservar','%s' % items) control.refresh() except: return
def manager(name, imdb, tvdb, content): try: post = {"movies": [{"ids": {"imdb": imdb}}]} if content == 'movie' else {"shows": [{"ids": {"tvdb": tvdb}}]} items = [(control.lang(32516).encode('utf-8'), '/sync/collection')] items += [(control.lang(32517).encode('utf-8'), '/sync/collection/remove')] items += [(control.lang(32518).encode('utf-8'), '/sync/watchlist')] items += [(control.lang(32519).encode('utf-8'), '/sync/watchlist/remove')] items += [(control.lang(32520).encode('utf-8'), '/users/me/lists/%s/items')] result = getTraktAsJson('/users/me/lists') lists = [(i['name'], i['ids']['slug']) for i in result] lists = [lists[i//2] for i in range(len(lists)*2)] for i in range(0, len(lists), 2): lists[i] = ((control.lang(32521) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items' % lists[i][1]) for i in range(1, len(lists), 2): lists[i] = ((control.lang(32522) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items/remove' % lists[i][1]) items += lists select = control.selectDialog([i[0] for i in items], control.lang(32515).encode('utf-8')) if select == -1: return elif select == 4: t = control.lang(32520).encode('utf-8') k = control.keyboard('', t) ; k.doModal() new = k.getText() if k.isConfirmed() else None if (new == None or new == ''): return result = __getTrakt('/users/me/lists', post={"name": new, "privacy": "private"})[0] try: slug = utils.json_loads_as_str(result)['ids']['slug'] except: return control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon='ERROR') result = __getTrakt(items[select][1] % slug, post=post)[0] else: result = __getTrakt(items[select][1], post=post)[0] icon = control.infoLabel('ListItem.Icon') if not result == None else 'ERROR' control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon=icon) except: return
def sourcesDialog(self, items): try: labels = [i['label'] for i in items] select = control.selectDialog(labels) if select == -1: return 'close://' next = [y for x,y in enumerate(items) if x >= select] prev = [y for x,y in enumerate(items) if x < select][::-1] items = [items[select]] items = [i for i in items+next+prev][:40] header = control.addonInfo('name') header2 = header.upper() progressDialog = control.progressDialog if control.setting('progress.dialog') == '0' else control.progressDialogBG progressDialog.create(header, '') progressDialog.update(0) block = None for i in range(len(items)): try: if items[i]['source'] == block: raise Exception() w = workers.Thread(self.sourcesResolve, items[i]) w.start() try: if progressDialog.iscanceled(): break progressDialog.update(int((100 / float(len(items))) * i), str(items[i]['label']), str(' ')) except: progressDialog.update(int((100 / float(len(items))) * i), str(header2), str(items[i]['label'])) m = '' for x in range(3600): try: if xbmc.abortRequested == True: return sys.exit() if progressDialog.iscanceled(): return progressDialog.close() except: pass k = control.condVisibility('Window.IsActive(virtualkeyboard)') if k: m += '1'; m = m[-1] if (w.is_alive() == False or x > 30) and not k: break k = control.condVisibility('Window.IsActive(yesnoDialog)') if k: m += '1'; m = m[-1] if (w.is_alive() == False or x > 30) and not k: break time.sleep(0.5) for x in range(30): try: if xbmc.abortRequested == True: return sys.exit() if progressDialog.iscanceled(): return progressDialog.close() except: pass if m == '': break if w.is_alive() == False: break time.sleep(0.5) if w.is_alive() == True: block = items[i]['source'] if self.url == None: raise Exception() self.selectedSource = items[i]['label'] try: progressDialog.close() except: pass control.execute('Dialog.Close(virtualkeyboard)') control.execute('Dialog.Close(yesnoDialog)') return self.url except: pass try: progressDialog.close() except: pass except: try: progressDialog.close() except: pass
def sourcesDialog(self, items): try: labels = [i['label'] for i in items] select = control.selectDialog(labels) if select == -1: return 'close://' next = [y for x, y in enumerate(items) if x >= select] prev = [y for x, y in enumerate(items) if x < select][::-1] items = [items[select]] items = [i for i in items + next + prev][:40] header = control.addonInfo('name') header2 = header.upper() progressDialog = control.progressDialog if control.setting( 'progress.dialog') == '0' else control.progressDialogBG progressDialog.create(header, '') progressDialog.update(0) block = None for i in range(len(items)): try: if items[i]['source'] == block: raise Exception() w = workers.Thread(self.sourcesResolve, items[i]) w.start() try: if progressDialog.iscanceled(): break progressDialog.update( int((100 / float(len(items))) * i), str(items[i]['label']), str(' ')) except: progressDialog.update( int((100 / float(len(items))) * i), str(header2), str(items[i]['label'])) m = '' for x in range(3600): try: if xbmc.abortRequested == True: return sys.exit() if progressDialog.iscanceled(): return progressDialog.close() except: pass k = control.condVisibility( 'Window.IsActive(virtualkeyboard)') if k: m += '1' m = m[-1] if (w.is_alive() == False or x > 30) and not k: break k = control.condVisibility( 'Window.IsActive(yesnoDialog)') if k: m += '1' m = m[-1] if (w.is_alive() == False or x > 30) and not k: break time.sleep(0.5) for x in range(30): try: if xbmc.abortRequested == True: return sys.exit() if progressDialog.iscanceled(): return progressDialog.close() except: pass if m == '': break if w.is_alive() == False: break time.sleep(0.5) if w.is_alive() == True: block = items[i]['source'] if self.url == None: raise Exception() self.selectedSource = items[i]['label'] try: progressDialog.close() except: pass control.execute('Dialog.Close(virtualkeyboard)') control.execute('Dialog.Close(yesnoDialog)') return self.url except: pass try: progressDialog.close() except: pass except: try: progressDialog.close() except: pass