def getLastTvShow(self, streamItem=False): """ Method to get all last tv show @return a list of StreamItem """ href = '/' # ___ Initialize the list to return elementList = [] # ___ Get the response response = self.openPage(href) if response and response.getcode() == 200: content = response.read() linksPattern = re.compile( '(.*)(window\.__NUXT__=)(.*?)(;</script>)(.*)', re.DOTALL) match = linksPattern.match(content) if match is not None: jsonEl = json.loads(match.group(3)) for movie in jsonEl['data'][0]['nouveaux']['series']: title = movie['name'] href = '/series/' + strUtil.remove_special_char( title).replace(' ', '-').lower() + '-' + str( movie['customID']) + '.html' year = movie['releaseYear'] quality = movie['quality'] langClass = movie['language'] lang = None subtitle = None if langClass == 'vf': lang = 'FR' else: lang = 'VO' subtitle = 'FR' title = strUtil.cleanTitle(title) title = strUtil.deleteAccent(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) if subtitle is not None: element.setSubTitle(subtitle) element.setSourceId(self.ID) element.setId(str(movie['customID'])) element.setIconImage(movie['poster']) element.setTvShowName(title) element.setType(StreamItem.TYPE_TVSHOW) element.setAction(StreamItem.ACTION_DISPLAY_SEASONS) elementList.append(element) return elementList
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 searchMovie(self, title): """ Method to search a movie @return a list of StreamItem """ # Use get http://libertyvf.com/v2/search?q= href = '/v2/search?q=' + webUtil.encodeStr(title) response = self.openPage(href) elementList = [] if response and response.getcode() == 200: content = response.read() soup = BeautifulSoup(content) # ___ Get the div for movie moviesDiv = soup.find('div', {'id': 'films-search'}) if moviesDiv is not None: movies = moviesDiv.findAll( 'div', {'class': 'col-lg-3 col-md-3 col-sm-3 col-xs-6'}) for movie in movies: title = movie.find('figcaption').find('a').text.encode( 'UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: " + title, xbmc.LOGDEBUG) title = strUtil.cleanTitle(title) self.__LOGGER__.log("Clean title: " + str(title), xbmc.LOGDEBUG) # __ Create the element element = StreamItem(title) element.setHref( movie.find('figcaption').find('a')['href'].replace( '/films/', '/films/streaming/').replace('-telecharger-', '-')) element.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setIconImage(movie.find('img')['src']) 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(href) + ')', xbmc.LOGERROR) return elementList
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 getMoviesFromContent(self,content): """ Method to get movies from content @param: the html content @return the elementList """ elementList = [] soup = BeautifulSoup(content) movies = soup.findAll('div',{'class':'movie'}) for movie in movies: title = movie.find('div',{'class':'infos'}).find('a',{'class':'title'}).find('span').text.encode('UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: "+title,xbmc.LOGDEBUG) href = movie.find('div',{'class':'infos'}).find('a',{'class':'title'})['href'] quality = movie.find('div',{'class':'pic'}).find('span',{'class':'qualitos'}).text.encode('UTF-8') title = strUtil.cleanTitle(title) self.__LOGGER__.log("Clean title: "+str(title),xbmc.LOGDEBUG) # __ Create the element element = StreamItem(title) element.setHref(href) element.setQuality(quality) element.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setSourceId(self.ID) element.setIconImage(movie.find('div',{'class':'pic'}).find('img')['src']) element.setId(movie.find('div',{'class':'infos'}).find('a',{'data-type':'movie'})['data-id']) # ___ Get metadatas metadatas = movie.find('div',{'class':'infos'}) if metadatas is not None: genres = metadatas.findAll('p',{'class':'nop genre meta an'})[0].find('a').text.encode('UTF-8') element.setMetadataGenre(genres) year = metadatas.findAll('p',{'class':'nop genre meta an'})[1].find('a').text.encode('UTF-8') element.setMetadataYear(year) lang = strUtil.getLangFromTitle(metadatas.findAll('p',{'class':'nop genre meta an'})[2].find('img')['alt']) element.setLang(lang) overview = metadatas.find('p',{'class':'nop synopsis meta an'}) if overview is not None: element.setMetadataOverview(overview.text.encode('UTF-8')) # __ Add the element to the list elementList.append(element) return elementList
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
def getTopWeekTvShow(self,streamItem=False): """ Method to get top week tv show @return a list of StreamItem """ # ___ Initialize the list to return elementList = [] # ___ Get the soup href = '/accueil' response = self.openPage(href) if response and response.getcode() == 200: content = response.read() soup = BeautifulSoup(content) if soup is not None: movies = soup.findAll('div',{'class':'side-item side-colored'})[1].findAll('a',{'class':'short1-item clearfix'}) for movie in movies: title = movie.find('div',{'class':'short1-title'}).text.encode('UTF-8').strip() title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: "+title,xbmc.LOGDEBUG) href = movie['href'] 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.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) return elementList
def getTopWeekMovie(self,streamItem=False): """ Method to get top week movie @return a list of StreamItem """ # ___ Initialize the list to return elementList = [] href = '/' # ___ Get the soup response = self.openPage(href) if response and response.getcode() == 200: content = response.read() soup = BeautifulSoup(content) movies = soup.find('div',{'class':'coco owl-carousel'}).findAll('a',{'class':'item movie_single'}) for movie in movies: title = movie.find('h4').text.encode('UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: "+title,xbmc.LOGDEBUG) href = movie['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_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setSourceId(self.ID) element.setIconImage(self.buildHref(movie.find('img')['src'])) idPattern = re.compile('(http://streamay.ws/)(\d{1,6}?)(-.*)(\.html)') match = idPattern.match(href) if match is not None: element.setId(match.group(2)) # __ Add the element to the list elementList.append(element) 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 getTopMovie(self,streamItem=False): """ Method to get top movie @return a list of StreamItem """ # ___ Initialize the list to return elementList = [] href = '/top-films' # ___ 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.findAll('li',{ 'class':'tops-item'}) 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_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) 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 getMoviesItemFromContent(self, content, filter=False): """ Method to get movie list @param content: the html content @return the StreamItem list """ elementList = [] itemsPattern = re.compile( '(.*)(window\.__NUXT__=)(.*?)(;</script>)(.*)', re.DOTALL) match = itemsPattern.match(content) if match is not None: jsonEl = json.loads(match.group(3)) if not filter or filter == StreamItem.TYPE_MOVIE: for item in jsonEl['data'][0]['films']: title = item['name'] href = '/films/' + strUtil.remove_special_char( title).replace(' ', '-').lower() + '-' + str( item['customID']) + '.html' year = item['releaseYear'] quality = item['quality'] langClass = item['language'] lang = None subtitle = None if langClass == 'vf': 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.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setSourceId(self.ID) element.setId(str(item['customID'])) element.setIconImage(item['poster']) type = StreamItem.TYPE_MOVIE elementList.append(element) elif filter == StreamItem.TYPE_TVSHOW: for item in jsonEl['data'][0]['series']: title = item['name'] href = '/series/' + strUtil.remove_special_char( title).replace(' ', '-').lower() + '-' + str( item['customID']) + '.html' year = item['releaseYear'] quality = item['quality'] langClass = item['language'] lang = None subtitle = None if langClass == 'vf': 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.setSourceId(self.ID) element.setId(str(item['customID'])) element.setIconImage(item['poster']) element.setTvShowName(title) element.setType(StreamItem.TYPE_TVSHOW) element.setAction(StreamItem.ACTION_DISPLAY_SEASONS) type = StreamItem.TYPE_TVSHOW elementList.append(element) # For every post, get title and topicLink """ movies = soup.findAll('div',{ 'class':'column is-one-quarter-desktop is-half-mobile'}) for index in range(0,len(movies)): movie = movies[index] 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.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setSourceId(self.ID) element.setIconImage(movie.find('img')['src']) type = StreamItem.TYPE_MOVIE tvshowPattern = re.compile("(/series/)(.*)") print href match = tvshowPattern.match(href) if match is not None: element.setTvShowName(title) element.setType(StreamItem.TYPE_TVSHOW) element.setAction(StreamItem.ACTION_DISPLAY_SEASONS) type = StreamItem.TYPE_TVSHOW # __ Add the element to the list if not filter: elementList.append(element) elif type == int(filter): elementList.append(element) """ 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 closePopup(self): """ Method to close the current popup and search link """ streamItem = StreamItem(strUtil.remove_special_char(self.title)) streamItem.setType(StreamItem.TYPE_MOVIE) streamItem.setAction(StreamItem.ACTION_MORE_LINKS) streamItem.setIconImage(self.thumbnail) self.close() progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) listItems = sources.getMoreLinks( constant.__addon__.getSetting('default_stream_src'), streamItem, True) for item in listItems: item.setMetadata(streamItem.getMetadata()) # ___ Update the list of elements selectItems = [] if listItems is not None and len(listItems) > 0: if progress is not None: progress.update(0, constant.__addon__.getLocalizedString(70008)) listItems = metadata.getMetadataForList(StreamItem.TYPE_MOVIE, listItems, progress) for index in range(0, len(listItems)): item = listItems[index] item.regenerateKodiTitle() selectItems.append(item.getKodiTitle()) if progress is not None: progress.close() # ___ Display all StreamItem dialog = xbmcgui.Dialog() result = dialog.select(constant.__addon__.getLocalizedString(80030), selectItems) error = False while result > -1 or error: result = -1 # ___ Resolve url playableUrl = False progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70009)) try: playableUrl = urlresolver.resolve(listItems[result].getHref()) except: # ___ If the url is not resolved, display link choice again. error = True listItems[result].setKOLinkStatus() listItems[result].regenerateKodiTitle() selectItems[result] = listItems[result].getKodiTitle() result = dialog.select( constant.__addon__.getLocalizedString(80030), selectItems) progress.close() # ___If the url is resolved, display the the list of possibilities (Open in web browser, Play, Download or Download & Play ) if playableUrl != False and isinstance(playableUrl, unicode): listItems[result].setPlayableUrl(playableUrl) player.playVideo(listItems[result]) else: # ___ If the url is not resolved, display link choice again. error = False listItems[result].setKOLinkStatus() listItems[result].regenerateKodiTitle() selectItems[result] = listItems[result].getKodiTitle() result = dialog.select( constant.__addon__.getLocalizedString(80030), selectItems)
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 = [] typeEl = None results = json.loads(content) if results is not None and len(results)>0: for result in results: detail = result['result'] title =detail['title'].encode('UTF-8') title = strUtil.unescapeHtml(str(title)) self.__LOGGER__.log("Finded title: "+title,xbmc.LOGDEBUG) href = detail['url'] year=None quality=None lang=None if 'anneeProduction' in detail: year = detail['anneeProduction'] if 'qualite' in detail: quality = detail['qualite'] if 'langue' in detail: lang = strUtil.getLangFromTitle(detail['langue']) self.__LOGGER__.log("Clean title: "+str(title),xbmc.LOGDEBUG) # __ Create the element element = StreamItem(title) element.setHref(href) if year is not None: element.setYear(year) if quality is not None: element.setQuality(quality) if lang is not None: element.setLang(lang) element.setId(detail['id']) element.setSourceId(self.ID) # __ Get the type if result['type'] == 'Film': typeEl = StreamItem.TYPE_MOVIE element.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) elif strUtil.deleteAccent(result['type']) == 'Serie': typeEl = StreamItem.TYPE_TVSHOW element.setAction(StreamItem.ACTION_DISPLAY_SEASONS) element.setType(StreamItem.TYPE_TVSHOW) element.setTvShowName(title) elif result['type'] == 'Manga': typeEl = StreamItem.TYPE_ANIME element.setAction(StreamItem.ACTION_DISPLAY_EPISODES) element.setType(StreamItem.TYPE_ANIME) element.setTvShowName(title) if typeEl is not None and typeEl == int(type): # __ Get the poster element.setIconImage(self.buildHref('/cdn/img/'+detail['img'])) # __ Set the genre if 'genre' in detail: element.setMetadataGenre(detail['genre']) # __ Add the element to the list elementList.append(element) return elementList
def router(params): """ Router function that calls other functions depending on the provided paramstring @param params: string slicing to trim the leading '?' from the plugin call paramstring """ #params = dict(parse_qsl(paramstring)) paramsItem = StreamItem(params=params) # ___ Google Analytics if constant.__kodiVersion__ >= 17: t = ga.GAThread(paramsItem) t.start() # ___ Get the source __SOURCE__ = sources.getStreaminSource( constant.__addon__.getSetting('default_stream_src')) # ___ If the source of the streamItem is not None if paramsItem.getSourceId() is not None and len( paramsItem.getSourceId()) > 0: # ___ If the source of the streamItem is not the selected source in settings if paramsItem.getSourceId() != constant.__addon__.getSetting( 'default_stream_src'): # ___ Change the source with the item's source __SOURCE__ = sources.getStreaminSource(paramsItem.getSourceId()) # ___ Check the parameters passed to the plugin if params: listItems = [] progress = None # ___ Display list of link when launch the addon from .strm file if 'strm' in params and int(params['strm']) == 1: # ___ Google Analytics if constant.__kodiVersion__ >= 17: t = ga.GAThread(paramsItem, 'strm') t.start() progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) # __ MOVIE LINK if int(params['type']) == StreamItem.TYPE_MOVIE or int( params['type']) == StreamItem.TYPE_MOVIE_HD: listItems = __SOURCE__.getMovieLink(paramsItem) # __ TV SHOW LINK elif int(params['type']) == StreamItem.TYPE_TVSHOW_EPISODE: listItems = __SOURCE__.getTvShowEpisodeLink(paramsItem) # __ ANIME LINK elif int(params['type']) == StreamItem.TYPE_ANIME_EPISODE: listItems = __SOURCE__.getAnimeEpisodeLink(paramsItem) # __ SHOW LINK elif int(params['type']) == StreamItem.TYPE_SHOW: listItems = __SOURCE__.getShowLink(paramsItem) # __ DOCUMENTARY LINK elif int(params['type']) == StreamItem.TYPE_DOCUMENTARY: listItems = __SOURCE__.getDocumentaryLink(paramsItem) progress.close() player.playStrm(listItems) # ___ Use cache if the cached page is the requested page # ___ Functionnality used until Kodi fix the cacheToDisc problem if cacheFunctions.isCachedPage(params) and int( params['action']) != StreamItem.ACTION_DISPLAY_MENU: listItems = cacheFunctions.getPreviousCachedPage() # ___ MAIN MENU elif int(params['action']) == StreamItem.ACTION_DISPLAY_MENU: cacheFunctions.clearCache() __SOURCE__.build_menu() # ___ TYPE MENU elif paramsItem.getAction() == StreamItem.ACTION_DISPLAY_TYPE_MENU: # ___ Movie Menu if int(params['type']) == StreamItem.TYPE_MOVIE: __SOURCE__.build_movie_menu() # ___ Movie HD Menu elif int(params['type']) == StreamItem.TYPE_MOVIE_HD: __SOURCE__.build_movie_hd_menu() # ___ Tvshow Menu elif int(params['type']) == StreamItem.TYPE_TVSHOW: __SOURCE__.build_tv_show_menu() # ___ Anime Menu elif int(params['type']) == StreamItem.TYPE_ANIME: __SOURCE__.build_anime_menu() # ___ Show Menu elif int(params['type']) == StreamItem.TYPE_SHOW: __SOURCE__.build_show_menu() # ___ Documentary Menu elif int(params['type']) == StreamItem.TYPE_DOCUMENTARY: __SOURCE__.build_documentary_menu() # ___ CATEGORIE MENU elif int(params['action']) == StreamItem.ACTION_DISPLAY_CATEGORIE_MENU: # __ Alphabetic if int(params['subtype']) == StreamItem.SUBTYPE_ALPHABETICS: __SOURCE__.build_alphabetic_category(int(params['type'])) # __ Genre if int(params['subtype']) == StreamItem.SUBTYPE_GENRE: __SOURCE__.build_genre_category(int(params['type'])) # __ DISPLAY LIST elif int(params['action']) == StreamItem.ACTION_DISPLAY_TYPE_LIST: progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) # ___ MOVIE LIST if int(params['type']) == StreamItem.TYPE_MOVIE or int( params['type']) == StreamItem.TYPE_MOVIE_HD: # __ Last if int(params['subtype']) == StreamItem.SUBTYPE_LAST: listItems = __SOURCE__.getLastMovie(paramsItem) # __ Top elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_RATE: listItems = __SOURCE__.getTopMovie(paramsItem) # __ Top week elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_WEEK: listItems = __SOURCE__.getTopWeekMovie(paramsItem) # __ Most view elif int(params['subtype']) == StreamItem.SUBTYPE_MOST_VIEW: listItems = __SOURCE__.getMostViewMovie(paramsItem) # __ Exclue elif int(params['subtype']) == StreamItem.SUBTYPE_EXCLUE: listItems = __SOURCE__.getExclueMovie(paramsItem) # __ List elif int(params['subtype']) == StreamItem.SUBTYPE_LIST: listItems = __SOURCE__.getMovieList(paramsItem) # ___ TVSHOW LIST elif int(params['type']) == StreamItem.TYPE_TVSHOW: #__ Last if int(params['subtype']) == StreamItem.SUBTYPE_LAST: listItems = __SOURCE__.getLastTvShow(paramsItem) # __ Top elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_RATE: listItems = __SOURCE__.getTopTvShow(paramsItem) # __ Top week elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_WEEK: listItems = __SOURCE__.getTopWeekTvShow(paramsItem) # __ Most view elif int(params['subtype']) == StreamItem.SUBTYPE_MOST_VIEW: listItems = __SOURCE__.getMostViewTvShow(paramsItem) # __ List elif int(params['subtype']) == StreamItem.SUBTYPE_LIST: listItems = __SOURCE__.getTvShowList(paramsItem) # ___ ANIME LIST elif int(params['type']) == StreamItem.TYPE_ANIME: #__ Last if int(params['subtype']) == StreamItem.SUBTYPE_LAST: listItems = __SOURCE__.getLastAnime(paramsItem) # __ Top elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_RATE: listItems = __SOURCE__.getTopAnime(paramsItem) # __ Top week elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_WEEK: listItems = __SOURCE__.getTopWeekAnime(paramsItem) # __ Most view elif int(params['subtype']) == StreamItem.SUBTYPE_MOST_VIEW: listItems = __SOURCE__.getMostViewAnime(paramsItem) # __ List elif int(params['subtype']) == StreamItem.SUBTYPE_LIST: listItems = __SOURCE__.getAnimeList(paramsItem) # ___ SHOW LIST elif int(params['type']) == StreamItem.TYPE_SHOW: #__ Last if int(params['subtype']) == StreamItem.SUBTYPE_LAST: listItems = __SOURCE__.getLastShow(paramsItem) # __ Top elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_RATE: listItems = __SOURCE__.getTopShow(paramsItem) # __ Top week elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_WEEK: listItems = __SOURCE__.getTopWeekShow(paramsItem) # __ Most view elif int(params['subtype']) == StreamItem.SUBTYPE_MOST_VIEW: listItems = __SOURCE__.getMostViewShow(paramsItem) # ___ DOCUMENTARY LIST elif int(params['type']) == StreamItem.TYPE_DOCUMENTARY: #__ Last if int(params['subtype']) == StreamItem.SUBTYPE_LAST: listItems = __SOURCE__.getLastDocumentary(paramsItem) # __ Top elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_RATE: listItems = __SOURCE__.getTopDocumentary(paramsItem) # __ Top week elif int(params['subtype']) == StreamItem.SUBTYPE_TOP_WEEK: listItems = __SOURCE__.getTopWeekDocumentary(paramsItem) # __ Most view elif int(params['subtype']) == StreamItem.SUBTYPE_MOST_VIEW: listItems = __SOURCE__.getMostViewDocumentary(paramsItem) # ___ DISPLAY CATEGORIE LIST elif int(params['action']) == StreamItem.ACTION_DISPLAY_CATEGORIE_LIST: progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) # ___ MOVIE LIST if int(params['type']) == StreamItem.TYPE_MOVIE: # __ Alphabetic if int(params['subtype']) == StreamItem.SUBTYPE_ALPHABETICS: listItems = __SOURCE__.getAlphabeticMovieList(paramsItem) # __ Genre if int(params['subtype']) == StreamItem.SUBTYPE_GENRE: listItems = __SOURCE__.getMovieListByGenre(paramsItem) # ___ MOVIE HD LIST elif int(params['type']) == StreamItem.TYPE_MOVIE_HD: # __ Alphabetic if int(params['subtype']) == StreamItem.SUBTYPE_ALPHABETICS: listItems = __SOURCE__.getAlphabeticMovieHDList(paramsItem) # ___ TVSHOW LIST elif int(params['type']) == StreamItem.TYPE_TVSHOW: #__ Alphabetic if int(params['subtype']) == StreamItem.SUBTYPE_ALPHABETICS: listItems = __SOURCE__.getAlphabeticTvShowList(paramsItem) # ___ ANIME LIST elif int(params['type']) == StreamItem.TYPE_ANIME: #__ Alphabetic if int(params['subtype']) == StreamItem.SUBTYPE_ALPHABETICS: listItems = __SOURCE__.getAlphabeticAnimeList(paramsItem) # ___ SHOW LIST elif int(params['type']) == StreamItem.TYPE_SHOW: # __ Alphabetic if int(params['subtype']) == StreamItem.SUBTYPE_ALPHABETICS: listItems = __SOURCE__.getAlphabeticShowList(paramsItem) # ___ DOCUMENTARY LIST elif int(params['type']) == StreamItem.TYPE_DOCUMENTARY: # __ Alphabetic if int(params['subtype']) == StreamItem.SUBTYPE_ALPHABETICS: listItems = __SOURCE__.getAlphabeticDocumentaryList( paramsItem) # ___ DISPLAY SEASON FOR ANIME OR TVSHOW elif int(params['action']) == StreamItem.ACTION_DISPLAY_SEASONS: progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) if int(params['type']) == StreamItem.TYPE_TVSHOW: listItems = __SOURCE__.getTvShowSeasons(paramsItem) elif int(params['type']) == StreamItem.TYPE_ANIME: listItems = __SOURCE__.getAnimeSeasons(paramsItem) # ___ DISPLAY EPISODES FOR ANIME OR TVSHOW elif int(params['action']) == StreamItem.ACTION_DISPLAY_EPISODES: progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) if int(params['type']) == StreamItem.TYPE_TVSHOW_SEASON: listItems = __SOURCE__.getTvShowEpisodes(paramsItem) elif int(params['type']) == StreamItem.TYPE_ANIME_SEASON: listItems = __SOURCE__.getAnimeEpisodes(paramsItem) # ___ DISPLAY LINKS elif int( params['action'] ) == StreamItem.ACTION_DISPLAY_LINKS and constant.__addon__.getSetting( 'links_in_dialog') == 'false': progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) # __ MOVIE LINK if int(params['type']) == StreamItem.TYPE_MOVIE or int( params['type']) == StreamItem.TYPE_MOVIE_HD: listItems = __SOURCE__.getMovieLink(paramsItem) # __ TV SHOW LINK elif int(params['type']) == StreamItem.TYPE_TVSHOW_EPISODE: listItems = __SOURCE__.getTvShowEpisodeLink(paramsItem) # __ ANIME LINK elif int(params['type']) == StreamItem.TYPE_ANIME_EPISODE: listItems = __SOURCE__.getAnimeEpisodeLink(paramsItem) # __ SHOW LINK elif int(params['type']) == StreamItem.TYPE_SHOW: listItems = __SOURCE__.getShowLink(paramsItem) # __ DOCUMENTARY LINK elif int(params['type']) == StreamItem.TYPE_DOCUMENTARY: listItems = __SOURCE__.getDocumentaryLink(paramsItem) # __ Add "More links" button moreLink = paramsItem.copy() moreLink.setAction(StreamItem.ACTION_MORE_LINKS) moreLink.regenerateKodiTitle() listItems.append(moreLink) # ___ Filter the links list listItems = miscFunctions.filterLinksList(listItems) # ___ GET MORE LINKS elif int( params['action'] ) == StreamItem.ACTION_MORE_LINKS and constant.__addon__.getSetting( 'links_in_dialog') == 'false': progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) listItems = sources.getMoreLinks( constant.__addon__.getSetting('default_stream_src'), paramsItem) for item in listItems: item.setMetadata(paramsItem.getMetadata()) # ___ Filter the links list listItems = miscFunctions.filterLinksList(listItems) # ___ SEARCH MOVIE, TVSHOW, ANIME ETC ... elif int(params['action']) == StreamItem.ACTION_SEARCH: keyboardInput = xbmc.Keyboard( '', constant.__addon__.getLocalizedString(33048), False) keyboardInput.doModal() # ___ If we search something if keyboardInput.isConfirmed(): # Take the input text title = keyboardInput.getText() progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) if int(params['type']) == StreamItem.TYPE_MOVIE: listItems = __SOURCE__.searchMovie(title) elif int(params['type']) == StreamItem.TYPE_MOVIE_HD: listItems = __SOURCE__.searchMovie(title) elif int(params['type']) == StreamItem.TYPE_TVSHOW: listItems = __SOURCE__.searchTvShow(title) elif int(params['type']) == StreamItem.TYPE_ANIME: listItems = __SOURCE__.searchAnime(title) elif int(params['type']) == StreamItem.TYPE_SHOW: listItems = __SOURCE__.searchShow(title) elif int(params['type']) == StreamItem.TYPE_DOCUMENTARY: listItems = __SOURCE__.searchDocumentary(title) # ___ DISPLAY LINKS IN DIALOG elif int( params['action'] ) == StreamItem.ACTION_DISPLAY_LINKS and constant.__addon__.getSetting( 'links_in_dialog') == 'true': # __ MOVIE LINK if int(params['type']) == StreamItem.TYPE_MOVIE or int( params['type']) == StreamItem.TYPE_MOVIE_HD: listItems = __SOURCE__.getMovieLink(paramsItem) # __ TV SHOW LINK elif int(params['type']) == StreamItem.TYPE_TVSHOW_EPISODE: listItems = __SOURCE__.getTvShowEpisodeLink(paramsItem) # __ ANIME LINK elif int(params['type']) == StreamItem.TYPE_ANIME_EPISODE: listItems = __SOURCE__.getAnimeEpisodeLink(paramsItem) # __ SHOW LINK elif int(params['type']) == StreamItem.TYPE_SHOW: listItems = __SOURCE__.getShowLink(paramsItem) # __ DOCUMENTARY LINK elif int(params['type']) == StreamItem.TYPE_DOCUMENTARY: listItems = __SOURCE__.getDocumentaryLink(paramsItem) # __ Add "More links" button moreLink = paramsItem.copy() moreLink.setAction(StreamItem.ACTION_MORE_LINKS) moreLink.regenerateKodiTitle() listItems.append(moreLink) # ___ Filter the links list listItems = miscFunctions.filterLinksList(listItems) player.displayLinksInDialog(listItems) # ___ GET MORE LINKS IN DIALOG elif int( params['action'] ) == StreamItem.ACTION_MORE_LINKS and constant.__addon__.getSetting( 'links_in_dialog') == 'true': listItems = sources.getMoreLinks( constant.__addon__.getSetting('default_stream_src'), paramsItem) for item in listItems: item.setMetadata(paramsItem.getMetadata()) # ___ Filter the links list listItems = miscFunctions.filterLinksList(listItems) player.displayLinksInDialog(listItems) # ___ DISPLAY VIDEO OPTION elif int(params['action']) == StreamItem.ACTION_PLAY: # ___ Google Analytics if constant.__kodiVersion__ >= 17: t = ga.GAThread(paramsItem) t.start() player.displayVideoOptions(paramsItem) # ___ SETTINGS MENU elif int(params['action']) == StreamItem.ACTION_DISPLAY_MENU_SETTINGS: __SOURCE__.build_settings_menu() # ___ SETTINGS elif int(params['action']) == StreamItem.ACTION_DISPLAY_SETTINGS: constant.__addon__.openSettings() # ___ METAHANDLER SETTINGS elif int(params['action'] ) == StreamItem.ACTION_DISPLAY_METAHANDLER_SETTINGS: xbmcaddon.Addon(id='script.module.metahandler').openSettings() # ___ URLRESOLVER SETTINGS elif int(params['action'] ) == StreamItem.ACTION_DISPLAY_URLRESOLVER_SETTINGS: xbmcaddon.Addon(id='script.module.urlresolver').openSettings() # ___ DOWNLOAD elif int(params['action']) == StreamItem.ACTION_DOWNLOAD: miscFunctions.downloadFile(paramsItem, playAtEnd=False) # ___ DOWNLOAD MANAGER elif int(params['action'] ) == StreamItem.ACTION_DISPLAY_DOWNLOAD_MANAGER: dlMod = downloaderModule.getDownloadModule( constant.__addon__.getSetting('downloader_module')) DownloaderManager.displayDownloadManager(__handle__, dlMod) # ___ PLAY TRAILER elif int(params['action']) == StreamItem.ACTION_PLAY_TRAILER: youtubeTrailer = YoutubeTrailer() youtubeTrailer.playTrailer(params['title']) # ___ WATAMOVIE SEARCH elif int(params['action']) == StreamItem.ACTION_SEARCH_WATAMOVIE: watam = Filmou() watam.doModal() del watam # ___ GLOBAL SEARCH elif int(params['action']) == StreamItem.ACTION_GLOBAL_SEARCH: keyboardInput = xbmc.Keyboard( '', constant.__addon__.getLocalizedString(33048), False) keyboardInput.doModal() # ___ If we search something if keyboardInput.isConfirmed(): # Take the input text title = keyboardInput.getText() progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70007)) if int(params['type']) == StreamItem.TYPE_MOVIE: listItems = sources.searchMovie(title) elif int(params['type']) == StreamItem.TYPE_MOVIE_HD: listItems = sources.searchMovie(title) elif int(params['type']) == StreamItem.TYPE_TVSHOW: listItems = sources.searchTvShow(title) elif int(params['type']) == StreamItem.TYPE_ANIME: listItems = sources.searchAnime(title) # ___ Get synopsis of selected item elif int(params['action']) == StreamItem.ACTION_GET_SYNOPSIS: progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70008)) titleToSearch = params['title'] params = cacheFunctions.getCachedParams() listItems = cacheFunctions.getCachedPage() listItems = metadata.getMetadataFromContextMenu( listItems, titleToSearch, progress) # ___ Change streaming source elif int(params['action']) == StreamItem.ACTION_CHANGE_STREAMING_SRC: sources.changeSrcDialog() xbmc.executebuiltin( 'Container.Update(plugin://plugin.video.seko.ultrastream/)') # ___ Favorite menu elif int(params['action']) == StreamItem.ACTION_DISPLAY_FAVORITES: import favoriteUtil jsonResults = favoriteUtil.favUtil.getFavorites(int( params['type'])) listItems = [] for jsonR in jsonResults: sItem = StreamItem(params=jsonR) sItem.setFavoriteItem(True) listItems.append(sItem) deleteAllFav = StreamItem( constant.__addon__.getLocalizedString(40045)) deleteAllFav.setType(int(params['type'])) deleteAllFav.setAction(StreamItem.ACTION_REMOVE_ALL_FAVORITE) listItems.append(deleteAllFav) # ___ Add to favorite elif int(params['action']) == StreamItem.ACTION_ADD_TO_FAVORITE: import favoriteUtil params['action'] = params['actionItem'] favoriteUtil.favUtil.createFavorite(params['type'], params) # ___ Remove from favorite elif int(params['action']) == StreamItem.ACTION_REMOVE_FROM_FAVORITE: import favoriteUtil params['action'] = params['actionItem'] favoriteUtil.favUtil.deleteHistory(params) jsonResults = favoriteUtil.favUtil.getFavorites(int( params['type'])) listItems = [] for jsonR in jsonResults: sItem = StreamItem(params=jsonR) sItem.setFavoriteItem(True) listItems.append(sItem) deleteAllFav = StreamItem( constant.__addon__.getLocalizedString(40045)) deleteAllFav.setType(int(params['type'])) deleteAllFav.setAction(StreamItem.ACTION_REMOVE_ALL_FAVORITE) listItems.append(deleteAllFav) # ___ Remove all favorite elif int(params['action']) == StreamItem.ACTION_REMOVE_ALL_FAVORITE: import favoriteUtil favoriteUtil.favUtil.deleteAll() jsonResults = favoriteUtil.favUtil.getFavorites(int( params['type'])) listItems = [] for jsonR in jsonResults: sItem = StreamItem(params=jsonR) sItem.setFavoriteItem(True) listItems.append(sItem) deleteAllFav = StreamItem( constant.__addon__.getLocalizedString(40045)) deleteAllFav.setType(int(params['type'])) deleteAllFav.setAction(StreamItem.ACTION_REMOVE_ALL_FAVORITE) listItems.append(deleteAllFav) # ___ TEST ACTION elif int(params['action']) == StreamItem.ACTION_TEST: """ params = {'subtitle': 'None', 'hostName': 'Allvid', 'isFolder': False, 'href': 'http://allvid.ch/embed-fdyng0r2n5sj.html/', 'playableUrl': u'http://212.7.213.12/oxyi6vzxwemxxkpdr63fvt4foq2yobougu6gav3wns6wujleoiojuc2mhdsa/v.mp4', 'year': '', 'quality': 'DVDRIP', 'id': '23350', 'title': 'Insaisissables 2', 'type': 102, 'metadata': '', 'dbTitle': 'Insaisissables 2', 'iconImage': 'DefaultMovies.png', 'season': '', 'tvShow': '', 'lang': 'None', 'episode': '', 'dbTvShow': '', 'sourceId': '', 'subtype_value': '', 'subtype': 0, 'kodi_title': '[B]Insaisissables 2[/B]', 'action': 18, 'page': ''} fileToDl = StreamItem("Insaisissables 2", params) miscFunctions.downloadFile(fileToDl, False) """ """ listItem = __SOURCE__.getTopWeekMovie() if listItems is not None and len(listItems) > 0 : listItems = metadata.getMetadataForList(listItem[0].getType(), listItems,None) for item in listItem: item.writeStrmFile('D:\\test') item.writeNfoFile('D:\\test') """ pass # ___ Update the list of elements if listItems is not None and len(listItems) > 0: if progress is not None: progress.update(0, constant.__addon__.getLocalizedString(70008)) else: progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70008)) listItems = metadata.getMetadataForList(params['type'], listItems, progress) # ___ Cached the current page before displaying it # ___ Functionnality used until Kodi fix the cacheToDisc problem if int(params['action']) != StreamItem.ACTION_DISPLAY_MENU and \ int(params['action']) != StreamItem.ACTION_DISPLAY_TYPE_MENU and \ int(params['action']) != StreamItem.ACTION_DISPLAY_CATEGORIE_MENU and \ int(params['action']) != StreamItem.ACTION_DISPLAY_DOWNLOAD_MANAGER and \ int(params['action']) != StreamItem.ACTION_GLOBAL_SEARCH and \ int(params['action']) != StreamItem.ACTION_SEARCH_WATAMOVIE and \ int(params['action']) != StreamItem.ACTION_SEARCH and \ int(params['action']) != StreamItem.ACTION_PLAY and \ int(params['action']) != StreamItem.ACTION_PLAY_TRAILER and \ int(params['action']) != StreamItem.ACTION_DOWNLOAD and \ int(params['action']) < StreamItem.ACTION_DISPLAY_MENU_SETTINGS: cacheFunctions.cachePage(params, listItems) # ___ Close the progress dialog if progress is not None: progress.close() # ___ Display all StreamItem miscFunctions.displayStreamItem(listItems) else: cacheFunctions.clearCache() __SOURCE__.build_menu()
def getMovieList(self, streamItem=False): """ Method to get a list of movie @return a list of StreamItem """ href = '/categories/films/page/1' page = 1 if streamItem and streamItem.isPage(): page = streamItem.getPage() href = streamItem.getHref() # ___ Initialize the list to return elementList = [] # ___ Get the response response = self.openPage(href) if response and response.getcode() == 200: content = response.read() linksPattern = re.compile( '(.*)(window\.__NUXT__=)(.*?)(;</script>)(.*)', re.DOTALL) match = linksPattern.match(content) if match is not None: jsonEl = json.loads(match.group(3)) for movie in jsonEl['data'][0]['elements']: href = '/films/' + strUtil.remove_special_char( movie['name']).replace(' ', '-').lower() + '-' + str( movie['customID']) + '.html' year = movie['releaseYear'] quality = movie['quality'] langClass = movie['language'] lang = None subtitle = None if langClass == 'vf': lang = 'FR' else: lang = 'VO' subtitle = 'FR' title = strUtil.cleanTitle(movie['name']) title = strUtil.deleteAccent(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) if subtitle is not None: element.setSubTitle(subtitle) element.setAction(StreamItem.ACTION_DISPLAY_LINKS) element.setType(StreamItem.TYPE_MOVIE) element.setSourceId(self.ID) element.setId(str(movie['customID'])) element.setIconImage(movie['poster']) elementList.append(element) if streamItem: element = streamItem.copy() page = page + 1 element.setType(StreamItem.TYPE_PAGE) element.setPage(page) element.setTitle('Page ' + str(element.getPage())) element.setHref('/categories/films/page/' + str(page)) elementList.append(element) else: page = page + 1 element = StreamItem('Page ' + str(element.getPage())) element.setType(StreamItem.TYPE_PAGE) element.setPage(page) element.setTitle('Page ' + str(element.getPage())) element.setAction(StreamItem.ACTION_DISPLAY_TYPE_LIST) element.setSubType(StreamItem.SUBTYPE_LIST) element.setHref('/categories/films/page/' + str(page)) 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 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