def search(): input_str = control.inputDialog() if not input_str: return items = radios_list(ALL_LINK) + _devpicks() if is_py3: titles = [strip_accents(i['title']) for i in items] matches = [ titles.index(t) for t, s in process.extract( strip_accents(input_str), titles, limit=10) if s >= 70 ] else: titles = [ strip_accents(i['title']).encode('unicode-escape') for i in items ] matches = [ titles.index(t) for t, s in process.extract(strip_accents( input_str).encode('unicode-escape'), titles, limit=10) if s >= 70 ] data = [] for m in matches: data.append(items[m]) if not data: control.infoDialog(30010) return else: for i in data: i.update({'action': 'play', 'isFolder': 'False'}) bookmark = dict((k, v) for k, v in iteritems(i) if not k == 'next') bookmark['bookmark'] = i['url'] i.update({ 'cm': [{ 'title': 30501, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } }] }) control.sortmethods('title') directory.add(data, infotype='music')
def search(self): input_str = control.inputDialog() try: input_str = cleantitle.strip_accents(input_str.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): input_str = cleantitle.strip_accents(input_str) input_str = quote(input_str.encode('utf-8')) directory.run_builtin(action='listing', url=self.search_link.format(input_str))
def search(self): search_str = control.dialog.input(control.addonInfo('name')) search_str = cleantitle.strip_accents(search_str.decode('utf-8')) if not search_str: return self.list = self.video_list() try: self.list = [ item for item in self.list if search_str.lower() in cleantitle.strip_accents( item['title'].decode('utf-8')).lower() ] except Exception: self.list = [ item for item in self.list if search_str.lower() in cleantitle.strip_accents(item['title']).lower() ] if not self.list: return for item in self.list: item['title'] = cleantitle.replaceHTMLCodes(item['title']) bookmark = dict( (k, v) for k, v in iteritems(item) if not k == 'next') bookmark['bookmark'] = item['url'] bm_cm = { 'title': 30011, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } } cache_clear = {'title': 30015, 'query': {'action': 'cache_clear'}} item.update({'cm': [cache_clear, bm_cm]}) self.list = sorted(self.list, key=lambda k: k['title'].lower()) if control.setting('force_view') == 'true': control.set_view_mode('50') directory.add(self.list)
def bookmarks(self): self.data = bookmarks.get() if not self.data: log_debug('Bookmarks list is empty') na = [{'title': 30033, 'action': None, 'icon': iconname('empty')}] directory.add(na) else: for i in self.data: item = dict((k, v) for k, v in iteritems(i) if not k == 'next') item['delbookmark'] = i['url'] i.update({ 'cm': [{ 'title': 30081, 'query': { 'action': 'deleteBookmark', 'url': json.dumps(item) } }] }) self.list = sorted(self.data, key=lambda k: strip_accents(k['title'].lower())) if setting('show_clear_bookmarks') == 'true': clear_all = { 'title': 30274, 'action': 'clear_bookmarks', 'icon': iconname('empty') } self.list.insert(0, clear_all) directory.add(self.list)
def listing(self, url, post=None, get_listing=False): if CACHE_DEBUG: self.list = self.items_list(url, post) else: self.list = cache.get(self.items_list, 12, url, post) if self.list is None: log_debug( 'Listing section failed to load, try resetting indexer methods' ) return if url.startswith(MOVIES) and control.setting( 'show_cartoons') == 'false' and url != ''.join( [GM_BASE, 'movies.php?g=8&y=&l=&p=']): if CACHE_DEBUG: bl_urls = blacklister() else: bl_urls = cache.get(blacklister, 96) self.list = [i for i in self.list if i['url'] not in bl_urls] for item in self.list: if url.startswith((MOVIES, THEATER, SHORTFILMS, PERSON, SEARCH)) and item['url'].startswith( (MOVIES, THEATER, SHORTFILMS, PERSON)): item.update({'action': 'play', 'isFolder': 'False'}) elif url.startswith(SPORTS): item.update({'action': 'events'}) else: item.update({'action': 'episodes'}) for item in self.list: bookmark = dict( (k, v) for k, v in iteritems(item) if not k == 'next') bookmark['bookmark'] = item['url'] bookmark_cm = { 'title': 30080, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } } refresh_cm = {'title': 30054, 'query': {'action': 'refresh'}} item.update({'cm': [bookmark_cm, refresh_cm]}) if get_listing: return self.list if len(self.list) > int( control.setting('pagination_integer')) and control.setting( 'paginate_items') == 'true': if control.setting('sort_method') == '0': self.list.sort( key=lambda k: cleantitle.strip_accents(k['title'].lower()), reverse=control.setting('reverse_order') == 'true') elif control.setting('sort_method') == '1': self.list.sort( key=lambda k: k['year'], reverse=control.setting('reverse_order') == 'true') try: pages = list_divider( self.list, int(control.setting('pagination_integer'))) self.list = pages[int(control.setting('page'))] reset = False except Exception: pages = list_divider( self.list, int(control.setting('pagination_integer'))) self.list = pages[0] reset = True self.list.insert(0, page_menu(len(pages), reset=reset)) if control.setting('paginate_items') == 'false' or len( self.list) <= int(control.setting('pagination_integer')): control.sortmethods() control.sortmethods('title') control.sortmethods('year') if url.startswith((MOVIES, THEATER, SHORTFILMS)): directory.add(self.list, content='movies') else: directory.add(self.list, content='tvshows')
def search(self): choices = [ control.lang(30096), control.lang(30097), control.lang(30098) ] choice = control.selectDialog(heading=control.lang(30095), list=choices) if choice == 0: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30096)) if not str_input: return try: str_input = str_input.decode('utf-8') except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): pass self.list = live.Indexer(argv=self.argv).live_tv( zapping=False, query=str_input.lower()) directory.add(self.list, argv=self.argv) elif choice == 1: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30097)) try: str_input = cleantitle.strip_accents(str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) if not str_input: return self.list = cache.get(self.wrapper, 12, str_input, self.WRAPPER_MOVIES) directory.add(self.list, content='movies', argv=self.argv) elif choice == 2: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30098)) if not str_input: return try: str_input = cleantitle.strip_accents(str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) self.list = cache.get(self.wrapper, 12, str_input, self.WRAPPER_SHOWS) directory.add(self.list, content='movies', argv=self.argv) else: control.execute('ActivateWindow(videos,"{0}")'.format(sysaddon))
def search(self): choices = [ control.lang(30096), control.lang(30031), control.lang(30030), control.lang(30063), control.lang(30068), control.lang(30097), control.lang(30101) #, control.lang(30125) ] choice = control.selectDialog(heading=control.lang(30095), list=choices) if choice == 0: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30096)) if not str_input: return self.list = live.Indexer().live_tv(zapping=False, query=str_input.lower()) directory.add(self.list) elif choice == 1: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30031)) try: str_input = cleantitle.strip_accents(str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) if not str_input: return self.list = self.wrapper(str_input, 'movies') directory.add(self.list, content='movies') elif choice == 2: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30030)) if not str_input: return try: str_input = cleantitle.strip_accents(str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) self.list = self.wrapper(str_input, 'series') directory.add(self.list, content='tvshows') elif choice == 3: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30063)) if not str_input: return try: str_input = cleantitle.strip_accents(str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) self.list = self.wrapper(str_input, 'shows') directory.add(self.list, content='tvshows') elif choice == 4: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30068)) if not str_input: return try: str_input = cleantitle.strip_accents(str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) self.list = self.wrapper(str_input, 'theater') directory.add(self.list, content='tvshows') elif choice == 5: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30097)) if not str_input: return try: str_input = cleantitle.strip_accents(str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) self.list = self.wrapper(str_input, 'animation') directory.add(self.list, content='tvshows') elif choice == 6: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30101)) if not str_input: return try: str_input = cleantitle.strip_accents(str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) self.list = self.wrapper(str_input, 'person') directory.add(self.list) # elif choice == 7: # # str_input = control.dialog.input( # heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30125) # ) # # if not str_input: # # return # # try: # str_input = cleantitle.strip_accents(str_input.decode('utf-8')) # except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): # str_input = cleantitle.strip_accents(str_input) # # self.list = cache.get(self.wrapper, 12, str_input, 'music') # # directory.add(self.list) else: control.execute('ActivateWindow(videos,"{0}")'.format(sysaddon))
def search(self, action, query=None): if query is not None: choice = list(QUERY_MAP.keys()).index(query.split(',')[0]) str_input = query.split(',')[1] else: choice = None str_input = None if choice is None: choices = [ control.lang(30096), control.lang(30031), control.lang(30030), control.lang(30063), control.lang(30068), control.lang(30097), control.lang(30101) ] choice = control.selectDialog(heading=control.lang(30095), list=choices) if choice == 0: if str_input is None: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30096)) if not str_input: return add_to_history(u"Live TV Channel,{0}".format(str_input)) if action == 'add_to_history': control.refresh() return self.list = live.Indexer().live_tv(zapping=False, query=str_input.lower()) if query: directory.add(self.list) else: directory.run_builtin(action='generic_index', query=quote_plus(json.dumps(self.list))) elif choice == 1: if str_input is None: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30031)) try: str_input = cleantitle.strip_accents( str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) if not str_input: return add_to_history(u"Movie,{0}".format(str_input)) if action == 'add_to_history': control.refresh() return self.list = self.wrapper(str_input, 'movies') if query: directory.add(self.list, content='movies') else: directory.run_builtin(action='generic_index', query=quote_plus(json.dumps(self.list))) elif choice == 2: if str_input is None: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30030)) if not str_input: return try: str_input = cleantitle.strip_accents( str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) add_to_history(u"TV Serie,{0}".format(str_input)) if action == 'add_to_history': control.refresh() return self.list = self.wrapper(str_input, 'series') if query is not None: directory.add(self.list, content='tvshows') else: directory.run_builtin(action='generic_index', query=quote_plus(json.dumps(self.list))) elif choice == 3: if not str_input: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30063)) if not str_input: return try: str_input = cleantitle.strip_accents( str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) add_to_history(u"TV Show,{0}".format(str_input)) if action == 'add_to_history': control.refresh() return self.list = self.wrapper(str_input, 'shows') if query is not None: directory.add(self.list, content='tvshows') else: directory.run_builtin(action='generic_index', query=quote_plus(json.dumps(self.list))) elif choice == 4: if str_input is None: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30068)) if not str_input: return try: str_input = cleantitle.strip_accents( str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) add_to_history(u"Theater,{0}".format(str_input)) if action == 'add_to_history': control.refresh() return self.list = self.wrapper(str_input, 'theater') if query is not None: directory.add(self.list, content='movies') else: directory.run_builtin(action='generic_index', query=quote_plus(json.dumps(self.list))) elif choice == 5: if str_input is None: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30097)) if not str_input: return try: str_input = cleantitle.strip_accents( str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) add_to_history(u"Cartoon,{0}".format(str_input)) if action == 'add_to_history': control.refresh() return self.list = self.wrapper(str_input, 'animation') if query is not None: directory.add(self.list, content='tvshows') else: directory.run_builtin(action='generic_index', query=quote_plus(json.dumps(self.list))) elif choice == 6: if str_input is None: str_input = control.dialog.input( heading=control.lang(30095).partition(' ')[0] + control.lang(30100) + control.lang(30101)) if not str_input: return try: str_input = cleantitle.strip_accents( str_input.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): str_input = cleantitle.strip_accents(str_input) add_to_history(u"Person,{0}".format(str_input)) if action == 'add_to_history': control.refresh() return self.list = self.wrapper(str_input, 'person') if query is not None: directory.add(self.list) else: directory.run_builtin(action='generic_index', query=quote_plus(json.dumps(self.list))) else: control.close_all()