Esempio n. 1
0
 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
Esempio n. 2
0
    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
Esempio n. 3
0
 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  
Esempio n. 4
0
    def getTvShowList(self, streamItem=False):
        """
            Method to get a list of tvshow
            @return a list of StreamItem        
        """

        href = '/categories/series-tv/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']:

                    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)

                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/series-tv//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/series-tv//page/' + str(page))
                    elementList.append(element)

        return elementList
Esempio n. 5
0
    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