def isEquals(str1, str2): str1 = strUtil.remove_special_char(str1) str1 = strUtil.deleteAccent(str1) str2 = strUtil.remove_special_char(str2) str2 = strUtil.deleteAccent(str2) return str1.upper() == str2.upper()
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 setTitle(self, title): """ Setter for the title """ self.Item[ 'title'] = title #strUtil.unescapeHtml(title) #strUtil.normalize(title) self.Item['dbTitle'] = strUtil.deleteAccent( strUtil.remove_special_char(self.Item['title'])) self.regenerateKodiTitle()
def searchTrailer(self, title): """ Method to search a trailer @param title: the movie title @return the youtube id """ searchParam = strUtil.deleteAccent(title) + ' ' + str( constant.__addon__.getLocalizedString(70012)) href = 'https://www.youtube.com/results?q=' + webUtil.encodeStr( searchParam) self.__LOGGER__.log(href, xbmc.LOGDEBUG) request = urllib2.Request(href, headers=webUtil.HEADER_CFG) response = None try: response = self.urlOpener.open(request) except urllib2.HTTPError as e: response = e except: traceback.print_exc() miscFunctions.displayNotification( 'Error during searching trailer for ' + title) if response and response.getcode() == 200: # ___ Read the source content = response.read() # ___ Initialize BeautifulSoup soup = BeautifulSoup(content) link = soup.find( 'a', { 'class': re.compile( '(yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-sessionlink)(.*)(spf-link)(.*)' ) }) patternIdYoutube = re.compile('(\/watch\?v=)(.*)') match = patternIdYoutube.match(link['href']) if match is not None: id = match.group(2) self.__LOGGER__.log('id = ' + id, xbmc.LOGDEBUG) return id return None
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 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