def searchlist(self): try: from urllib import quote_plus as quote, urlencode # noqa: F401 except ImportError: from urllib.parse import quote_plus as quote, urlencode # noqa: F401 self.reset_media_type_counters() self.addCat(py2_encode(self.language(30734)), "INTERNAL_SEARCH", self.get_media_resource('search.png'), HbogoConstants.ACTION_SEARCH) self.addCat(py2_encode(self.language(30735)), "DEL_SEARCH_HISTORY", self.get_media_resource('remove.png'), HbogoConstants.ACTION_SEARCH_CLEAR_HISTORY) history_items = self.get_search_history() for history_itm in history_items: tmp_url = '%s?%s' % (self.base_url, urlencode({ 'url': "INTERNAL_SEARCH", 'mode': HbogoConstants.ACTION_SEARCH, 'name': py2_encode(self.language(30734)) + ': ' + py2_encode(history_itm[0]), 'query': py2_encode(history_itm[0]), })) liz = xbmcgui.ListItem(py2_encode(history_itm[0])) liz.setArt({'fanart': self.get_resource("fanart.jpg"), 'thumb': self.get_media_resource('search.png'), 'icon': self.get_media_resource('search.png')}) liz.setInfo(type="Video", infoLabels={"Title": py2_encode(self.language(30734)) + ': ' + py2_encode(history_itm[0])}) liz.setProperty('isPlayable', "false") runplugin = 'RunPlugin(%s?%s)' rem_search_query = urlencode({ 'url': 'REM_SEARCH_QUERY', 'mode': HbogoConstants.ACTION_SEARCH_REMOVE_HISTOY_ITEM, 'itm': py2_encode(history_itm[0]), }) rem_search = (py2_encode(self.language(30736)), runplugin % (self.base_url, rem_search_query)) liz.addContextMenuItems(items=[rem_search]) xbmcplugin.addDirectoryItem(handle=self.handle, url=tmp_url, listitem=liz, isFolder=True) KodiUtil.endDir(self.handle, None, True)
def search(self, query=None): if not self.chk_login(): self.login() search_text = "" if query is None: keyb = xbmc.Keyboard("", self.LB_SEARCH_DESC) keyb.doModal() if keyb.isConfirmed(): search_text = py2_encode(keyb.getText()) else: self.force_original_names = False search_text = py2_encode(query) if search_text == "": xbmcgui.Dialog().notification( self.LB_SEARCH_NORES, self.LB_ERROR, self.get_media_resource('search.png')) else: if query is None: self.add_to_search_history(search_text) self.log("Performing search: " + self.API_URL_SEARCH + quote(search_text)) response = self.get_from_hbogo( self.API_URL_SEARCH + quote(search_text) + "&max=30&offset=0", 'xml') if response is False: return count = 0 for item in response.findall('.//item'): count += 1 item_link = item.find('link').text if item_link: if self.lograwdata: self.log(ET.tostring(item, encoding='utf8')) item_type = py2_encode( item.find('clearleap:itemType', namespaces=self.NAMESPACES).text) if item_type != 'media': self.addDir(item) elif item_type == 'media': self.addLink(item, HbogoConstants.ACTION_PLAY) else: self.log('Unknown item type: ' + item_type) if count == 0: # No result xbmcgui.Dialog().notification( self.LB_SEARCH_NORES, self.LB_ERROR, self.get_media_resource('search.png')) KodiUtil.endDir(self.handle, self.decide_media_type())
def list(self, url, simple=False): if not self.chk_login(): self.login() self.log("List: " + str(url)) self.reset_media_type_counters() self.list_pages(url, 200, 0) if simple is False: KodiUtil.endDir(self.handle, self.decide_media_type())
def categories(self): if not self.chk_login(): self.login() self.setDispCat(self.operator_name) if self.addon.getSetting('enforce_kids') != 'true': self.addCat(self.LB_SEARCH, "INTERNAL_SEARCH", self.get_media_resource('search.png'), HbogoConstants.ACTION_SEARCH_LIST) browse_xml = self.get_from_hbogo(self.API_URL_BROWSE + self.LANGUAGE_CODE, response_format='xml') if browse_xml is False: return home = None series = None movies = None kids = None watchlist = None for item in browse_xml.findall('.//item'): if item.find('category').text == 'Home': home = item elif item.find('category').text == 'Series': series = item elif item.find('category').text == 'Movies': movies = item elif item.find('category').text == 'Watchlist': watchlist = item elif item.find('category').text == 'Kids' or item.find( 'category').text == 'Toonix': kids = item else: pass if self.addon.getSetting('enforce_kids') == 'true': if kids is not None: self.list(kids.find('link').text, True) else: self.log("No Kids Category found") KodiUtil.endDir(self.handle, None, True) return if self.addon.getSetting('show_mylist') == 'true': if watchlist is not None: self.exclude_url_from_cache(watchlist.find('link').text) self.addCat(self.LB_MYPLAYLIST, watchlist.find('link').text, self.get_media_resource('FavoritesFolder.png'), HbogoConstants.ACTION_LIST) else: self.log("No Watchlist Category found") if series is not None: self.addCat(py2_encode(series.find('title').text), series.find('link').text, self.get_media_resource('tv.png'), HbogoConstants.ACTION_LIST) else: self.log("No Series Category found") if movies is not None: self.addCat(py2_encode(movies.find('title').text), movies.find('link').text, self.get_media_resource('movie.png'), HbogoConstants.ACTION_LIST) else: self.log("No Movies Category found") if self.addon.getSetting('show_kids') == 'true': if kids is not None: self.addCat(py2_encode(kids.find('title').text), kids.find('link').text, self.get_media_resource('kids.png'), HbogoConstants.ACTION_LIST) else: self.log("No Kids Category found") if home is not None: if self.addon.getSetting('group_home') == 'true': self.addCat(py2_encode(self.language(30733)), home.find('link').text, self.get_media_resource('DefaultFolder.png'), HbogoConstants.ACTION_LIST) else: self.list(home.find('link').text, True) else: self.log("No Home Category found") KodiUtil.endDir(self.handle, None, True)