def getTopMovie(self, streamItem=False): """ Method to get top movie @return a list of StreamItem """ href = '' response = self.openPage(href) elementList = [] if response and response.getcode() == 200: content = response.read() soup = BeautifulSoup(content) # For every post, get title and topicLink movies = soup.find('ul', {'id': 'tab-popular-2'}).findAll('li') for index in range(0, len(movies)): movie = movies[index] el = movie.find('p', {'class': 'tab-item-title'}).find('a') title = el.text.encode('UTF-8') title = strUtil.unescapeHtml(str(title)) # Remove ' Film Complet en Streaming' title = self.removeFilmComplet(title) self.__LOGGER__.log("Finded title: " + title, xbmc.LOGDEBUG) href = el['href'] year = strUtil.getYearFromTitle(title) quality = strUtil.getQualityFromTitle(title) lang = strUtil.getLangFromTitle(title) 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.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) # __ Add the element to the list elementList.append(element) # ___ Error during open last movie page else: miscFunctions.displayNotification('Unable to get top movie ') self.__LOGGER__.log( 'Connection ERROR : Failed to open page (' + self.buildHref(href) + ')', xbmc.LOGERROR) return elementList
def getMoviesItemFromContent(self, content): """ Method to get movie list @param content: the html content @return the StreamItem list """ elementList = [] soup = BeautifulSoup(content) # For every post, get title and topicLink movies = soup.find('div', { 'class': 'filmcontent' }).findAll('div', {'class': 'moviefilm'}) for index in range(0, len(movies)): movie = movies[index] title = movie.find('div', {'class': 'movief'}).text.encode('UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: " + title, xbmc.LOGDEBUG) href = movie.find('div', {'class': 'movief'}).find('a')['href'] year = strUtil.getYearFromTitle(title) quality = strUtil.getQualityFromTitle(title) lang = strUtil.getLangFromTitle(title) 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.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setSourceId(self.ID) # __ Add the element to the list elementList.append(element) return elementList
def searchMovie(self, title): """ Method to search a movie @return a list of StreamItem """ # Use get ?s=300 get_href = '?s=' + webUtil.encodeStr(title) response = self.openPage(get_href) elementList = [] if response and response.getcode() == 200: content = response.read() soup = BeautifulSoup(content) # For every post, get title and topicLink if soup.find('div', {'class': 'post-list group'}) is not None: movies = soup.find('div', { 'class': 'post-list group' }).findAll('article') else: return elementList for index in range(0, len(movies)): movie = movies[index] el = movie.find('h2', { 'class': 'post-title entry-title' }).find('a') title = el.text.encode('UTF-8') title = strUtil.unescapeHtml(str(title)) # Remove ' Film Complet en Streaming' title = self.removeFilmComplet(title) self.__LOGGER__.log("Finded title: " + title, xbmc.LOGDEBUG) href = el['href'] year = strUtil.getYearFromTitle(title) quality = strUtil.getQualityFromTitle(title) lang = strUtil.getLangFromTitle(title) 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.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setSourceId(self.ID) # __ Add the element to the list elementList.append(element) # ___ Error during search the movie else: miscFunctions.displayNotification('Unable to search Movie ' + title) self.__LOGGER__.log( 'Connection ERROR : Failed to open page (' + self.buildHref(get_href) + ')', xbmc.LOGERROR) return elementList
def getItemsFromContent(self,content,type): """ Method to get movie list @param content: the html content @param type: the type to extract @return the StreamItem list """ elementList = [] soup = BeautifulSoup(content) # For every post, get title and topicLink movies = soup.find('div',{'class':'list_f'}).findAll('li',{'class':'item'}) for index in range(0,len(movies)): movie = movies[index] link = movie.find('div',{'class':'info'}).find('h3',{'class':'name'}).find('a') title =link.text.encode('UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: "+title,xbmc.LOGDEBUG) href = link['href'] year = strUtil.getYearFromTitle(title) quality = strUtil.getQualityFromTitle(title) lang = strUtil.getLangFromTitle(title) 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.setSourceId(self.ID) # __ Get the type typePattern = re.compile('(http://papystreaming.org/)(.*?)(/.*?/)') match = typePattern.match(href) typeEl = None if match is not None: if match.group(2) == 'film': typeEl = StreamItem.TYPE_MOVIE element.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) elif match.group(2) == 'serie': typeEl = StreamItem.TYPE_TVSHOW element.setAction(StreamItem.ACTION_DISPLAY_SEASONS) element.setType(StreamItem.TYPE_TVSHOW) element.setTvShowName(title) if typeEl is not None and typeEl == int(type): # __ Get the poster poster = movie.find('img')['src'] element.setIconImage(poster) # __ Set the genre genre = movie.find('span',{'class':'genero'}).text.encode('UTF-8') element.setMetadataGenre(genre) # __ Add the element to the list elementList.append(element) return elementList
def searchMovie(self, title): """ Method to search a movie @return a list of StreamItem """ # Use post http://mega-stream.fr/recherche # # search:3 # post_href = '/recherche' # Data to post data = {'search':title} response = self.postPage(post_href, data) elementList = [] if response and response.getcode() == 200: content = response.read() soup = BeautifulSoup(content) # ___ The first sectio is for movie movies = soup.findAll('div',{'class':'section'})[0].findAll('div',{'class':'movie-item ignore-select'}) for index in range(0,len(movies)): movie = movies[index] title = movie.find('img')['alt'].encode('UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: "+title,xbmc.LOGDEBUG) href = movie.find('div',{'class':'movie-series'}).find('a')['href'] titleExtract = movie.find('div',{'class':'movie-series'}).find('a').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.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_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setSourceId(self.ID) element.setIconImage(movie.find('img')['src']) # __ Add the element to the list elementList.append(element) # ___ Error during search the movie else: miscFunctions.displayNotification('Unable to search Movie ' + title) self.__LOGGER__.log('Connection ERROR : Failed to open page (' + self.buildHref(post_href) + ')', xbmc.LOGERROR) return elementList
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