def _buildRow(self, accessible, dummy=False): ''' Wrapper for building a row in the tree. Use this method instead of trying to construct the row by hand as it will be synced with the design of the model fields. @param accessible: Accessible object @type accessible: L{Accessibility.Accessible} @param dummy: Is this a dummy row? @type dummy: boolean ''' if accessible is not None: icon = getIcon(accessible) name = accessible.name role = accessible.getLocalizedRoleName() count = str(accessible.childCount) else: icon = None if not dummy: name = _('<dead>') else: name = None role = None count = None return [icon, name, role, count, False, dummy, accessible]
def getMostViewTvShow(self,streamItem=False): """ Method to get top week tv show @return a list of StreamItem """ # ___ Initialize the list to return elementList = [] href = '/series?p=Populaire&page=' page = 1 # ___ Get the page if streamItem and streamItem.getPage() is not None and len(streamItem.getPage()) > 0: page = streamItem.getPage() href = href+str(page) # ___ Get the soup response = self.openPage(href) if response and response.getcode() == 200: content = response.read() elementList = self.getTvShowsFromContent(content) # ___ Ad the next page nextPage = StreamItem(constant.__addon__.getLocalizedString(70010)) nextPage.setIconImage(icons.getIcon('nextpage')) nextPage.setType(StreamItem.TYPE_TVSHOW) nextPage.setAction(StreamItem.ACTION_DISPLAY_TYPE_LIST) nextPage.setSubType(StreamItem.SUBTYPE_LAST) nextPage.setPage(int(page)+1) elementList.append(nextPage) return elementList
def _refreshIcon(self, app): ''' Refresh the icon of a given application's accessible. This is done because it takes wnck a while to load an application's icon at application startup. @param app: The given application's accessible. @type app: L{Accessibility.Accessible} ''' path = self.model.getAccPath(app) try: self.model[path][COL_ICON] = getIcon(app) except: pass return False
def getTvShowContent(self, streamItem, page, response): """ Generic method to get movie content @param response: the html response @param subtype: the subtype for streamItem """ elementList = [] if response and response.getcode() == 200: content = response.read() soup = BeautifulSoup(content) if soup is not None: movies = soup.find('div', { 'class': 'filmcontent' }).findAll('div', {'class': 'moviefilm'}) for movie in movies: title = movie.find('img')['alt'].encode('UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: " + title, xbmc.LOGDEBUG) href = movie.find('a')['href'] title = strUtil.cleanTitle(title) self.__LOGGER__.log("Clean title: " + str(title), xbmc.LOGDEBUG) # __ Create the element element = StreamItem(title) element.setHref(href) element.setAction(StreamItem.ACTION_DISPLAY_SEASONS) element.setType(StreamItem.TYPE_TVSHOW) element.setSourceId(self.ID) element.setIconImage(movie.find('img')['src']) # __ Add the element to the list elementList.append(element) nextPage = StreamItem(constant.__addon__.getLocalizedString(70010)) nextPage.setIconImage(icons.getIcon('nextpage')) nextPage.setType(StreamItem.TYPE_TVSHOW) nextPage.setAction(StreamItem.ACTION_DISPLAY_TYPE_LIST) nextPage.setSubType(streamItem.getSubType()) nextPage.setPage(int(page) + 1) elementList.append(nextPage) return elementList
iconsWanted = thisAddon.getSetting('retrieve_icons') == 'true' includeDisabled = thisAddon.getSetting('include_disabled_channels') == 'true' # Paths thisPluginPath = thisAddon.getAddonInfo('path') resourcesPath = os.path.join(thisPluginPath, 'resources') iconsPath = os.path.join(resourcesPath, 'icons') provider = channelproviders.GitHubJSON(includeDisabled) # provider = channelproviders.TvOnlineAPP() # provider = channelproviders.GitHubMD() channelList = provider.retrieveList() for channel in channelList: channelListItem = xbmcgui.ListItem(channel[0]) if iconsWanted: iconfile = icons.getIcon(channel[0]) if iconfile != None: channelListItem.setArt({ 'icon': os.path.join(iconsPath, iconfile), 'poster': os.path.join(iconsPath, iconfile), 'banner': os.path.join(iconsPath, iconfile) }) xbmcplugin.addDirectoryItem(handle=addon_handle, url=channel[1], listitem=channelListItem) xbmcplugin.endOfDirectory(addon_handle)
def getLastAnime(self,streamItem=False): """ Method to get all last anime @return a list of StreamItem """ # ___ Initialize the list to return elementList = [] href = '/accueil-mangas' page = 0 # ___ Get the page if streamItem and streamItem.getPage() is not None and len(streamItem.getPage()) > 0: href = href +'/page/' +streamItem.getPage() page = streamItem.getPage() # ___ Get the soup response = self.openPage(href) if response and response.getcode() == 200: content = response.read() soup = BeautifulSoup(content) if soup is not None: movies = soup.find('div',{'id':'dle-content'}).findAll('div',{ 'class':'movie-item ignore-select short-movie clearfix'}) for movie in movies: title = movie.find('img')['alt'].encode('UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: "+title,xbmc.LOGDEBUG) href = movie.find('a',{'class':'movie-title'})['href'] titleExtract = movie.find('a',{'class':'movie-title'}).text.encode('UTF-8') year = strUtil.getYearFromTitle(titleExtract) quality = strUtil.getQualityFromTitle(titleExtract) lang = strUtil.getLangFromTitle(titleExtract) title = strUtil.cleanTitle(title) self.__LOGGER__.log("Clean title: "+str(title),xbmc.LOGDEBUG) # __ Create the element element = StreamItem(title) element.setTvShowName(title) element.setHref(href) element.setYear(year) if movie.find('span') is not None: element.setQuality(movie.find('span').text.encode('UTF-8')) element.setLang(lang) element.setAction(StreamItem.ACTION_DISPLAY_SEASONS) element.setType(StreamItem.TYPE_TVSHOW) element.setSourceId(self.ID) element.setIconImage(movie.find('img')['src']) # ___ Get metadatas metadatas = movie.find('div',{'class':'movie-desc'}) metas = metadatas.findAll('div',{'class':'movie-director'}) if metas is not None: genres = metas[0].text.encode('UTF-8') genres = genres.replace(metas[0].find('b').text.encode('UTF-8'),'').strip() element.setMetadataGenre(genres) year = metas[1].text.encode('UTF-8') year = year.replace(metas[1].find('b').text.encode('UTF-8'),'') year = year[len(year)-5:len(year)] element.setMetadataYear(year) overview = metadatas.find('div',{'class':'movie-text'}) if overview is not None: element.setMetadataOverview(overview.text.encode('UTF-8')) # __ Add the element to the list elementList.append(element) nextPage = StreamItem(constant.__addon__.getLocalizedString(70010)) nextPage.setIconImage(icons.getIcon('nextpage')) nextPage.setType(StreamItem.TYPE_TVSHOW) nextPage.setAction(StreamItem.ACTION_DISPLAY_TYPE_LIST) nextPage.setSubType(StreamItem.SUBTYPE_LAST) nextPage.setPage(int(page)+1) elementList.append(nextPage) return elementList
def getMovieContent(self, streamItem, page, response): """ Generic method to get movie content @param response: the html response @param subtype: the subtype for streamItem """ elementList = [] if response and response.getcode() == 200: content = response.read() soup = BeautifulSoup(content) if soup is not None: movies = soup.find('section', { 'class': 'box' }).findAll( 'div', {'class': 'column is-one-quarter-desktop is-half-mobile'}) for movie in movies: title = movie.find( 'img', {'class': 'image-fix'})['alt'].encode('UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: " + title, xbmc.LOGDEBUG) href = movie.find('a')['href'] year = strUtil.getYearFromTitle(title) quality = movie.find( 'div', { 'class': re.compile('(media-content)(.*)') }).text.encode('UTF-8') langClass = movie.find('img', {'class': 'language-image'})['src'] lang = None subtitle = None if langClass == '/vf.png': lang = 'FR' else: lang = 'VO' subtitle = 'FR' title = strUtil.cleanTitle(title) self.__LOGGER__.log("Clean title: " + str(title), xbmc.LOGDEBUG) # __ Create the element element = StreamItem(title) element.setHref(href) element.setYear(year) element.setQuality(quality) element.setLang(lang) element.setSubTitle(subtitle) element.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setSourceId(self.ID) element.setIconImage( movie.find('img', {'class': 'image-fix'})['src']) # __ Add the element to the list elementList.append(element) nextPage = StreamItem(constant.__addon__.getLocalizedString(70010)) nextPage.setIconImage(icons.getIcon('nextpage')) nextPage.setType(StreamItem.TYPE_MOVIE) nextPage.setAction(StreamItem.ACTION_DISPLAY_TYPE_LIST) nextPage.setSubType(streamItem.getSubType()) nextPage.setPage(int(page) + 1) elementList.append(nextPage) return elementList
def getListItem(self): """ Getter for the JSON Item @return the JSON item """ # ___ Generate Kodi Title self.regenerateKodiTitle() # ___ Create the list item with the name, the default iconImage is 'DefaultMovies.png' li = xbmcgui.ListItem(self.Item['kodi_title'], iconImage=self.Item['iconImage']) # ___ If the iconImage value starts with 'resources/media', we use it as icon and thumbail image if self.Item['iconImage'].startswith('resources/media'): li.setIconImage( xbmc.translatePath( os.path.join(constant.__addonDir__, self.Item['iconImage']))) li.setThumbnailImage( xbmc.translatePath( os.path.join(constant.__addonDir__, self.Item['iconImage']))) # ___ If the dictionnary has the 'metadata' value not null, we used it as video informations if self.Item['metadata'] != '' and not self.isPage(): # ___ Load metada str in json object or dict in json obect __ Fix in the metadata setter meta = self.getMetadata() """ try: if isinstance(self.Item['metadata'],str): meta = json.loads(self.Item['metadata']) else: meta = self.Item['metadata'] except: #traceback.print_exc() try: meta = ast.literal_eval(self.Item['metadata']) except: #traceback.print_exc() meta = self.Item['metadata'] """ try: li.setInfo("video", meta) # ___ If 'metadata' has a 'picturepath' parameter, we used it as Thumbnail image and icon image if 'picturepath' in meta: try: li.setThumbnailImage(meta['picturepath']) except: pass li.setIconImage(meta['picturepath']) # ___ If 'metadata' has a 'fanart_image' parameter, we used it as fanart_image if 'fanart_image' in meta: li.setProperty('fanart_image', meta['fanart_image']) if 'cover_url' in meta: try: li.setIconImage(meta['cover_url']) except: pass if 'backdrop_url' in meta: try: li.setProperty('fanart_image', meta['backdrop_url']) except: pass except: traceback.print_exc() self.__LOGGER__.log( 'Error during setting property of listItem', xbmc.LOGERROR) # ___ If the item is movie if (self.getType() == self.TYPE_MOVIE or self.getType() == self.TYPE_MOVIE_HD ) and self.getAction() == self.ACTION_DISPLAY_LINKS: li.addContextMenuItems([ (constant.__addon__.getLocalizedString(70012).title(), 'RunPlugin(plugin://plugin.video.seko.ultrastream/?action=23&title=' + self.getTitle() + ')'), (constant.__addon__.getLocalizedString(70008).title(), 'Container.Update(plugin://plugin.video.seko.ultrastream/?action=26&type=-1&title=' + self.getTitle() + ')'), (constant.__addon__.getLocalizedString(70015).title(), 'RunPlugin(plugin://plugin.video.seko.ultrastream/?action=27)' ) ]) else: li.addContextMenuItems([( constant.__addon__.getLocalizedString(70015).title(), 'RunPlugin(plugin://plugin.video.seko.ultrastream/?action=27)') ]) # Add to Favorite if not self.isFavorite() and \ ( ((self.getType() == self.TYPE_ANIME or self.getType() == self.TYPE_TVSHOW) and \ (self.getAction() == self.ACTION_DISPLAY_SEASONS or self.getAction() == self.ACTION_DISPLAY_EPISODES or self.getAction() == self.ACTION_DISPLAY_LINKS)) or \ (self.getType() == self.TYPE_MOVIE and self.getAction()==self.ACTION_DISPLAY_LINKS) or \ (self.getType() == self.TYPE_MOVIE_HD and self.getAction()==self.ACTION_DISPLAY_LINKS) ): li.addContextMenuItems([ (constant.__addon__.getLocalizedString(40043).title(), 'RunPlugin(plugin://plugin.video.seko.ultrastream/?action=' + str(self.ACTION_ADD_TO_FAVORITE) + '&' + urllib.urlencode(self.getFavJson()) + ')') ]) # Remove to Favorite if self.isFavorite(): li.addContextMenuItems([( constant.__addon__.getLocalizedString(40044).title(), 'Container.Update(plugin://plugin.video.seko.ultrastream/?action=' + str(self.ACTION_REMOVE_FROM_FAVORITE) + '&' + urllib.urlencode(self.getFavJson()) + ')')]) # ___ If the item is a page, we set the page thumbnail and page icon. if self.isPage(): li.setThumbnailImage(icons.getIcon('nextpage')) li.setIconImage(icons.getIcon('nextpage')) return li