Example #1
0
    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
Example #2
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
    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
Example #4
0
 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
Example #5
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
 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
Example #7
0
 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 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
Example #9
0
 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
Example #10
0
 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
Example #11
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  
Example #12
0
    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
Example #13
0
    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
Example #14
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
Example #15
0
    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)
Example #16
0
    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