示例#1
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
示例#2
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