def __init__( self ):
     if common.args.mode == 'Movie' and common.settings['flat_movie_cats']:
         xbmcplugin.setContent(int(sys.argv[1]), 'movies')
         self.addMoviesList()
         xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
     elif common.args.mode == 'Movie_List':
         xbmcplugin.setContent(int(sys.argv[1]), 'movies')
         self.addMoviesList()
         xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
     elif common.args.mode == 'Movie_Items':
         xbmcplugin.setContent(int(sys.argv[1]), 'movies')
         self.addVideosList()
         xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
     elif common.args.mode == 'Movie_Clips':
         xbmcplugin.setContent(int(sys.argv[1]), 'movies')
         self.addClipsList()
         #it is better to end the directory list in the function
         #it looks f**k-tarded if no clips are found and we end it here.
     else:
         self.addCategories()
         #ADD 'ALL SHOWS' to Main Category
         if common.args.mode == "Movie":
             #space in string ' All Movies' ensures it is at top of sorted list
             common.addDirectory(' All Movies', common.args.url, 'Movie_List')
             xbmcplugin.setContent(int(sys.argv[1]), 'movies')
             xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
         elif common.args.mode.startswith("Movie_cat"):
             self.addMoviesList() #if we're in a category view, add videos that match the selected category
             xbmcplugin.setContent(int(sys.argv[1]), 'movies')
             if common.args.mode=="Movie_cat_sub2":
                 xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ]), updateListing=True ) #if we're going into subcategories, don't add to heirchy
             else:
                 xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
 def __init__( self ):
     if common.args.mode == 'TV' and common.settings['flat_tv_cats']:
         xbmcplugin.setContent(int(sys.argv[1]), 'tvshows')
         self.addShowsList()
         xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
     elif common.args.mode == 'TV_List':
         xbmcplugin.setContent(int(sys.argv[1]), 'tvshows')
         self.addShowsList()
         xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
     elif common.args.mode == 'TV_Seasons':
         self.addSeasonList()
     elif common.args.mode == 'TV_Episodes':
         xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
         self.addEpisodeList()
         xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
     elif common.args.mode == 'TV_Clips':
         xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
         self.addClipsList()
     else:
         xbmcplugin.setContent(int(sys.argv[1]), 'tvshows')
         self.addCategories()
         #ADD 'ALL SHOWS' to Main Category List
         if common.args.mode == "TV":
             #space in string ' All Shows' ensures it is at top of sorted list
             common.addDirectory(' '+xbmc.getLocalizedString(30070), common.args.url, 'TV_List')
             xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
         elif common.args.mode.startswith("TV_cat"):
             self.addShowsList() #if we're in a category view, add videos that match the selected category
             xbmcplugin.setContent(int(sys.argv[1]), 'tvshows')
             if common.args.mode=="TV_cat_sub2":
                 xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ]), updateListing=True ) #if we're going into subcategories, don't add to heirchy
             else:
                 xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
    def addSeasonList( self ):
        tree=MinimalSoup(common.getHTML(common.args.url))  
        seasons=tree.findAll('td', attrs={"class":re.compile('^vex')})
        #flatten seasons by settings
        if common.settings['flat_season'] == 1 or (len(seasons) == 1 and common.settings['flat_season'] == 0):
            common.args.mode='TV_Episodes'
            seasonNums=[]
            for season in seasons:
                common.args.name = season.contents[0]
                seasonNums.append(season.contents[0])
                self.addEpisodeList( )
            #add clips folder
            rss=tree.findAll('a', attrs={'class':'rss-link'})
            clipRSS = None
            for feed in rss:
                if feed['href'].split('/')[-1]=='clips':
                    clipRSS = feed['href']
            if clipRSS != None:
                common.addDirectory(xbmc.getLocalizedString(30095), clipRSS, "TV_Clips")
            xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))

        else:
            #add one folder for each season
            for season in seasons:
                name=season.contents[0]
                p=re.compile('"(http://.+?)"')
                url=p.findall(season['onclick'])
                url=url[0].replace('&','&')
                ok=common.addDirectory(name, common.args.url, "TV_Episodes")
            #add clips folder
            rss=tree.findAll('a', attrs={'class':'rss-link'})
            for feed in rss:
                if feed['href'].split('/')[-1]=='clips': clipRSS = feed['href']
            common.addDirectory(xbmc.getLocalizedString(30095), clipRSS, "TV_Clips")
            xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
    def addListings ( self ):
        xmlsoup = BeautifulStoneSoup(common.getHTML( common.args.url ))
        items = xmlsoup.findAll('item')
        for item in items:
            name = item.title.contents[0]
            url  = item.guid.contents[0]
            try:
                try:
                    p = re.compile('<p>(.+?)</p>')
                    plot = p.findall(item.description.contents[0])[0]
                except:
                    p = re.compile('<p>(.+?)</p>')
                    plot = p.findall(str(item.description))[0]
            except:
                plot = 'Unavaliable'
            try:
                p = re.compile('media:thumbnail.+?url="(.+?)"')
                thumb = p.findall(str(item))[0]
            except:
                thumb = ''
            try:
                fanart = 'http://assets.hulu.com/shows/key_art_'+name.split(':')[0].replace('-','_').replace(' ','_').replace('\'','').replace('"','').lower()+'.jpg'
            except:
                fanart = ''

            genre = common.args.name

            if common.args.name == 'Recently Added Shows':
                common.addDirectory(name, url, 'RSS_Shows', thumb, thumb, fanart, plot, genre)
            else:
                common.addDirectory(name, url, 'RSS_play', thumb, thumb, fanart, plot, genre)
Beispiel #5
0
    def addEpisodeList(self):

        print " \n\n adding episodes \n\n"

        content = common.getHTML(common.args.url)

        # get the RSS feed URL and slurp it
        rssURL = re.compile('var _rssURL = "(.+?)";').findall(
            content)[0].replace('%26', '&')
        content = common.getHTML(rssURL)

        # title, watchURL, plot, thumbnail
        episodeInfo = re.compile(
            '<item>.+?<title>.+?CDATA\[(.+?)\].+?<link>(.+?id=\d+).+?</link>.+?<description>.+?CDATA\[(.+?)\].+?thumbnail.+?url="(.+?)"',
            re.DOTALL).findall(content, re.DOTALL)

        # add episodes
        for title, watchURL, plot, thumbnail in episodeInfo:
            # see if we want plots
            plot = (
                '',
                common.cleanNames(plot))[common.settings['get_episode_plot']]
            common.addDirectory(common.cleanNames(title), watchURL,
                                'TV_play_usa', thumbnail, thumbnail,
                                common.args.fanart, plot, 'genre')
    def addShowsList( self ):
        xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_LABEL)
        xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_GENRE)

        html=common.getHTML(common.args.url)
        tree=MinimalSoup(html)
        shows=tree.findAll('a', attrs={"class":"show-thumb info_hover"})
        del html
        del tree
        # with clips
        for show in shows:
            name  = show.contents[0].replace('&quot;','"').replace('&amp;','&')
            url   = show['href']
            tmp   = show['href'].split('/')[3]
            art   = "http://assets.hulu.com/shows/key_art_"+tmp.replace('-','_')+".jpg"
            #thumb = "http://assets.hulu.com/shows/show_thumbnail_"+tmp.replace('-','_')+".jpg"
            #icon  = "http://assets.hulu.com/shows/show_thumbnail_"+tmp.replace('-','_')+".jpg"
            #Use higher res fanart (key_art) instead of lower res thumbs & icons
            thumb = art
            icon = art
            if common.settings['get_show_plot'] == True:
                json = common.getHTML("http://www.hulu.com/shows/info/"+tmp)
                try:
                    #this needs better regex, or maybe some sort of json parser
                    p = re.compile('description: "(.+?)"[,}]')
                    match = p.findall(json)
                    plot = match[0].replace('\\','')
                except:
                    plot=xbmc.getLocalizedString(30090)
                try:
                    p = re.compile('channel: "(.+?)"[,}]')
                    match = p.findall(json)
                    genre = match[0]
                except:
                    genre=xbmc.getLocalizedString(30090)
                #hopefully deleting this will help with xbox memory problems
                del json
            else:
                plot=genre=xbmc.getLocalizedString(30090)
            try:
                if show.parent['class'] != "full-episode-icon":
                    name += ' '+xbmc.getLocalizedString(30091)
                    genre += ' '+xbmc.getLocalizedString(30091)
                elif common.args.url != common.BASE_TV_URL:
                    common.addDirectory(name, url, "TV_Seasons", art, icon, art, plot, genre)
            except:
                name += ' '+xbmc.getLocalizedString(30091)
                genre += ' '+xbmc.getLocalizedString(30091)
                if common.settings['only_full_episodes'] == False:
                    common.addDirectory(name, url, "TV_Seasons", art, icon, art, plot, genre)
        
        #if we're doing both clips & full episodes, we need to run through the function again.
        if common.args.url == common.BASE_TV_URL :
            common.args.url = common.BASE_FULLTV_URL
            self.addShowsList()
        
        xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
 def addVideosList( self ):
     if '(clips only)' in common.args.name:
         self.addClipsList()
     else:
         tree=BeautifulSoup(common.getHTML(common.args.url))
         link=tree.find('a', attrs={"class":'info_hover'})
         movieUrl = link['href']
         common.addDirectory(common.args.name, movieUrl, "Movie_play", common.args.fanart, common.args.fanart, common.args.fanart, common.args.plot, common.args.genre)
         common.addDirectory(xbmc.getLocalizedString(30092)+' '+common.args.name.replace(xbmc.getLocalizedString(30091),''), common.args.url, 'Movie_Clips', common.args.fanart,common.args.fanart,common.args.fanart)
Beispiel #8
0
    def addEpisodeList( self ):

        print " \n\n adding episodes \n\n"

        content=common.getHTML(common.args.url)

        # get list of pages of additional episodes, if we have any
        try:
            pagesSegment=re.search('div class="nbcu_pager".+?class="nbcu_pager_last">', content, re.DOTALL).group(0)
            pages=common.unique(re.compile('<a href="(.+?)"').findall(pagesSegment))
            print pages
        except:
            pages=None

        # get episode list per page
        episodeListSegment=re.search('<div class="scet-gallery-content">.+?</div><!-- item list -->', content, re.DOTALL).group(0)

        # title, thumbnail, watchURL, episode, plot
        episodeInfo=re.compile('<li class="list_full_detail_horiz" >.+?href="(.+?)".+?title="(.+?)"><img src="(.+?)".+?<strong>.+?Ep\. (\d+):.+?</div>.+?</li>', re.DOTALL).findall(episodeListSegment, re.DOTALL)
        print episodeInfo

        # season number
        season=re.compile('<h2>Full Episodes.+?(\d+)</span>').findall(episodeListSegment)[0]
        print season

        # add first page worth of episodes
        for watchURL, title, thumbnail, episode in episodeInfo:
            plot = ''
            # build s0xe0y season/episode header if wanted; includes trailing space!
            seasonEpisodeHeader=('', "s%02de%03d " % (int(season), int(episode)))[common.settings['show_epi_labels']]
            # see if we want plots
            plot=('', common.cleanNames(plot))[common.settings['get_episode_plot']]
            common.addDirectory(common.cleanNames(seasonEpisodeHeader + title), watchURL, 'TV_play_nbc', thumbnail, thumbnail, common.args.fanart, plot, 'genre')

        # now loop through rest of episode pages, if any; skip the first page

        # TODO: see if we can consolidate the code from episodeListSegment down,
        # as it duplicates the first page stuff above

        if pages:
            for page in pages[1:]:
                content=common.getHTML(common.NBC_BASE_URL + page)

                # get episode list per page
                episodeListSegment=re.search('<div class="scet-gallery-content">.+?</div><!-- item list -->', content, re.DOTALL).group(0)

                # title, thumbnail, watchURL, episode, plot
                episodeInfo=re.compile('<li class="list_full_detail_horiz" >.+?href="(.+?)".+?title="(.+?)"><img src="(.+?)".+?<strong>.+?Ep\. (\d+):.+?</div>.+?</li>', re.DOTALL).findall(episodeListSegment, re.DOTALL)

                # add each add'l page worth of episodes
                for watchURL, title, thumbnail, episode in episodeInfo:
                    plot = ''
                    # build s0xe0y season/episode header if wanted; includes trailing space!
                    seasonEpisodeHeader=('', "s%02de%03d " % (int(season), int(episode)))[common.settings['show_epi_labels']]
                    # see if we want plots
                    plot=('', common.cleanNames(plot))[common.settings['get_episode_plot']]
                    common.addDirectory(common.cleanNames(seasonEpisodeHeader + title), watchURL, 'TV_play_nbc', thumbnail, thumbnail, common.args.fanart, plot, 'genre')
Beispiel #9
0
    def LISTSHOWS(self, cat):
        url = common.ALL_SHOWS_URL
        link = common.getHTML(url)
        match = re.compile(
            '<a href="(.+?)" class="shows" target="_parent">(.+?)<').findall(
                link)
        for url, name in match:
            thumb = "http://www.cbs.com" + url + "images/common/show_logo.gif"
            #Clean names
            name = name.replace("<br>", " ").replace("&reg", "")
            #Ignore badshow links & showids
            if "http://" in url:
                pass
            elif "/daytime/" == url:
                pass
            elif "/primetime/survivor/fantasy/" == url:
                pass
            else:
                #Fix late show showid & thumb
                if "/latenight/lateshow/" == url:
                    url = "/late_show/"
                    thumb = "http://www.cbs.com" + url + "images/common/show_logo.gif"
                #Fix crimetime thumb
                elif "/crimetime/" == url:
                    thumb = "http://www.cbs.com" + url + "images/common/show_logo.png"
                #Fix 48 Hours and Victorias Secret thumb
                elif "/primetime/48_hours/" == url or "/specials/victorias_secret/" == url:
                    thumb = "http://www.cbs.com" + url + "images/common/show_logo.jpg"
                elif "/primetime/big_brother/housecalls/" == url:
                    thumb = "http://www.cbs.com" + "/primetime/big_brother/" + "images/common/show_logo.gif"
                #Blank icons for unavailable
                elif "/primetime/flashpoint/" == url or "/primetime/game_show_in_my_head/" == url or "/specials/grammys/lincoln/" == url:
                    thumb = xbmc.translatePath(
                        os.path.join(common.imagepath,
                                     url.replace('/', '') + ".png"))

                #Plot cache file
                plotfile = xbmc.translatePath(
                    os.path.join(common.cachepath,
                                 url.replace('/', '') + ".txt"))
                #Check for show info cache file
                if os.path.isfile(plotfile):
                    f = open(plotfile, 'r')
                    plot = f.read()
                    f.close()
                #No Plot
                else:
                    plot = 'No Plot Information Available'
                #All Categories
                if cat == "all":
                    common.addDirectory(name, url, 'List', thumb, thumb, plot)
                #Selected Categories
                elif cat in url:
                    common.addDirectory(name, url, 'List', thumb, thumb, plot)

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
    def addMoviesList( self ):
        
        xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_LABEL)
        xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_GENRE)

        html=common.getHTML(common.args.url)
        tree=BeautifulSoup(html)
        movies=tree.findAll('a', attrs={"class":"show-thumb info_hover"})
        del html
        del tree
        # with clips
        for movie in movies:
            name  = movie.contents[0].replace('&quot;','"').replace('&amp;','&')
            url   = movie['href']
            tmp   = movie['href'].split('/')[3]
            thumb = "http://assets.hulu.com/shows/show_thumbnail_"+tmp.replace('-','_')+".jpg"
            icon  = "http://assets.hulu.com/shows/show_thumbnail_"+tmp.replace('-','_')+".jpg"
            art   = "http://assets.hulu.com/shows/key_art_"+tmp.replace('-','_')+".jpg"
            if common.settings['get_movie_plot'] == True:
                json = common.getHTML("http://www.hulu.com/shows/info/"+tmp)
                try:
                    #this needs better regex, or maybe some sort of json parser
                    p = re.compile('description: "(.+?)"[,}]')
                    match = p.findall(json)
                    plot = match[0].replace('\\','')
                except:
                    plot=xbmc.getLocalizedString(30090)
                try:
                    p = re.compile('channel: "(.+?)"[,}]')
                    match = p.findall(json)
                    genre = match[0]
                except:
                    genre=xbmc.getLocalizedString(30090)
                #hopefully deleting this will help with xbox memory problems
                del json
            else:
                plot=genre=xbmc.getLocalizedString(30090)
            try:
                if movie.parent['class'] != "full-movie-icon":
                    name += ' '+xbmc.getLocalizedString(30091)
                    genre = xbmc.getLocalizedString(30091)+' '+genre
                elif common.args.url != common.BASE_MOVIE_URL:
                    common.addDirectory(name, url, "Movie_Items", art, icon, art, plot, genre)
            except:
                name += ' '+xbmc.getLocalizedString(30091)
                genre += ' '+xbmc.getLocalizedString(30091)
                if common.settings['only_full_movies'] == False:
                    common.addDirectory(name, url, "Movie_Items", art, icon, art, plot, genre)
                    
        #if we're doing both clips & full movies, we need to run through the function again.
        if common.args.url == common.BASE_MOVIE_URL :
            common.args.url = common.BASE_FULLMOVIE_URL
            self.addMoviesList()
Beispiel #11
0
    def addShowsList( self ):

        print "\n\n adding shows \n\n"

        content=common.getHTML(common.args.url)
        
        # title, thumb, id, fanart
        shows=re.compile('<series>.+?<name>(.+?)</name>.+?<thumbnailUrl>(.+?)</thumbnailUrl>.+?<id>(\d+)</id>.+?<backgroundUrl>(.+?)</backgroundUrl>.+?</series>', re.DOTALL).findall(content, re.DOTALL)

        for title, thumb, id, fanart in shows:
            showURL="http://video.scifi.com/player/feeds/?level=%s&type=placement&showall=1" % (id)
            common.addDirectory(common.cleanNames(title), showURL, 'TV_Episodes_scifi', thumb=common.SCIFI_BASE_URL + thumb, fanart=common.SCIFI_BASE_URL + fanart)
 def addListings(self):
     tree = BeautifulSoup(common.getHTML(common.args.url))
     items = tree.findAll("li")
     for item in items:
         link = item.findAll("a", "info_hover")
         url = link[0]["href"]
         name = common.cleanNames(link[-1].contents[0])
         thumb = item.find("img")["src"]
         print name
         print url
         print thumb
         common.addDirectory(name, url, "HD_play", thumb, thumb)
Beispiel #13
0
    def addEpisodeList( self ):

        print " \n\n adding episodes \n\n"
        
        content=common.getHTML(common.args.url)
        
        # get list of pages of additional episodes, if we have any
        try:
            pagesSegment=re.search('div class="nbcu_pager".+?class="nbcu_pager_last">', content, re.DOTALL).group(0)
            pages=common.unique(re.compile('<a href="(.+?)"').findall(pagesSegment))
        except:
            pages=None

        # get episode list per page
        episodeListSegment=re.search('<div id="browse_container">.+?</div><!-- #browse_container -->', content, re.DOTALL).group(0)
        
        # title, thumbnail, watchURL, episode, plot
        episodeInfo=re.compile('<li class="list_full_detail">.+?title="(.+?)"><img src="(.+?)".+?<a href="(.+?)".+?<strong>Ep\. (\d+):.+?<p class="list_full_des"><em>(.+?)</em>', re.DOTALL).findall(episodeListSegment, re.DOTALL)
        
        # season number
        season=re.compile('<h2>Full Episodes.+?(\d+)</span>').findall(episodeListSegment)[0]
        
        # add first page worth of episodes
        for title, thumbnail, watchURL, episode, plot in episodeInfo:
            # build s0xe0y season/episode header if wanted; includes trailing space!
            seasonEpisodeHeader=('', "s%02de%03d " % (int(season), int(episode)))[common.settings['show_epi_labels']]
            # see if we want plots
            plot=('', common.cleanNames(plot))[common.settings['get_episode_plot']]
            common.addDirectory(common.cleanNames(seasonEpisodeHeader + title), watchURL, 'TV_play_nbc', thumbnail, thumbnail, common.args.fanart, plot, 'genre')

        # now loop through rest of episode pages, if any; skip the first page
        
        # TODO: see if we can consolidate the code from episodeListSegment down,
        # as it duplicates the first page stuff above
        
        if pages:
            for page in pages[1:]:
                content=common.getHTML(common.NBC_BASE_URL + page)
                
                # get episode list per page
                episodeListSegment=re.search('<div id="browse_container">.+?</div><!-- #browse_container -->', content, re.DOTALL).group(0)
                
                # title, thumbnail, watchURL, episode, plot
                episodeInfo=re.compile('<li class="list_full_detail">.+?title="(.+?)"><img src="(.+?)".+?<a href="(.+?)".+?<strong>Ep\. (\d+):.+?<p class="list_full_des"><em>(.+?)</em>', re.DOTALL).findall(episodeListSegment, re.DOTALL)
                
                # add each add'l page worth of episodes
                for title, thumbnail, watchURL, episode, plot in episodeInfo:
                    # build s0xe0y season/episode header if wanted; includes trailing space!
                    seasonEpisodeHeader=('', "s%02de%03d " % (int(season), int(episode)))[common.settings['show_epi_labels']]
                    # see if we want plots
                    plot=('', common.cleanNames(plot))[common.settings['get_episode_plot']]
                    common.addDirectory(common.cleanNames(seasonEpisodeHeader + title), watchURL, 'TV_play_nbc', thumbnail, thumbnail, common.args.fanart, plot, 'genre')
Beispiel #14
0
    def LISTSHOWS(self,cat):
        url = common.ALL_SHOWS_URL
        link=common.getHTML(url)
        match=re.compile('<a href="(.+?)" class="shows" target="_parent">(.+?)<').findall(link)
        for url,name in match:
                thumb = "http://www.cbs.com" + url + "images/common/show_logo.gif"
                #Clean names
                name = name.replace("<br>"," ").replace("&reg","")
                #Ignore badshow links & showids
                if "http://" in url:
                        pass
                elif "/daytime/" == url:
                        pass
                elif "/primetime/survivor/fantasy/" == url:
                        pass                       
                else:
                        #Fix late show showid & thumb
                        if "/latenight/lateshow/" == url:
                                url = "/late_show/"
                                thumb = "http://www.cbs.com" + url + "images/common/show_logo.gif"
                        #Fix crimetime thumb        
                        elif "/crimetime/" == url:
                                thumb = "http://www.cbs.com" + url + "images/common/show_logo.png"
                        #Fix 48 Hours and Victorias Secret thumb
                        elif "/primetime/48_hours/" == url or "/specials/victorias_secret/" == url:
                                thumb = "http://www.cbs.com" + url + "images/common/show_logo.jpg"
                        elif "/primetime/big_brother/housecalls/" == url:
                                thumb = "http://www.cbs.com" + "/primetime/big_brother/" + "images/common/show_logo.gif"
                        #Blank icons for unavailable
                        elif "/primetime/flashpoint/" == url or "/primetime/game_show_in_my_head/" == url or "/specials/grammys/lincoln/" == url:
                                thumb = xbmc.translatePath(os.path.join(common.imagepath,url.replace('/','') + ".png"))

                        #Plot cache file
                        plotfile = xbmc.translatePath(os.path.join(common.cachepath,url.replace('/','') + ".txt"))
                        #Check for show info cache file
                        if os.path.isfile(plotfile):
                            f = open(plotfile , 'r')
                            plot = f.read()
                            f.close()
                        #No Plot
                        else:
                            plot = 'No Plot Information Available'
                        #All Categories
                        if cat == "all":
                            common.addDirectory(name,url,'List',thumb,thumb,plot)
                        #Selected Categories
                        elif cat in url:
                            common.addDirectory(name,url,'List',thumb,thumb,plot)

        xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
Beispiel #15
0
    def addEpisodeList( self ):

        print " \n\n adding episodes \n\n"
        
        content=common.getHTML(common.args.url)

        # title, watchURL, plot, thumbnail
        episodeInfo=re.compile('<item>.+?<title>.+?CDATA\[(.+?)\].+?<link>(.+?id=\d+).+?</link>.+?<description>.+?CDATA\[(.+?)\].+?thumbnail.+?url="(.+?)"', re.DOTALL).findall(content, re.DOTALL)
        
        # add episodes
        for title, watchURL, plot, thumbnail in episodeInfo:
            # see if we want plots
            plot=('', common.cleanNames(plot))[common.settings['get_episode_plot']]
            common.addDirectory(common.cleanNames(title), watchURL, 'TV_play_scifi', thumbnail, thumbnail, common.args.fanart, plot, 'genre')
Beispiel #16
0
    def addShowsList( self ):

        print "\n\n adding shows \n\n"

        content=common.getHTML(common.args.url)
        
        # establish show library context
        showListSegment=re.search('<h4>Show Library</h4>.+?</ul>', content, re.DOTALL).group(0)

        # showURL, title
        shows=re.compile('<li><a href="(http://www.nbc.com/.+?/video/)">(.+?)</a></li>').findall(showListSegment, re.DOTALL)

        for showURL, title in shows:
            title=(title, title + ' (Vintage)')[showURL.find('Vintage_Shows') > 0]  # if vintage, say so
            common.addDirectory(common.cleanNames(title), showURL, 'TV_Seasons_nbc')
Beispiel #17
0
    def addShowsList( self ):

        print "\n\n adding shows \n\n"

        content=common.getHTML(common.args.url)

        # establish show library context
        showListSegment=re.search('<h3>Show Library</h3>.+?</ul>', content, re.DOTALL).group(0)

        # showURL, title
        shows=re.compile('<li><a href="(http://www.nbc.com/.+?/video/)">(.+?)</a></li>').findall(showListSegment, re.DOTALL)

        for showURL, title in shows:
            title=(title, title + ' (Vintage)')[showURL.find('Vintage_Shows') > 0]  # if vintage, say so
            common.addDirectory(common.cleanNames(title), showURL, 'TV_Seasons_nbc')
Beispiel #18
0
 def addMainHomeItems( self ):
     tvicon = xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png"))
     #Video lists
     #common.addDirectory('Most Popular','popular','Videos')
     #common.addDirectory('Latest Videos','latest','Videos')
     #common.addDirectory('Full Episodes','fullep','Videos')
     
     #Show types
     data = common.getHTML(common.BASE_URL)
     tree=BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES)
     menu=tree.find(attrs={'id' : 'daypart_nav'})
     categories=menu.findAll('a')
     for item in categories:
         catid = item['onclick'].replace("showDaypart('",'').replace("');",'')
         name = catid.title()
         common.addDirectory(name,catid,mode="Shows")
Beispiel #19
0
 def __init__( self ):
     xbmcplugin.setContent(int(sys.argv[1]), 'tvshows')
     data = common.getHTML(common.BASE_URL)
     tree=BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES)
     menu=tree.find(attrs={'id' : 'videoContent'})
     categories=menu.findAll('div', attrs={'id' : True}, recursive=False)
     for item in categories:
         if item['id'] == common.args.url:
             shows = item.findAll(attrs={'id' : 'show_block_interior'})
             for show in shows:
                 name = show.find('img')['alt'].encode('utf-8')
                 thumbnail = common.BASE_URL + show.find('img')['src']
                 url = common.BASE + show.find('a')['href'].encode('utf-8')
                 common.addDirectory(name, url,'Videos',thumb=thumbnail)
             break
     xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_LABEL)
     xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
Beispiel #20
0
 def VIDEOSHOWSEASONS(self, showid, name):
     #Season Filter
     seasons = self.CHECKSEASONS(showid)
     C = 0
     for season in range(1, 15):
         url = common.SITEFEED_URL + showid + str(season) + ".js"
         if self.TESTURL(url) == True:
             C = C + 1
             common.addDirectory('Season ' + str(season), url, 'Seasons',
                                 common.args.thumbnail,
                                 common.args.thumbnail)
             if C == int(seasons):
                 xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
                 return
     url = url = "http://www.cbs.com/sitefeeds" + showid + "episodes.js"
     common.addDirectory('All Episodes', url, 'ListAny',
                         common.args.thumbnail, common.args.thumbnail)
     xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
Beispiel #21
0
    def addShowsList( self ):

        print "\n\n adding shows \n\n"

        content=common.getHTML(common.args.url)
        
        showsSegment=re.search('<item name="FULL EPISODES">.+?</item>', content, re.DOTALL).group(0)
        # showsSegment=re.search('<item name="USA ORIGINALS">.+?</item>', content, re.DOTALL).group(0)

        # title, showURL
        shows=re.compile('name="(.+?)".+?url="(.+?)"', re.DOTALL).findall(showsSegment, re.DOTALL)

        for title, showURL in shows:
            if (title.title() in thumbs):
                thumbnail=thumbs[title.title()]
            else:
                thumbnail=''
            common.addDirectory(common.cleanNames(title).title(), common.USA_BASE_URL + showURL, 'TV_Episodes_usa', thumbnail)
 def addEpisodeList( self ):
     #initialize variables
     p=re.compile('(\d+)')#gets last number from "season ##"
     currentSeason=p.findall(common.args.name)[0]
     epRSS=None
     #parse html tree
     tree=MinimalSoup(common.getHTML(common.args.url))
     rss=tree.findAll('a', attrs={'class':'rss-link'})
     for feed in rss:
         if feed['href'].split('/')[-1]=='episodes':
             tree=BeautifulStoneSoup(common.getHTML(feed['href']))
             items=tree.findAll('item')
             for episode in items:
                 p=re.compile('\(s([0-9]*).+?\|.+?e([0-9]*)\)')
                 match=p.findall(episode.title.contents[0])[0]
                 seasonNum  = match[0]
                 episodeNum = match[1]
                 if seasonNum == currentSeason:
                     #add this episode to list
                     name    = episode.title.contents[0].split('(')[0]
                     if len(seasonNum)<2:seasonNum='0'+seasonNum
                     if len(episodeNum)<2:episodeNum='0'+episodeNum
                     name = 's'+seasonNum+'e'+episodeNum+' '+name
                     url = episode.link.contents[0].split('#')[0]
                     try:
                         thumb = episode.findAll('media:thumbnail')[0]['url']
                     except:
                         thumb = ''
                     try:
                         airdate = episode.pubdate.contents[0]
                     except:
                         airdate = ''
                     try:
                         p=re.compile('<p>(.+?)</p>.+?Added: ')
                         plot =''.join(p.findall(str(episode.findAll('description'))))
                         try:
                             p=re.compile('Duration: (.+?)\n')
                             duration=p.findall(plot)[0].split(':')
                             duration=(int(duration[0])*60)+int(duration[1])
                         except:
                             duration=1
                     except:
                         plot = ''
                     common.addDirectory(name,url,'TV_play', thumb, thumb, common.args.fanart, plot, 'genre')
Beispiel #23
0
    def addShowsList(self):

        print "\n\n adding shows \n\n"

        content = common.getHTML(common.args.url)

        # title, thumb, id, fanart
        shows = re.compile(
            '<series>.+?<name>(.+?)</name>.+?<thumbnailUrl>(.+?)</thumbnailUrl>.+?<id>(\d+)</id>.+?<backgroundUrl>(.+?)</backgroundUrl>.+?</series>',
            re.DOTALL).findall(content, re.DOTALL)

        for title, thumb, id, fanart in shows:
            showURL = "http://video.scifi.com/player/feeds/?level=%s&type=placement&showall=1" % (
                id)
            common.addDirectory(common.cleanNames(title),
                                showURL,
                                'TV_Episodes_scifi',
                                thumb=common.SCIFI_BASE_URL + thumb,
                                fanart=common.SCIFI_BASE_URL + fanart)
 def addClipsList( self ):
     name = common.args.name.replace(xbmc.getLocalizedString(30091),'')
     tree=BeautifulStoneSoup(common.getHTML(common.args.url))
     clips = tree.findAll('item')
     print clips
     for clip in clips:
         name = clip.title.contents[0].split(': ')[1:][0]
         url  = clip.link.contents[0].split('#')[0]
         try:
             thumb = clip.findAll('media:thumbnail')[0]['url']
         except:
             thumb = common.args.fanart
         try:
             p=re.compile('<p>(.+?)</p>.+?Added: ')
             plot =''.join(p.findall(str(clip.findAll('description')))).replace('<br />','\n').replace('Added: ','\n\nAdded: ')
         except:
             plot = ''
         common.addDirectory(name, url, 'TV_Clips_play', thumb, thumb, common.args.fanart, plot, common.args.genre )
     xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
Beispiel #25
0
    def addClipsList( self ):
        
        print " \n\n adding clips \n\n"

        content=common.getHTML(common.args.url)
        
        # watchURL, thumbnail, title
        clipInfo=re.compile('<li>.+?<a href="(.+?)".+?<img src="(.+?)".+?alt="(.+?)".+?</li>').findall(content)

        for watchURL, thumbnail, title in clipInfo:
            # see if we want plots
            if common.settings['get_episode_plot']:
                episodeInfoID=re.compile('http://www.hulu.com/watch/(\d+)/').findall(watchURL)[0]
                content=common.getHTML("http://www.hulu.com/videos/info/%s" % (episodeInfoID))
                # only getting description for now; info page also includes:
                #  programming_type, rating, has_captions, episode_number, show_name, title, air_date, content_rating, thumbnail_url, season_number, duration
                plot=repr(re.compile('description: "(.+?)"').findall(content)[0].replace('\n', '\r'))
            else:
                plot=''
            common.addDirectory(common.cleanNames(title), watchURL, 'TV_Clips_play_nbc', thumbnail, thumbnail, common.args.fanart, plot, 'genre')
        del content
Beispiel #26
0
    def addClipsList( self ):

        print " \n\n adding clips \n\n"

        content=common.getHTML(common.args.url)

        # watchURL, thumbnail, title
        clipInfo=re.compile('<li>.+?<a href="(.+?)".+?<img src="(.+?)".+?alt="(.+?)".+?</li>').findall(content)

        for watchURL, thumbnail, title in clipInfo:
            # see if we want plots
            if common.settings['get_episode_plot']:
                episodeInfoID=re.compile('http://www.hulu.com/watch/(\d+)/').findall(watchURL)[0]
                content=common.getHTML("http://www.hulu.com/videos/info/%s" % (episodeInfoID))
                # only getting description for now; info page also includes:
                #  programming_type, rating, has_captions, episode_number, show_name, title, air_date, content_rating, thumbnail_url, season_number, duration
                plot=repr(re.compile('description: "(.+?)"').findall(content)[0].replace('\n', '\r'))
            else:
                plot=''
            common.addDirectory(common.cleanNames(title), watchURL, 'TV_Clips_play_nbc', thumbnail, thumbnail, common.args.fanart, plot, 'genre')
        del content
Beispiel #27
0
 def addMainHomeItems(self):
     common.addDirectory("NBC",
                         common.NBC_FULL_URL,
                         "TV_nbc",
                         xbmc.translatePath(
                             os.path.join(common.imagepath,
                                          "nbc_posterart.jpg")),
                         xbmc.translatePath(
                             os.path.join(common.imagepath,
                                          "nbc_posterart.jpg")),
                         genre="list",
                         plot="NBC")
     common.addDirectory("SciFi",
                         common.SCIFI_FULL_URL,
                         "TV_scifi",
                         xbmc.translatePath(
                             os.path.join(common.imagepath,
                                          "scifi_posterart.jpg")),
                         xbmc.translatePath(
                             os.path.join(common.imagepath,
                                          "scifi_posterart.jpg")),
                         genre="list",
                         plot="SciFi")
     common.addDirectory("USA",
                         common.USA_FULL_URL,
                         "TV_usa",
                         xbmc.translatePath(
                             os.path.join(common.imagepath,
                                          "usa_posterart.jpg")),
                         xbmc.translatePath(
                             os.path.join(common.imagepath,
                                          "usa_posterart.jpg")),
                         genre="list",
                         plot="USA")
 def addClipsList( self ):
     tree=BeautifulSoup(common.getHTML(common.args.url))
     rssLink = tree.find('a', attrs={'class':'rss-link'})
     if rssLink == None:
         xbmcgui.Dialog().ok(xbmc.getLocalizedString(30093),xbmc.getLocalizedString(30094)+' '+common.args.name)
     else:
         name = common.args.name.replace(xbmc.getLocalizedString(30090),'')
         tree=BeautifulStoneSoup(common.getHTML(rssLink['href']))
         clips = tree.findAll('item')
         for clip in clips:
             name = clip.title.contents[0].split(': ')[1:][0]
             url  = clip.link.contents[0].split('#')[0]
             try:
                 thumb = clip.findAll('media:thumbnail')[0]['url']
             except:
                 thumb = common.args.fanart
             try:
                 p=re.compile('<p>(.+?)</p>.+?Added: ')
                 plot =''.join(p.findall(str(clip.findAll('description')))).replace('<br />','\n').replace('Added: ','\n\nAdded: ')
             except:
                 plot = ''
             common.addDirectory(name, url, 'TV_Clips_play', thumb, thumb, common.args.fanart, plot, common.args.genre )
         xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
Beispiel #29
0
    def HDSHOWS(self, url):
        link = common.getHTML(url)
        hdcachefile = xbmc.translatePath(
            os.path.join(common.cachepath, "hd.js"))
        f = open(hdcachefile, 'w')
        plot = f.write(str(link))
        f.close()
        match = re.compile('videoProperties(.+?);\r').findall(link)
        SHOWLIST = ['']
        CLIPLIST = ['']
        EPISODELIST = ['']
        #set List Counter to 1 for popular and recent shows
        for url in match:
            breakurl = url.split("','")
            SHOWNAME = breakurl[3]
            if SHOWNAME <> '':
                Episodes = False
                Clips = False
                if len(breakurl[9]) > 4:
                    Episodes = True
                if len(breakurl[9]) <= 4:
                    Clips = True
                if SHOWLIST[0] == '':
                    #print "first run"
                    SHOWLIST[0] = SHOWNAME
                    EPISODELIST[0] = Episodes
                    CLIPLIST[0] = Clips
                elif SHOWNAME in SHOWLIST:
                    #print "existing show"
                    i = SHOWLIST.index(SHOWNAME)
                    if Episodes == True:
                        EPISODELIST[i] = Episodes
                    elif Clips == True:
                        CLIPLIST[i] = Clips
                else:
                    #print "New Show"
                    SHOWLIST.append(SHOWNAME)
                    EPISODELIST.append(Episodes)
                    CLIPLIST.append(Clips)
            else:
                print "NO SHOW NAME: " + breakurl

        #for SHOWNAME,Episodes,Clips in SHOWLIST:
        for SHOWNAME in SHOWLIST:
            i = SHOWLIST.index(SHOWNAME)
            Episodes = EPISODELIST[i]
            Clips = CLIPLIST[i]
            if Episodes == True and Clips == True:
                common.addDirectory(SHOWNAME, 'EpisodesClips', 'ListHD')
            elif Episodes == True:
                common.addDirectory(SHOWNAME, 'Episodes', 'ListHD')
            elif Clips == True:
                common.addDirectory(SHOWNAME, "Clips", "ListHD")

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
Beispiel #30
0
    def HDSHOWS(self, url):
        link = common.getHTML(url)
        hdcachefile = xbmc.translatePath(os.path.join(common.cachepath, "hd.js"))
        f = open(hdcachefile, "w")
        plot = f.write(str(link))
        f.close()
        match = re.compile("videoProperties(.+?);\r").findall(link)
        SHOWLIST = [""]
        CLIPLIST = [""]
        EPISODELIST = [""]
        # set List Counter to 1 for popular and recent shows
        for url in match:
            breakurl = url.split("','")
            SHOWNAME = breakurl[3]
            if SHOWNAME <> "":
                Episodes = False
                Clips = False
                if len(breakurl[9]) > 4:
                    Episodes = True
                if len(breakurl[9]) <= 4:
                    Clips = True
                if SHOWLIST[0] == "":
                    # print "first run"
                    SHOWLIST[0] = SHOWNAME
                    EPISODELIST[0] = Episodes
                    CLIPLIST[0] = Clips
                elif SHOWNAME in SHOWLIST:
                    # print "existing show"
                    i = SHOWLIST.index(SHOWNAME)
                    if Episodes == True:
                        EPISODELIST[i] = Episodes
                    elif Clips == True:
                        CLIPLIST[i] = Clips
                else:
                    # print "New Show"
                    SHOWLIST.append(SHOWNAME)
                    EPISODELIST.append(Episodes)
                    CLIPLIST.append(Clips)
            else:
                print "NO SHOW NAME: " + breakurl

        # for SHOWNAME,Episodes,Clips in SHOWLIST:
        for SHOWNAME in SHOWLIST:
            i = SHOWLIST.index(SHOWNAME)
            Episodes = EPISODELIST[i]
            Clips = CLIPLIST[i]
            if Episodes == True and Clips == True:
                common.addDirectory(SHOWNAME, "EpisodesClips", "ListHD")
            elif Episodes == True:
                common.addDirectory(SHOWNAME, "Episodes", "ListHD")
            elif Clips == True:
                common.addDirectory(SHOWNAME, "Clips", "ListHD")

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
Beispiel #31
0
 def addMainHomeItems( self ):
     xml=common.getFEED(common.BASE_MENU_URL)
     tree = ElementTree.XML(xml)
     menuitems = tree.findall('item')
     fanart = common.hulu_fanart
     for item in menuitems:
         display= item.findtext('display')
         items_url='http://m.hulu.com'+item.findtext('items_url') 
         cmtype=item.find('app_data').findtext('cmtype')
         thumbnail = xbmc.translatePath(os.path.join(common.imagepath,"icon.png"))
         cm = []
         if cmtype == 'None' or display == 'Help' or display == 'Profiles' or display == 'Now Playing':
             continue
         elif display =='Popular':
             thumbnail = xbmc.translatePath(os.path.join(common.imagepath,"icon_popular.jpg"))
             cm.append( ('Export Popular Shows', "XBMC.RunPlugin(%s?mode='ForcePopularShowsLibrary')" % ( sys.argv[0] ) ) )
             cm.append( ('Export Popular Movies', "XBMC.RunPlugin(%s?mode='ForcePopularMoviesLibrary')" % ( sys.argv[0] ) ) )
             cm.append( ('Export Popular Episodes', "XBMC.RunPlugin(%s?mode='ForcePopularEpisodesLibrary')" % ( sys.argv[0] ) ) )
         elif display =='Recently Added':
             thumbnail = xbmc.translatePath(os.path.join(common.imagepath,"icon_recently_added.jpg"))        
         elif display == 'TV':
             cm.append( ('Export All Full Shows', "XBMC.RunPlugin(%s?mode='ForceFullShowsLibrary')" % ( sys.argv[0] ) ) )
             thumbnail = xbmc.translatePath(os.path.join(common.imagepath,"icon_tv.jpg"))
         elif display == 'Movies':
             cm.append( ('Export All Full Movies', "XBMC.RunPlugin(%s?mode='ForceFullMoviesLibrary')" % ( sys.argv[0] ) ) )
             thumbnail = xbmc.translatePath(os.path.join(common.imagepath,"icon_movies.jpg"))
         elif display == 'Search':
             thumbnail = xbmc.translatePath(os.path.join(common.imagepath,"icon_search.jpg"))
         common.addDirectory(display,items_url,cmtype,thumbnail,thumbnail,fanart=fanart,page='1',perpage='25',cm=cm)
     if common.settings['enable_login']=='true':
         if not os.path.isfile(common.QUEUETOKEN):
             common.login_queue()
         thumbnail = xbmc.translatePath(os.path.join(common.imagepath,"icon_queue.jpg"))
         cm = [ ('Add Queue to Library', "XBMC.RunPlugin(%s?mode='ForceQueueLibrary')" % ( sys.argv[0] ) ) ]
         cm.append( ('Clear Library Directory', "XBMC.RunPlugin(%s?mode='ClearLibrary')" % ( sys.argv[0] ) ) )
         common.addDirectory('Queue'         ,'http://m.hulu.com/menu/hd_user_queue'          , 'Queue'         ,thumbnail,thumbnail,fanart=fanart,page='1',perpage='2000',cm=cm)
         thumbnail = xbmc.translatePath(os.path.join(common.imagepath,"icon_subscriptions.jpg"))
         cm = [ ('Add Subscriptions to Library', "XBMC.RunPlugin(%s?mode='ForceSubscriptionsLibrary')" % ( sys.argv[0] ) ) ]
         cm.append( ('Clear Library Directory', "XBMC.RunPlugin(%s?mode='ClearLibrary')" % ( sys.argv[0] ) ) )
         common.addDirectory('Subscriptions' ,'http://m.hulu.com/menu/hd_user_subscriptions'  , 'Subscriptions' ,thumbnail,thumbnail,fanart=fanart,page='1',perpage='2000',cm=cm)
         thumbnail = xbmc.translatePath(os.path.join(common.imagepath,"icon_history.jpg"))
         common.addDirectory('History'       ,'http://m.hulu.com/menu/hd_user_history'        , 'History'       ,thumbnail,thumbnail,fanart=fanart,page='1',perpage='2000')
Beispiel #32
0
    def __init__( self ):
        xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
        name = common.args.name
        page = common.args.page
        
        data = common.getHTML(common.args.url)
        tree=BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES)

        if page == 'optionlist':
            try:
                options = tree.find(attrs={'id' : 'secondary-show-nav-wrapper'})
                options = options.findAll('a')
                for option in options:
                    name = option.string.encode('utf-8')
                    url = common.BASE + option['href']
                    common.addDirectory(name,url,'Videos','1')
            except:
                print 'CBS: secondary-show-nav-wrapper failed'
                print 'CBS: trying vid_module'
                try:
                    options = tree.findAll(attrs={'class' : 'vid_module'})
                    for option in options:
                        moduleid = option['id']
                        name = option.find(attrs={'class' : 'hdr'}).string
                        common.addDirectory(name,common.args.url,'Videos',moduleid)                                        
                except:
                    print 'CBS: vid_module failed'
        elif page == '1':
            print 'CBS: trying vid_module'
            try:
                options = tree.findAll(attrs={'class' : 'vid_module'})
                if len(options) == 1:
                    self.PAGES(tree)
                else:
                    for option in options:
                        moduleid = option['id']
                        name = option.find(attrs={'class' : 'hdr'}).string
                        common.addDirectory(name,common.args.url,'Videos',moduleid)                                        
            except:
                self.PAGES(tree)
        elif 'vid_module' in page:
            vid_module = tree.find(attrs={'id' : page})
            self.PAGES(vid_module)
            
        if common.args.updatelist == 'true':
            xbmcplugin.endOfDirectory( pluginhandle, cacheToDisc=True, updateListing=True)
        else:
            xbmcplugin.endOfDirectory( pluginhandle, cacheToDisc=True)
    def __init__(self):
        xbmcplugin.setContent(int(sys.argv[1]), "episodes")
        name = common.args.name
        page = common.args.page

        data = common.getHTML(common.args.url)
        tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES)

        if page == "optionlist":
            try:
                options = tree.find(attrs={"id": "secondary-show-nav-wrapper"})
                options = options.findAll("a")
                for option in options:
                    name = option.string.encode("utf-8")
                    url = common.BASE + option["href"]
                    common.addDirectory(name, url, "Videos", "1")
            except:
                print "CBS: secondary-show-nav-wrapper failed"
                print "CBS: trying vid_module"
                try:
                    options = tree.findAll(attrs={"class": "vid_module"})
                    for option in options:
                        moduleid = option["id"]
                        name = option.find(attrs={"class": "hdr"}).string
                        common.addDirectory(name, common.args.url, "Videos", moduleid)
                except:
                    print "CBS: vid_module failed"
        elif page == "1":
            print "CBS: trying vid_module"
            try:
                options = tree.findAll(attrs={"class": "vid_module"})
                if len(options) == 1:
                    self.PAGES(tree)
                else:
                    for option in options:
                        moduleid = option["id"]
                        name = option.find(attrs={"class": "hdr"}).string
                        common.addDirectory(name, common.args.url, "Videos", moduleid)
            except:
                self.PAGES(tree)
        elif "vid_module" in page:
            vid_module = tree.find(attrs={"id": page})
            self.PAGES(vid_module)

        if common.args.updatelist == "true":
            xbmcplugin.endOfDirectory(pluginhandle, cacheToDisc=True, updateListing=True)
        else:
            xbmcplugin.endOfDirectory(pluginhandle, cacheToDisc=True)
 def addCategories( self ):
     html=common.getHTML(common.args.url)
     p=re.compile('href="http://www.hulu.com/browse/alphabetical/.+?(\?channel=.+?)">[^<]')
     match=p.findall(html)
     del html
     for item in match:
         name=item.split("=")[-1]
         if name!='all':
             if common.args.mode == "Movie_cat_sub":#SubCategories _ don't add to dir heirachy
                 item=item.split('&')[-1]
                 name = "(Subcategory) "+name.replace("+"," ").title()
                 common.addDirectory(name, common.args.url+"&"+item, "Movie_cat_sub2")
             elif "&" in item.split("=")[-2]:#SubCategories
                 item=item.split('&')[-1]
                 name = "(Subcategory) "+name.replace("+"," ").title()
                 common.addDirectory(name, common.args.url+"&"+item, "Movie_cat_sub")
             elif common.args.mode!='TV_categories':#RegularCategory
                 name= name.replace("+"," ").title()
                 common.addDirectory(name, common.args.url+item, "Movie_cat")
Beispiel #35
0
 def addMainHomeItems(self):
     xml = common.getFEED(common.BASE_MENU_URL)
     tree = ElementTree.XML(xml)
     menuitems = tree.findall('item')
     fanart = common.hulu_fanart
     for item in menuitems:
         display = item.findtext('display')
         items_url = 'http://m.hulu.com' + item.findtext('items_url')
         cmtype = item.find('app_data').findtext('cmtype')
         thumbnail = xbmc.translatePath(
             os.path.join(common.imagepath, "icon.png"))
         cm = []
         if cmtype == 'None' or display == 'Help' or display == 'Profiles' or display == 'Now Playing':
             continue
         elif display == 'Popular':
             thumbnail = xbmc.translatePath(
                 os.path.join(common.imagepath, "icon_popular.jpg"))
             cm.append(
                 ('Export Popular Shows',
                  "XBMC.RunPlugin(%s?mode='ForcePopularShowsLibrary')" %
                  (sys.argv[0])))
             cm.append(
                 ('Export Popular Movies',
                  "XBMC.RunPlugin(%s?mode='ForcePopularMoviesLibrary')" %
                  (sys.argv[0])))
             cm.append(
                 ('Export Popular Episodes',
                  "XBMC.RunPlugin(%s?mode='ForcePopularEpisodesLibrary')" %
                  (sys.argv[0])))
         elif display == 'Recently Added':
             thumbnail = xbmc.translatePath(
                 os.path.join(common.imagepath, "icon_recently_added.jpg"))
         elif display == 'TV':
             cm.append(('Export All Full Shows',
                        "XBMC.RunPlugin(%s?mode='ForceFullShowsLibrary')" %
                        (sys.argv[0])))
             thumbnail = xbmc.translatePath(
                 os.path.join(common.imagepath, "icon_tv.jpg"))
         elif display == 'Movies':
             cm.append(('Export All Full Movies',
                        "XBMC.RunPlugin(%s?mode='ForceFullMoviesLibrary')" %
                        (sys.argv[0])))
             thumbnail = xbmc.translatePath(
                 os.path.join(common.imagepath, "icon_movies.jpg"))
         elif display == 'Search':
             thumbnail = xbmc.translatePath(
                 os.path.join(common.imagepath, "icon_search.jpg"))
         common.addDirectory(display,
                             items_url,
                             cmtype,
                             thumbnail,
                             thumbnail,
                             fanart=fanart,
                             page='1',
                             perpage='25',
                             cm=cm)
     if common.settings['enable_login'] == 'true':
         if not os.path.isfile(common.QUEUETOKEN):
             common.login_queue()
         thumbnail = xbmc.translatePath(
             os.path.join(common.imagepath, "icon_queue.jpg"))
         cm = [
             ('Add Queue to Library',
              "XBMC.RunPlugin(%s?mode='ForceQueueLibrary')" % (sys.argv[0]))
         ]
         cm.append(
             ('Clear Library Directory',
              "XBMC.RunPlugin(%s?mode='ClearLibrary')" % (sys.argv[0])))
         common.addDirectory('Queue',
                             'http://m.hulu.com/menu/hd_user_queue',
                             'Queue',
                             thumbnail,
                             thumbnail,
                             fanart=fanart,
                             page='1',
                             perpage='2000',
                             cm=cm)
         thumbnail = xbmc.translatePath(
             os.path.join(common.imagepath, "icon_subscriptions.jpg"))
         cm = [('Add Subscriptions to Library',
                "XBMC.RunPlugin(%s?mode='ForceSubscriptionsLibrary')" %
                (sys.argv[0]))]
         cm.append(
             ('Clear Library Directory',
              "XBMC.RunPlugin(%s?mode='ClearLibrary')" % (sys.argv[0])))
         common.addDirectory('Subscriptions',
                             'http://m.hulu.com/menu/hd_user_subscriptions',
                             'Subscriptions',
                             thumbnail,
                             thumbnail,
                             fanart=fanart,
                             page='1',
                             perpage='2000',
                             cm=cm)
         thumbnail = xbmc.translatePath(
             os.path.join(common.imagepath, "icon_history.jpg"))
         common.addDirectory('History',
                             'http://m.hulu.com/menu/hd_user_history',
                             'History',
                             thumbnail,
                             thumbnail,
                             fanart=fanart,
                             page='1',
                             perpage='2000')
Beispiel #36
0
    def addMenuItems(self, perpage, pagenumber, url=common.args.url):
        # Grab xml item list
        orginalUrl = url
        if '?' in url:
            url += '&'
        else:
            url += '?'
        noCache = False
        if 'Queue' == common.args.mode or 'Subscriptions' == common.args.mode or 'History' == common.args.mode:
            usertoken = common.settings['usertoken']
            url += 'dp_id=' + dp_id + '&limit=' + perpage + '&package_id=' + package_id + '&user_id=' + usertoken
            noCache = True
            total_count = 0
        else:
            url += 'dp_id=' + dp_id + '&package_id=' + package_id + '&limit=' + perpage + '&page=' + pagenumber
            total_count = self.getTotalCount(orginalUrl)
        if noCache:
            xml = common.getFEED(url)
        else:
            xml = common.getFEED(url)
        while xml == False:
            if noCache:
                xml = common.getFEED(url)
            else:
                xml = common.getFEED(url)
            #xbmc.sleep(400)

        # Add Next/Prev Pages
        count = 0
        if int(perpage) < int(total_count):
            if 'Popular' in common.args.name or 'Featured' in common.args.name or 'Recently' in common.args.name:
                popular = 'true'
            else:
                try:
                    popular = common.args.popular
                except:
                    popular = 'false'
            current_page = int(pagenumber)
            next_page = int(pagenumber) + 1
            prev_page = int(pagenumber) - 1
            npage_begin = int(perpage) * current_page + 1
            npage_end = int(perpage) * next_page
            if total_count < npage_end:
                npage_end = total_count
            if npage_begin < total_count:
                next_name = 'Next Page (' + str(npage_begin) + '-' + str(
                    npage_end) + ' of ' + str(total_count) + ')'
                nextthumb = xbmc.translatePath(
                    os.path.join(common.imagepath, "next.png"))
                common.addDirectory(next_name,
                                    url,
                                    common.args.mode,
                                    page=str(next_page),
                                    icon=nextthumb,
                                    perpage=perpage,
                                    popular=popular,
                                    fanart=common.hulu_fanart,
                                    updatelisting='true')
            if prev_page > 0:
                ppage_begin = int(perpage) * (prev_page - 1) + 1
                ppage_end = int(perpage) * prev_page
                prev_name = 'Previous Page (' + str(ppage_begin) + '-' + str(
                    ppage_end) + ' of ' + str(total_count) + ')'
                prevthumb = xbmc.translatePath(
                    os.path.join(common.imagepath, "prev.png"))
                common.addDirectory(prev_name,
                                    url,
                                    common.args.mode,
                                    page=str(prev_page),
                                    icon=prevthumb,
                                    perpage=perpage,
                                    popular=popular,
                                    fanart=common.hulu_fanart,
                                    updatelisting='true')

        tree = ElementTree.XML(xml)
        menuitems = tree.findall('item')
        del tree
        hasMovies = False
        hasEpisodes = False
        hasTVShows = False
        for item in menuitems:
            display = item.findtext('display').encode('utf-8')
            displayname = display
            url = 'http://m.hulu.com' + item.findtext('items_url')
            mode = item.find('app_data').findtext('cmtype')

            #Flatten All and Alphabetical
            if display == 'All' and total_count == 1:
                return self.addMenuItems(common.settings['allperpage'],
                                         common.args.page, url)
            # Skip unwanted menu items
            elif mode == 'None' or display == 'Add to queue' or display == 'Subscriptions':
                continue

            #set Data
            isVideo = False
            if common.args.fanart and common.args.fanart <> '':
                fanart = common.args.fanart
            else:
                fanart = common.hulu_fanart

            if common.args.art <> '':
                art = common.args.art
            elif 'Popular' in common.args.name or 'Popular' in display:
                art = xbmc.translatePath(
                    os.path.join(common.imagepath, "icon_popular.jpg"))
            elif 'Recently' in common.args.name or 'Recently' in display:
                art = xbmc.translatePath(
                    os.path.join(common.imagepath, "icon_recently_added.jpg"))
            elif 'TV' == common.args.name:
                art = xbmc.translatePath(
                    os.path.join(common.imagepath, "icon_tv.jpg"))
            elif 'Movies' == common.args.name:
                art = xbmc.translatePath(
                    os.path.join(common.imagepath, "icon_movies.jpg"))
            else:
                art = common.hulu_icon

            infoLabels = {'Title': display}
            show_id = False
            ishd = False
            data = item.find('data')
            if data:
                #data = data[0]
                canonical_name = data.findtext('canonical_name')
                show_canonical_name = data.findtext('show_canonical_name')
                #Show Only
                if canonical_name:
                    infoLabels['TVShowTitle'] = data.findtext('name').encode(
                        'utf-8')
                    infoLabels['Genre'] = data.findtext('genre', default="")
                    totalEpisodes = data.findtext('full_episodes_count')
                    if totalEpisodes:
                        infoLabels['Episode'] = int(totalEpisodes)
                    totalSeasons = data.findtext('total_seasons_count')
                    parent_id = data.findtext('parent_id')
                    if parent_id:
                        displayname = '- ' + displayname
                    art = "http://assets.hulu.com/shows/key_art_" + canonical_name.replace(
                        '-', '_') + ".jpg"
                #Video Only
                elif show_canonical_name:
                    isVideo = True
                    canonical_name = show_canonical_name
                    content_id = data.findtext('content_id')
                    video_id = data.findtext('video_id')
                    eid = data.findtext('eid')
                    media_type = data.findtext('media_type')
                    art = data.findtext('thumbnail_url_16x9_large')
                    infoLabels['TVShowTitle'] = data.findtext(
                        'show_name').encode('utf-8')
                    infoLabels['Genre'] = data.findtext('parent_channel_name',
                                                        default="")
                    infoLabels['MPAA'] = data.findtext('content_rating')
                    votes_data = data.findtext('votes_count')
                    seasondata = data.findtext('season_number')
                    if seasondata.isdigit():
                        infoLabels['Season'] = int(seasondata)
                    else:
                        infoLabels['Season'] = 0
                    episodedata = data.findtext('episode_number')
                    if episodedata.isdigit():
                        infoLabels['Episode'] = int(episodedata)
                    else:
                        infoLabels['Episode'] = 0
                    durationseconds = int(float(data.findtext('duration')))
                    infoLabels['Duration'] = str(
                        datetime.timedelta(seconds=durationseconds))
                #Both Show and Video
                plot = data.findtext('description')
                if plot:
                    plot = unicode(plot.replace('\n', ' ').replace(
                        '\r', ' ')).encode('utf-8')
                else:
                    plot = ''

                plus_only = data.findtext('plus_only')
                if plus_only == 'True':
                    plus_web_expires_at = data.findtext('plus_web_expires_at')
                    if plus_web_expires_at:
                        plot = 'Plus Expires: ' + plus_web_expires_at.replace(
                            ' 00:00:00', '') + '\n' + plot
                else:
                    expires_at = data.findtext('expires_at')
                    if expires_at:
                        plot = 'Expires: ' + expires_at.replace(
                            ' 00:00:00', '') + '\n' + plot
                    else:
                        composite_expires_at = data.findtext(
                            'composite_expires_at')
                        if composite_expires_at:
                            plot = 'Expires: ' + composite_expires_at.replace(
                                ' 00:00:00', '') + '\n' + plot
                infoLabels['Plot'] = plot
                premiered = data.findtext('original_premiere_date')
                if premiered:
                    premiered = premiered.split(' ')[0]
                    infoLabels['Premiered'] = premiered
                    datesplit = premiered.split('-')
                    infoLabels['date'] = datesplit[2] + '.' + datesplit[
                        1] + '.' + datesplit[0]
                    infoLabels['Year'] = int(premiered.split('-')[0])
                rating = data.findtext('rating')
                if rating:
                    #if rating.isdigit():
                    infoLabels['Rating'] = float(rating) * 2
                company_name = data.findtext('company_name', default="")
                infoLabels['Studio'] = company_name
                ishd = data.findtext('has_hd')
                language = data.findtext('language', default="").upper()
                hascaptions = data.findtext('has_captions')
                show_id = data.findtext('show_id')
                if canonical_name:
                    fanart = "http://assets.hulu.com/shows/key_art_" + canonical_name.replace(
                        '-', '_') + ".jpg"

            if mode == 'SeasonMenu':
                xbmcplugin.setContent(pluginhandle, 'seasons')
                dtotal_count = self.getTotalCount(url)
                #displayname = displayname + ' ('+str(dtotal_count)+')'
                episode_number = dtotal_count
                isVideo = False
            elif mode == 'ShowPage':
                xbmcplugin.setContent(pluginhandle, 'tvshows')
                hasTVShows = True
                isVideo = False
            elif common.args.mode == 'ChannelMenu':
                xbmcplugin.setContent(pluginhandle, 'tvshows')
                fanart = common.hulu_fanart
                art = common.hulu_icon
            elif common.args.mode == 'ShowPage':
                xbmcplugin.setContent(pluginhandle, 'episodes')
                dtotal_count = self.getTotalCount(url)
                episode_number = dtotal_count
                displayname = displayname + ' (' + str(dtotal_count) + ')'
                if dtotal_count == 0:
                    continue
            #Set Networks and Studios fanart
            elif common.args.name == 'Networks' or common.args.name == 'Studios':
                xbmcplugin.setContent(pluginhandle, 'tvshows')
                canonical_name = self.remove_accents(
                    canonical_name.encode('utf-8'))
                fanart = "http://assets.huluim.com/companies/key_art_" + canonical_name.replace(
                    '-', '_') + ".jpg"
                art = fanart
            #Add Count to Display Name for Non-Show/Episode Lists
            elif common.args.mode == 'Menu' and isVideo == False:
                dtotal_count = self.getTotalCount(url)
                if dtotal_count <> 1:
                    displayname = displayname + ' (' + str(dtotal_count) + ')'
                elif dtotal_count == 0:
                    continue
            #Set Final Video Name
            elif isVideo == True:
                url = content_id
                #URL of video
                #url="http://www.hulu.com/watch/"+videoid
                mode = 'TV_play'
                if media_type == 'TV':
                    xbmcplugin.setContent(pluginhandle, 'episodes')
                    hasEpisodes = True
                elif media_type == 'Film':
                    xbmcplugin.setContent(pluginhandle, 'episodes')
                    hasMovies = True
                    #infoLabels['TVShowTitle'] = company_name
                #xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_EPISODE)
                if infoLabels['Season'] <> 0 and infoLabels['Episode'] <> 0:
                    if 'Popular' in common.args.name or 'Featured' in common.args.name or 'Recently' in common.args.name or 'Queue' == common.args.mode or 'History' == common.args.mode or common.args.popular == 'true':
                        displayname = infoLabels['TVShowTitle'] + ' - ' + str(
                            infoLabels['Season']) + 'x' + str(
                                infoLabels['Episode']) + ' - ' + display
                    else:
                        displayname = str(infoLabels['Season']) + 'x' + str(
                            infoLabels['Episode']) + ' - ' + display
                if 'EN' <> language:
                    displayname += ' (' + language + ')'
            if 'True' == ishd:
                displayname += ' (HD)'

            u = sys.argv[0]
            u += '?url="' + urllib.quote_plus(url) + '"'
            u += '&mode="' + urllib.quote_plus(mode) + '"'
            item = xbmcgui.ListItem(displayname,
                                    iconImage=art,
                                    thumbnailImage=art)
            infoLabels['Title'] = displayname
            infoLabels['count'] = count
            count += 1
            item.setInfo(type="Video", infoLabels=infoLabels)
            item.setProperty('fanart_image', fanart)

            #Set total count
            if int(perpage) < int(total_count):
                total_items = int(perpage)
            elif int(perpage) < len(menuitems):
                total_items = len(menuitems)
            else:
                total_items = int(total_count)

            cm = []
            if isVideo == False:
                u += '&name="' + urllib.quote_plus(display.replace("'",
                                                                   "")) + '"'
                u += '&art="' + urllib.quote_plus(art) + '"'
                u += '&fanart="' + urllib.quote_plus(fanart) + '"'
                u += '&page="1"'
                u += '&popular="false"'
                u += '&updatelisting="false"'
                if common.settings[
                        'enable_login'] == 'true' and common.settings[
                            'usertoken']:
                    if 'Subscriptions' == common.args.mode:
                        cm.append(
                            ('Remove Subscription',
                             "XBMC.RunPlugin(%s?mode='removesub'&url=%s)" %
                             (sys.argv[0], show_id)))
                    elif show_id <> '':
                        cm.append(('Add to Subscriptions',
                                   "XBMC.RunPlugin(%s?mode='addsub'&url=%s)" %
                                   (sys.argv[0], show_id)))
                item.addContextMenuItems(cm)  #,replaceItems=True)
                xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                            url=u,
                                            listitem=item,
                                            isFolder=True,
                                            totalItems=total_items)
            elif isVideo == True:
                u += '&videoid="' + urllib.quote_plus(video_id) + '"'
                u += '&eid="' + urllib.quote_plus(eid) + '"'
                if common.settings[
                        'enable_login'] == 'true' and common.settings[
                            'usertoken']:
                    if 'History' == common.args.mode:
                        cm.append(
                            ('Remove from History',
                             "XBMC.RunPlugin(%s?mode='removehistory'&url=%s)" %
                             (sys.argv[0], video_id)))
                    if 'Queue' == common.args.mode:
                        cm.append(
                            ('Remove from Queue',
                             "XBMC.RunPlugin(%s?mode='removequeue'&url=%s)" %
                             (sys.argv[0], video_id)))
                    else:
                        cm.append(
                            ('Add to Queue',
                             "XBMC.RunPlugin(%s?mode='addqueue'&url=%s)" %
                             (sys.argv[0], video_id)))
                        if show_id <> '':
                            cm.append(
                                ('Add to Subscriptions',
                                 "XBMC.RunPlugin(%s?mode='addsub'&url=%s)" %
                                 (sys.argv[0], show_id)))
                    if 'True' == hascaptions:
                        if common.settings['enable_captions'] == 'true':
                            cm.append((
                                'Play without Subtitles',
                                "XBMC.RunPlugin(%s?mode='NoCaptions_TV_play'&url='%s'&videoid='%s')"
                                % (sys.argv[0], url, video_id)))
                        else:
                            cm.append((
                                'Play with Subtitles',
                                "XBMC.RunPlugin(%s?mode='Captions_TV_play'&url='%s'&videoid='%s')"
                                % (sys.argv[0], url, video_id)))
                        cm.append((
                            'Assign Subtitles',
                            "XBMC.RunPlugin(%s?mode='SUBTITLE_play'&url='%s'&videoid='%s')"
                            % (sys.argv[0], url, video_id)))
                    cm.append((
                        'Select Quality',
                        "XBMC.RunPlugin(%s?mode='Select_TV_play'&url='%s'&videoid='%s')"
                        % (sys.argv[0], url, video_id)))
                    cm.append(('Vote for Video',
                               "XBMC.RunPlugin(%s?mode='vote'&url=%s)" %
                               (sys.argv[0], video_id)))
                item.addContextMenuItems(cm)  #,replaceItems=True)
                item.setProperty('IsPlayable', 'true')
                xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                            url=u,
                                            listitem=item,
                                            isFolder=False,
                                            totalItems=total_items)
Beispiel #37
0
 def addMainHomeItems( self ):
     common.addDirectory("NBC", common.NBC_FULL_URL, "TV_nbc", xbmc.translatePath(os.path.join(common.imagepath,"nbc_posterart.jpg")), xbmc.translatePath(os.path.join(common.imagepath,"nbc_posterart.jpg")), genre = "list", plot = "NBC")
     common.addDirectory("SciFi", common.SCIFI_FULL_URL, "TV_scifi", xbmc.translatePath(os.path.join(common.imagepath,"scifi_posterart.jpg")), xbmc.translatePath(os.path.join(common.imagepath,"scifi_posterart.jpg")), genre = "list", plot = "SciFi")
     common.addDirectory("USA", common.USA_FULL_URL, "TV_usa", xbmc.translatePath(os.path.join(common.imagepath,"usa_posterart.jpg")), xbmc.translatePath(os.path.join(common.imagepath,"usa_posterart.jpg")), genre = "list", plot = "USA")
Beispiel #38
0
    def VIDEOSHOWIDS(self, showid, name):
        if (xbmcplugin.getSetting('recent')
                == '0') or (xbmcplugin.getSetting('recent') == '1'):
            url = common.SITEFEED_URL + showid + "recent.js"
            if self.TESTURL(url) == True:
                common.addDirectory(" Latest Videos", url, "Latest",
                                    common.args.thumbnail,
                                    common.args.thumbnail)
        if (xbmcplugin.getSetting('popular')
                == '0') or (xbmcplugin.getSetting('recent') == '1'):
            url = common.SITEFEED_URL + showid + "popular.js"
            if self.TESTURL(url) == True:
                common.addDirectory(" Most Popular", url, "Popular",
                                    common.args.thumbnail,
                                    common.args.thumbnail)
        if (xbmcplugin.getSetting('editorial') == 'true'):
            url = common.SITEFEED_URL + showid + "editorial.js"
            if self.TESTURL(url) == True:
                common.addDirectory(" Editor's Picks", url, "Editorial",
                                    common.args.thumbnail,
                                    common.args.thumbnail)
        if (xbmcplugin.getSetting('clips') == 'true'):
            url = common.SITEFEED_URL + showid + "clips.js"
            if self.TESTURL(url) == True:
                common.addDirectory(" Clips", url, "Clips",
                                    common.args.thumbnail,
                                    common.args.thumbnail)
        if (xbmcplugin.getSetting('all') == 'true'):
            url = common.SITEFEED_URL + showid + "all.js"
            if self.TESTURL(url) == True:
                common.addDirectory(" All Videos", url, "All",
                                    common.args.thumbnail,
                                    common.args.thumbnail)

        #Special Crimetime case. Normal video lists unavailable
        if showid == "/crimetime/":
            url = "http://www.cbs.com/crimetime/js/video/behind_the_scenes.js"
            if self.TESTURL(url) == True:
                common.addDirectory("Behind the Scenes", url, "ListAny",
                                    common.args.thumbnail,
                                    common.args.thumbnail)
            url = "http://www.cbs.com/crimetime/js/video/48_hours.js"
            if self.TESTURL(url) == True:
                common.addDirectory("48 Hours: Crimetime", url, "ListAny",
                                    common.args.thumbnail,
                                    common.args.thumbnail)

        #Full Episodes Listings
        url = common.SITEFEED_URL + showid + "episodes.js"
        #Check seasons.js for Season Count
        if self.CHECKSEASONS(showid) > 1:
            common.addDirectory(" Seasons", showid, "SeasonsList",
                                common.args.thumbnail, common.args.thumbnail)
        #Add Episodes
        else:
            if self.TESTURL(url) == True:
                self.VIDEOLINKS(url, name)

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
Beispiel #39
0
    def addSeasonList( self ):

        print "\n\n adding seasons \n\n"
        
        # get the seasons list from the show page
        content=common.getHTML(common.args.url)
        
        # establish seasons context; do we have any?
        try:
            seasonsSegment=re.search('<h4>Full Episodes</h4>.+?</ul>', content, re.DOTALL).group(0)
            # seasonURL, name
            seasons=re.compile('<li><a href="(.+?)">(.+?)</a></li>').findall(seasonsSegment, re.DOTALL)
        except:
            seasons=None

        # get the episodes page header
        headerSegment=re.search('<head>.+?</head>', content, re.DOTALL).group(0)
        fanart=re.compile(".+?background-image: url\(\\'(.+?)\\'", re.DOTALL).findall(headerSegment, re.DOTALL)[0]

        if seasons:
            # are we flat/1 season?
            if common.settings['flat_season'] == 1 or (len(seasons) == 1 and common.settings['flat_season'] == 0):
                common.args.mode='TV_Episodes_nbc'
                for seasonURL, name in seasons:
                    common.args.url=common.NBC_BASE_URL + seasonURL
                    self.addEpisodeList()
            else:
                for seasonURL, name in seasons:
                    common.addDirectory(name, common.NBC_BASE_URL + seasonURL, 'TV_Episodes_nbc', fanart=common.NBC_BASE_URL + fanart)
        
        xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))

        return
        
        ########## ########## for future work with clips and webisodes
        
        slider=re.compile('VideoSlider\(.+, ({.+})').findall(content)[0]
        del content

        # get seasons and episodes per season; also determine how many episodes in total
        seasons=re.compile('.+?s(\d+): (\d+)').findall(re.search('episode: {.+?}', slider).group(0))
        episodeCount=re.compile('.+?all: (\d+)').findall(re.search('episode: {.+?}', slider).group(0))[0]
                
        # URL for the slider call and the showID to plug into it
        sliderURL=re.search('url: \"(.+?)\"', slider).group(1)
        show_id=re.search('show_id: (\d+)', slider).group(1)

        # only add episodes if we have any
        if int(episodeCount) > 0:
            # are we flat/1 season?
            if common.settings['flat_season'] == 1 or (len(seasons) == 1 and common.settings['flat_season'] == 0):
                common.args.mode='TV_Episodes_nbc'
                common.args.url="%s?type=episode&show_id=%s&items_per_page=%s" % (sliderURL, show_id, episodeCount)
                self.addEpisodeList()
            else:
                # one folder per season
                for seasonID, seasonEpisodeCount in seasons:
                    if int(seasonEpisodeCount) > 0:  # some seasons in the list have 0 episodes
                        name="Season %s" % (seasonID)
                        common.args.url="%s?type=episode&show_id=%s&season=%s&items_per_page=%s" % (sliderURL, show_id, seasonID, seasonEpisodeCount)
                        common.addDirectory(name, common.args.url, 'TV_Episodes_nbc')

        # add clips folder if not indicated otherwise
        if not(common.settings['only_full_episodes']):
            clipCount=re.compile('.+?all: (\d+)').findall(re.search('clip: {.+?}', slider).group(0))[0]
            if int(clipCount) > 0:
                common.args.url="%s?type=clip&show_id=%s&items_per_page=%s" % (sliderURL, show_id, clipCount)
                if int(episodeCount) > 0: # only add a clips folder if we have episodes, otherwise go straight to the clips
                    common.addDirectory(xbmc.getLocalizedString(30095), common.args.url, 'TV_Clips')
                else:
                    self.addClipsList()
        
        xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))
Beispiel #40
0
    def VIDEOLINKS(self, url, name):
        showfilter = ''
        CLIPSDIR = False
        if url == "EpisodesClips":
            url = "Episodes"
            CLIPSDIR = True
        if url == "Episodes":
            HD = True
            typefilter = url
            showfilter = name.replace(' Clips', '')
            url = common.HDVIDEOS_URL
        elif url == "Clips":
            HD = True
            typefilter = url
            showfilter = name.replace(' Clips', '')
            url = common.HDVIDEOS_URL
        else:
            typefilter = ''
            showfilter = ''
            HD = False

        hdcachefile = xbmc.translatePath(
            os.path.join(common.cachepath, "hd.js"))
        if url == common.HDVIDEOS_URL and os.path.isfile(hdcachefile):
            f = open(hdcachefile, 'r')
            link = f.read()
            f.close()
        else:
            link = common.getHTML(url)
        match = re.compile('videoProperties(.+?);\r').findall(link)
        #set List Counter to 1 for popular and recent shows
        if "popular" in url or "recent" in url or "editorial" in url:
            C = 1
        else:
            C = 0
        for url in match:
            # breakurl item list
            #  0 = empty
            #  1 = title1
            #  2 = title2
            #  3 = series_title
            #  4 = season_number
            #  5 = description
            #  6 = episode_number
            #  7 = primary_cid
            #  8 = category_type
            #  9 = runtime
            # 10 = pid or 480p pid
            # 11 = thumbnail 160x120
            # 12 = fullsize thumbnail 640x480
            # 13 = the current category value for the existing show pages(mostly blank)
            # 14 = site name in xml, lowercased and trimmed to match the value passed from the left menu(mostly blank)
            # 15 = empty or 720p pid
            breakurl = url.split("','")
            #change single digit season numbers to 2 digits
            if len(breakurl[4]) == 1:
                breakurl[4] = "0" + breakurl[4]
            #change single digit episode numbers to 2 digits
            if len(breakurl[6]) == 1:
                breakurl[6] = "0" + breakurl[6]
            #Standard Definition pid
            breakurl[15] = breakurl[15].replace("')", "")
            if breakurl[15] == '':
                pid = breakurl[10]
                if HD == True:
                    continue
            #480p and 720p pids
            elif breakurl[15] <> '':
                breakurl[16] = breakurl[16].replace("')", "")
                pid = breakurl[10] + "<break>" + breakurl[
                    15] + "<break>" + breakurl[16]
            if (xbmcplugin.getSetting('largethumbs') == 'true'):
                thumbnail = breakurl[12]
            elif (xbmcplugin.getSetting('largethumbs') == 'false'):
                thumbnail = breakurl[11]
            plot = breakurl[5].replace('\\', '')
            duration = breakurl[9]
            if breakurl[4] <> '':
                season = int(breakurl[4].replace('_', '').replace('-',
                                                                  '').replace(
                                                                      '.', ''))
            else:
                season = 0
            if breakurl[6] <> '':
                episode = int(breakurl[6].replace('_', '').replace(
                    '-', '').replace('.', '').replace('A',
                                                      '').replace('T', ''))
            else:
                episode = 0
            #seriestitle = breakurl[3]
            #episodetitle = breakurl[2]
            #List Order Counter for popular and recent lists
            if C <> 0:
                if len(str(C)) == 1:
                    ordernumber = "#0" + str(C) + ". "
                else:
                    ordernumber = "#" + str(C) + ". "
                C = C + 1
            #Blank ordernumber value for all other lists
            else:
                ordernumber = ''
            #Generate filename for Full Episode - series title + "S" + season number+ "E" + episode number + " - " + episode title
            if breakurl[8] == "Full Episode":
                if "late" in breakurl[1] or "daytime" in breakurl[1]:
                    finalname = ordernumber + breakurl[2]
                else:
                    finalname = ordernumber + "S" + breakurl[
                        4] + "E" + breakurl[6] + " - " + breakurl[2]
            #Generate filename for Clip - series title + " - " + episode title + " (Clip)"
            elif breakurl[8] == "Clip":
                #finalname = ordernumber + breakurl[3] + " - " + breakurl[2] + " (Clip) " + breakurl[9]
                if breakurl[2] == '':
                    finalname = ordernumber + breakurl[3] + " (Clip)"
                if breakurl[3] in breakurl[2]:
                    finalname = ordernumber + breakurl[2] + " (Clip)"
                else:
                    finalname = ordernumber + breakurl[2] + " (Clip)"
            #HD title and for everything else
            else:
                if len(breakurl[9]) > 4:
                    finalname = breakurl[3] + " E" + breakurl[
                        6] + " - " + breakurl[2]  # + " (" + breakurl[9] + ")"
                elif len(breakurl[9]) <= 4:
                    if breakurl[3] in breakurl[2]:
                        finalname = breakurl[
                            2] + " (Clip)"  # (" + breakurl[9] + ")"
                    else:
                        finalname = breakurl[3] + " - " + breakurl[
                            2] + " (Clip)"  # + " (" + breakurl[9] + ")"
            #Clean filename
            finalname = finalname.replace('\\\'', '\'')
            if "<break>" in pid:
                if breakurl[3] == showfilter:
                    if typefilter == "Episodes":
                        if len(breakurl[9]) > 4:
                            passname = finalname.replace(ordernumber, '')
                            url = sys.argv[
                                0] + '?mode="' + 'Play' + '"&name="' + urllib.quote_plus(
                                    common.cleanNames(passname)
                                ) + '"&pid="' + urllib.quote_plus(
                                    pid
                                ) + '"&thumbnail="' + urllib.quote_plus(
                                    common.cleanNames(thumbnail)
                                ) + '"'  #+'"&plot="'+urllib.quote_plus(plot)+'?duration="'+urllib.quote_plus(duration)+'?season="'+urllib.quote_plus(str(season))+'?episode="'+urllib.quote_plus(str(episode))+'"'
                            item = xbmcgui.ListItem(finalname,
                                                    iconImage=thumbnail,
                                                    thumbnailImage=thumbnail)
                            item.setInfo(type="Video",
                                         infoLabels={
                                             "Title": finalname,
                                             "Season": season,
                                             "Episode": episode,
                                             "Duration": duration,
                                             "Plot": plot
                                         })
                            xbmcplugin.addDirectoryItem(handle=int(
                                sys.argv[1]),
                                                        url=url,
                                                        listitem=item,
                                                        isFolder=True)
                            continue
                    elif typefilter == "Clips":
                        if len(breakurl[9]) <= 4:
                            passname = finalname.replace(ordernumber, '')
                            url = sys.argv[
                                0] + '?mode="' + 'Play' + '"&name="' + urllib.quote_plus(
                                    common.cleanNames(passname)
                                ) + '"&pid="' + urllib.quote_plus(
                                    pid
                                ) + '"&thumbnail="' + urllib.quote_plus(
                                    common.cleanNames(thumbnail)
                                ) + '"'  #+'"&plot="'+urllib.quote_plus(plot)+'?duration="'+urllib.quote_plus(duration)+'?season="'+urllib.quote_plus(str(season))+'?episode="'+urllib.quote_plus(str(episode))+'"'
                            item = xbmcgui.ListItem(finalname,
                                                    iconImage=thumbnail,
                                                    thumbnailImage=thumbnail)
                            item.setInfo(type="Video",
                                         infoLabels={
                                             "Title": finalname,
                                             "Season": season,
                                             "Episode": episode,
                                             "Duration": duration,
                                             "Plot": plot
                                         })
                            xbmcplugin.addDirectoryItem(handle=int(
                                sys.argv[1]),
                                                        url=url,
                                                        listitem=item,
                                                        isFolder=True)
                            continue
            else:
                passname = finalname.replace(ordernumber, '')
                url = sys.argv[
                    0] + '?mode="' + 'Play' + '"&name="' + urllib.quote_plus(
                        common.cleanNames(passname)
                    ) + '"&pid="' + urllib.quote_plus(
                        pid
                    ) + '"&thumbnail="' + urllib.quote_plus(
                        common.cleanNames(thumbnail)
                    ) + '"'  #+'"&plot="'+urllib.quote_plus(plot)+'?duration="'+urllib.quote_plus(duration)+'?season="'+urllib.quote_plus(str(season))+'?episode="'+urllib.quote_plus(str(episode))+'"'
                item = xbmcgui.ListItem(finalname,
                                        iconImage=thumbnail,
                                        thumbnailImage=thumbnail)
                item.setInfo(type="Video",
                             infoLabels={
                                 "Title": finalname,
                                 "Season": season,
                                 "Episode": episode,
                                 "Duration": duration,
                                 "Plot": plot
                             })
                xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                            url=url,
                                            listitem=item)
                continue
        #add Clips Dir for HD
        if CLIPSDIR == True:
            common.addDirectory(showfilter + " Clips", "Clips", "ListHD")
        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
Beispiel #41
0
 def addMainHomeItems( self ):
     namecount = 0
     if (xbmcplugin.getSetting('recent') == '0') or (xbmcplugin.getSetting('recent') == '2'):
         namecount += 1
         common.addDirectory(str(namecount) + ". Latest Videos",
                             common.ALL_RECENT_URL,
                             "Latest",
                             xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                             xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                             plot = "Latest Videos Added to CBS.com")
     if (xbmcplugin.getSetting('popular') == '0') or (xbmcplugin.getSetting('popular') == '2'):
         namecount += 1
         common.addDirectory(str(namecount) + ". Most Popular",
                             common.ALL_POPULAR_URL,
                             "Popular",
                             xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                             xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                             plot = "Most Popular Episodes and Clips from CBS.com")
     namecount += 1
     common.addDirectory(str(namecount) + ". All Shows",
                         common.ALL_SHOWS_URL,
                         "Shows",
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         plot = "")
     namecount += 1
     common.addDirectory(str(namecount) + ". Primetime",
                         common.ALL_SHOWS_URL,
                         "ShowsPrimetime",
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         plot = "")
     namecount += 1
     common.addDirectory(str(namecount) + ". Daytime",
                         common.ALL_SHOWS_URL,
                         "ShowsDaytime",
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         plot = "")
     namecount += 1
     common.addDirectory(str(namecount) + ". Late Night",
                         common.ALL_SHOWS_URL,
                         "ShowsLate",
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         plot = "")
     namecount += 1
     common.addDirectory(str(namecount) + ". TV Classics",
                         common.ALL_SHOWS_URL,
                         "ShowsClassics",
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         plot = "")
     namecount += 1
     common.addDirectory(str(namecount) + ". Specials",
                         common.ALL_SHOWS_URL,
                         "ShowsSpecials",
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),
                         plot = "")
     if (xbmcplugin.getSetting('hdcat') == 'true'):
         namecount += 1
         common.addDirectory(str(namecount) + ". HD Videos",
                             common.HDVIDEOS_URL,
                             "HD",
                             xbmc.translatePath(os.path.join(common.imagepath,"hd_icon.png")),
                             xbmc.translatePath(os.path.join(common.imagepath,"hd_icon.png")),
                             plot = "")
Beispiel #42
0
    def addMenuItems( self, perpage, pagenumber ,url=common.args.url ):
        # Grab xml item list
        orginalUrl = url
        if '?' in url:
            url += '&' 
        else:
            url += '?'
        noCache = False
        if 'Queue' == common.args.mode or 'Subscriptions' == common.args.mode or 'History' == common.args.mode:
            usertoken = common.settings['usertoken']
            url += 'dp_id='+dp_id+'&limit='+perpage+'&package_id='+package_id+'&user_id='+usertoken
            noCache = True
            total_count = 0
        else:
            url += 'dp_id='+dp_id+'&package_id='+package_id+'&limit='+perpage+'&page='+pagenumber
            total_count = self.getTotalCount( orginalUrl )
        if noCache:
            xml = common.getFEED(url)
        else:
            xml=common.getFEED(url)
        while xml == False:
            if noCache:
                xml = common.getFEED(url)
            else:
                xml=common.getFEED(url)
            #xbmc.sleep(400)

        # Add Next/Prev Pages
        count = 0
        if int(perpage) < int(total_count):
            if 'Popular' in common.args.name or 'Featured' in common.args.name or 'Recently' in common.args.name:
                popular='true'
            else:
                try:
                    popular = common.args.popular
                except:
                    popular='false'
            current_page = int(pagenumber)
            next_page = int(pagenumber)+1
            prev_page = int(pagenumber)-1         
            npage_begin = int(perpage)*current_page + 1
            npage_end = int(perpage)*next_page
            if total_count < npage_end:
                npage_end = total_count
            if npage_begin < total_count:
                next_name = 'Next Page ('+str(npage_begin)+'-'+str(npage_end)+' of '+str(total_count)+')'
                nextthumb=xbmc.translatePath(os.path.join(common.imagepath,"next.png"))
                common.addDirectory(next_name,url,common.args.mode,page=str(next_page),icon=nextthumb,perpage=perpage,popular=popular,fanart=common.hulu_fanart,updatelisting='true')
            if prev_page > 0:
                ppage_begin = int(perpage)*(prev_page-1)+1
                ppage_end = int(perpage)*prev_page
                prev_name = 'Previous Page ('+str(ppage_begin)+'-'+str(ppage_end)+' of '+str(total_count)+')'
                prevthumb=xbmc.translatePath(os.path.join(common.imagepath,"prev.png"))
                common.addDirectory(prev_name,url,common.args.mode,page=str(prev_page),icon=prevthumb,perpage=perpage,popular=popular,fanart=common.hulu_fanart,updatelisting='true')

        tree = ElementTree.XML(xml)
        menuitems = tree.findall('item')        
        del tree
        hasMovies = False
        hasEpisodes = False
        hasTVShows = False
        for item in menuitems:
            display=item.findtext('display').encode('utf-8')
            displayname=display
            url='http://m.hulu.com'+item.findtext('items_url') 
            mode=item.find('app_data').findtext('cmtype')
            
            #Flatten All and Alphabetical
            if display == 'All' and total_count == 1:
                return self.addMenuItems(common.settings['allperpage'],common.args.page,url)
            # Skip unwanted menu items
            elif mode == 'None' or display == 'Add to queue' or display == 'Subscriptions':
                continue
            
            #set Data
            isVideo = False
            if common.args.fanart and common.args.fanart <> '':
                fanart = common.args.fanart
            else:
                fanart = common.hulu_fanart
            
            if common.args.art <> '':
                art = common.args.art
            elif 'Popular' in common.args.name or 'Popular' in display:
                art = xbmc.translatePath(os.path.join(common.imagepath,"icon_popular.jpg"))
            elif 'Recently' in common.args.name or 'Recently' in display:
                art = xbmc.translatePath(os.path.join(common.imagepath,"icon_recently_added.jpg")) 
            elif 'TV' == common.args.name:
                art = xbmc.translatePath(os.path.join(common.imagepath,"icon_tv.jpg"))
            elif 'Movies' == common.args.name:
                art = xbmc.translatePath(os.path.join(common.imagepath,"icon_movies.jpg"))
            else:
                art = common.hulu_icon

            infoLabels={'Title':display}
            show_id = False
            ishd = False
            data = item.find('data')
            if data:
                #data = data[0]
                canonical_name      = data.findtext('canonical_name')
                show_canonical_name = data.findtext('show_canonical_name')
                #Show Only
                if canonical_name:
                    infoLabels['TVShowTitle'] = data.findtext('name').encode('utf-8')
                    infoLabels['Genre'] = data.findtext('genre', default="")
                    totalEpisodes = data.findtext('full_episodes_count')
                    if totalEpisodes:
                        infoLabels['Episode'] = int(totalEpisodes)
                    totalSeasons = data.findtext('total_seasons_count')
                    parent_id = data.findtext('parent_id')
                    if parent_id:
                        displayname = '- '+displayname
                    art = "http://assets.hulu.com/shows/key_art_"+canonical_name.replace('-','_')+".jpg"
                #Video Only
                elif show_canonical_name:
                    isVideo = True
                    canonical_name = show_canonical_name
                    content_id = data.findtext('content_id')
                    video_id = data.findtext('video_id')
                    eid = data.findtext('eid') 
                    media_type = data.findtext('media_type')
                    art = data.findtext('thumbnail_url_16x9_large')
                    infoLabels['TVShowTitle'] = data.findtext('show_name').encode('utf-8')
                    infoLabels['Genre'] = data.findtext('parent_channel_name', default="")
                    infoLabels['MPAA'] = data.findtext('content_rating')
                    votes_data = data.findtext('votes_count')
                    seasondata = data.findtext('season_number')
                    if seasondata.isdigit():  
                        infoLabels['Season'] = int(seasondata)
                    else:
                        infoLabels['Season'] = 0
                    episodedata = data.findtext('episode_number')
                    if episodedata.isdigit():
                        infoLabels['Episode'] = int(episodedata)
                    else:
                        infoLabels['Episode'] = 0
                    durationseconds = int(float(data.findtext('duration')))
                    infoLabels['Duration'] =  str(datetime.timedelta(seconds=durationseconds))
                #Both Show and Video
                plot=data.findtext('description')
                if plot:
                    plot = unicode(plot.replace('\n', ' ').replace('\r', ' ')).encode('utf-8')
                else:
                    plot = ''
                
                plus_only=data.findtext('plus_only')
                if plus_only == 'True':
                    plus_web_expires_at=data.findtext('plus_web_expires_at')
                    if plus_web_expires_at:
                        plot = 'Plus Expires: '+plus_web_expires_at.replace(' 00:00:00','')+'\n'+plot
                else:
                    expires_at=data.findtext('expires_at')
                    if expires_at:
                        plot = 'Expires: '+expires_at.replace(' 00:00:00','')+'\n'+plot
                    else:
                        composite_expires_at=data.findtext('composite_expires_at')
                        if composite_expires_at:
                            plot = 'Expires: '+composite_expires_at.replace(' 00:00:00','')+'\n'+plot
                infoLabels['Plot'] = plot                
                premiered =  data.findtext('original_premiere_date')
                if premiered:
                    premiered = premiered.split(' ')[0]
                    infoLabels['Premiered'] = premiered
                    datesplit=premiered.split('-')
                    infoLabels['date'] = datesplit[2]+'.'+datesplit[1]+'.'+datesplit[0]
                    infoLabels['Year'] = int(premiered.split('-')[0])
                rating = data.findtext('rating')
                if rating:
                    #if rating.isdigit():
                    infoLabels['Rating'] = float(rating)*2
                company_name = data.findtext('company_name', default="")
                infoLabels['Studio'] = company_name
                ishd = data.findtext('has_hd')
                language = data.findtext('language', default="").upper()
                hascaptions=data.findtext('has_captions')
                show_id = data.findtext('show_id')
                if canonical_name:
                    fanart = "http://assets.hulu.com/shows/key_art_"+canonical_name.replace('-','_')+".jpg"

            if mode == 'SeasonMenu':
                xbmcplugin.setContent(pluginhandle, 'seasons')
                dtotal_count = self.getTotalCount( url )
                #displayname = displayname + ' ('+str(dtotal_count)+')'
                episode_number = dtotal_count
                isVideo = False
            elif mode == 'ShowPage':
                xbmcplugin.setContent(pluginhandle, 'tvshows')
                hasTVShows = True
                isVideo = False
            elif common.args.mode == 'ChannelMenu':
                xbmcplugin.setContent(pluginhandle, 'tvshows')
                fanart = common.hulu_fanart
                art = common.hulu_icon
            elif common.args.mode == 'ShowPage':
                xbmcplugin.setContent(pluginhandle, 'episodes')
                dtotal_count = self.getTotalCount( url )
                episode_number = dtotal_count
                displayname = displayname + ' ('+str(dtotal_count)+')'
                if dtotal_count == 0:
                    continue
            #Set Networks and Studios fanart
            elif common.args.name == 'Networks' or common.args.name == 'Studios':
                xbmcplugin.setContent(pluginhandle, 'tvshows')
                canonical_name = self.remove_accents(canonical_name.encode('utf-8'))
                fanart = "http://assets.huluim.com/companies/key_art_"+canonical_name.replace('-','_')+".jpg"
                art = fanart
            #Add Count to Display Name for Non-Show/Episode Lists
            elif common.args.mode == 'Menu' and isVideo == False:
                dtotal_count = self.getTotalCount( url )
                if dtotal_count <> 1:
                    displayname = displayname + ' ('+str(dtotal_count)+')'
                elif dtotal_count == 0:
                    continue
            #Set Final Video Name
            elif isVideo == True:
                url=content_id
                #URL of video
                #url="http://www.hulu.com/watch/"+videoid
                mode = 'TV_play'
                if media_type == 'TV':
                    xbmcplugin.setContent(pluginhandle, 'episodes')
                    hasEpisodes = True
                elif media_type == 'Film':
                    xbmcplugin.setContent(pluginhandle, 'episodes')
                    hasMovies = True
                    #infoLabels['TVShowTitle'] = company_name
                #xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_EPISODE)
                if infoLabels['Season'] <> 0 and infoLabels['Episode'] <> 0:
                    if 'Popular' in common.args.name or 'Featured' in common.args.name or 'Recently' in common.args.name or 'Queue' == common.args.mode or 'History' == common.args.mode or common.args.popular == 'true':
                        displayname = infoLabels['TVShowTitle']+' - '+str(infoLabels['Season'])+'x'+str(infoLabels['Episode'])+' - '+display
                    else:
                        displayname = str(infoLabels['Season'])+'x'+str(infoLabels['Episode'])+' - '+display
                if 'EN' <> language:
                    displayname += ' ('+language+')'
            if 'True' == ishd:
                displayname += ' (HD)'


            u = sys.argv[0]
            u += '?url="'+urllib.quote_plus(url)+'"'
            u += '&mode="'+urllib.quote_plus(mode)+'"'
            item=xbmcgui.ListItem(displayname, iconImage=art, thumbnailImage=art)
            infoLabels['Title']=displayname
            infoLabels['count']=count
            count += 1
            item.setInfo( type="Video", infoLabels=infoLabels)
            item.setProperty('fanart_image',fanart)

            #Set total count
            if int(perpage) < int(total_count):
                total_items = int(perpage)
            elif int(perpage) < len(menuitems):
                total_items = len(menuitems)
            else:
                total_items = int(total_count)
            
            cm = []
            if isVideo == False:
                u += '&name="'+urllib.quote_plus(display.replace("'",""))+'"'
                u += '&art="'+urllib.quote_plus(art)+'"'
                u += '&fanart="'+urllib.quote_plus(fanart)+'"'
                u += '&page="1"'
                u += '&popular="false"'
                u += '&updatelisting="false"'
                if common.settings['enable_login']=='true' and common.settings['usertoken']:
                    if 'Subscriptions' == common.args.mode:
                        cm.append( ('Remove Subscription', "XBMC.RunPlugin(%s?mode='removesub'&url=%s)" % ( sys.argv[0], show_id ) ) )
                    elif show_id <> '':
                        cm.append( ('Add to Subscriptions', "XBMC.RunPlugin(%s?mode='addsub'&url=%s)" % ( sys.argv[0], show_id ) ) )
                item.addContextMenuItems( cm )#,replaceItems=True)
                xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=True,totalItems=total_items)
            elif isVideo == True:
                u += '&videoid="'+urllib.quote_plus(video_id)+'"'
                u += '&eid="'+urllib.quote_plus(eid)+'"'
                if common.settings['enable_login']=='true' and common.settings['usertoken']:
                    if 'History' == common.args.mode:
                        cm.append( ('Remove from History', "XBMC.RunPlugin(%s?mode='removehistory'&url=%s)" % ( sys.argv[0], video_id ) ) )   
                    if 'Queue' == common.args.mode:
                        cm.append( ('Remove from Queue', "XBMC.RunPlugin(%s?mode='removequeue'&url=%s)" % ( sys.argv[0], video_id ) ) )
                    else:
                        cm.append( ('Add to Queue', "XBMC.RunPlugin(%s?mode='addqueue'&url=%s)" % ( sys.argv[0], video_id ) ) )
                        if show_id <> '':
                            cm.append( ('Add to Subscriptions', "XBMC.RunPlugin(%s?mode='addsub'&url=%s)" % ( sys.argv[0], show_id ) ) )
                    if 'True' == hascaptions:
                        if common.settings['enable_captions'] == 'true':
                            cm.append( ('Play without Subtitles', "XBMC.RunPlugin(%s?mode='NoCaptions_TV_play'&url='%s'&videoid='%s')" % ( sys.argv[0], url, video_id ) ) ) 
                        else:
                            cm.append( ('Play with Subtitles', "XBMC.RunPlugin(%s?mode='Captions_TV_play'&url='%s'&videoid='%s')" % ( sys.argv[0], url, video_id ) ) ) 
                        cm.append( ('Assign Subtitles', "XBMC.RunPlugin(%s?mode='SUBTITLE_play'&url='%s'&videoid='%s')" % ( sys.argv[0], url, video_id ) ) )
                    cm.append( ('Select Quality', "XBMC.RunPlugin(%s?mode='Select_TV_play'&url='%s'&videoid='%s')" % ( sys.argv[0], url, video_id ) ) )
                    cm.append( ('Vote for Video', "XBMC.RunPlugin(%s?mode='vote'&url=%s)" % ( sys.argv[0], video_id ) ) )
                item.addContextMenuItems( cm )#,replaceItems=True) 
                item.setProperty('IsPlayable', 'true')
                xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=False,totalItems=total_items)
    def addMainHomeItems( self ):
        #space before " TV Shows" and " Movies" ensures that they are at the top of the list
        if common.settings['only_full_episodes']:
            common.addDirectory(" "+xbmc.getLocalizedString(20343), common.BASE_FULLTV_URL, "TV", xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),   xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),    genre = "list", plot = "A listing of all the Television Shows currently avaliable on Hulu.com")
        else:
            common.addDirectory(" "+xbmc.getLocalizedString(20343), common.BASE_TV_URL, "TV", xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),   xbmc.translatePath(os.path.join(common.imagepath,"tv_icon.png")),    genre = "list", plot = "A listing of all the Television Shows currently avaliable on Hulu.com")
        if common.settings['only_full_movies']:
            common.addDirectory(" "+xbmc.getLocalizedString(342), common.BASE_FULLMOVIE_URL, "Movie", xbmc.translatePath(os.path.join(common.imagepath,"movie_icon.png")),xbmc.translatePath(os.path.join(common.imagepath,"movie_icon.png")), genre = "list", plot = "A listing of all the Movies currently avaliable on Hulu.com")
        else:
            common.addDirectory(" "+xbmc.getLocalizedString(342), common.BASE_MOVIE_URL, "Movie", xbmc.translatePath(os.path.join(common.imagepath,"movie_icon.png")),xbmc.translatePath(os.path.join(common.imagepath,"movie_icon.png")), genre = "list", plot = "A listing of all the Movies currently avaliable on Hulu.com")

        #Leave this removed until H264 Streams Correctly
        #common.addDirectory(xbmc.getLocalizedString(30037), common.HD_GALLERY_URL, "HD", xbmc.translatePath(os.path.join(common.imagepath,"hd_icon.png")), xbmc.translatePath(os.path.join(common.imagepath,"hd_icon.png")), genre = "HD", plot = "Sample the videos in our HD gallery to preview the future of online video quality today. Videos include trailers for Street Kings, The Indredible Hulk, Leatherheads, Step Brothers, Horton Hears a Who!...")
        #Temporarily removed because It F***s Shit Up (TM)
        #common.addDirectory(xbmc.getLocalizedString(30038), common.RSS_RECENT_SHOWS, "RSS",xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), genre = "rss")
        common.addDirectory(xbmc.getLocalizedString(30037), common.RSS_RECENT_MOVIES, "RSS",xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), genre = "rss")
        common.addDirectory(xbmc.getLocalizedString(30031), common.RSS_HIGHEST_RATED, "RSS",xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), genre = "rss")
        common.addDirectory(xbmc.getLocalizedString(30032), common.RSS_MOST_POP_TOD, "RSS",xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), genre = "rss")
        common.addDirectory(xbmc.getLocalizedString(30033), common.RSS_MOST_POP_WEEK, "RSS",xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), genre = "rss")
        common.addDirectory(xbmc.getLocalizedString(30034), common.RSS_MOST_POP_MON, "RSS",xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), genre = "rss")
        common.addDirectory(xbmc.getLocalizedString(30035), common.RSS_MOST_POP_ALL, "RSS",xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), xbmc.translatePath(os.path.join(common.imagepath,"rss_icon.png")), genre = "rss")
Beispiel #44
0
    def addSeasonList( self ):

        print "\n\n adding seasons \n\n"

        # get the seasons list from the show page
        content=common.getHTML(common.args.url)

        # establish seasons context; do we have any?
        try:
            seasonsSegment=re.search('<h3>Full Episodes</h3>.+?</ul>', content, re.DOTALL).group(0)
            # seasonURL, name
            seasons=re.compile('<li><a href="(.+?)">(.+?)</a></li>').findall(seasonsSegment, re.DOTALL)
        except:
            seasons=None

        # get the episodes page header
        headerSegment=re.search('<head>.+?</head>', content, re.DOTALL).group(0)
	#print headerSegment
        #fanart=re.compile(".+?background-image: url\(\\'(.+?)\\'", re.DOTALL).findall(headerSegment, re.DOTALL)[0]

        if seasons:
            # are we flat/1 season?
            if common.settings['flat_season'] == 1 or (len(seasons) == 1 and common.settings['flat_season'] == 0):
                common.args.mode='TV_Episodes_nbc'
                for seasonURL, name in seasons:
                    common.args.url=common.NBC_BASE_URL + seasonURL
                    self.addEpisodeList()
            else:
                for seasonURL, name in seasons:
                    #common.addDirectory(name, common.NBC_BASE_URL + seasonURL, 'TV_Episodes_nbc', fanart=common.NBC_BASE_URL + fanart)
                    common.addDirectory(name, common.NBC_BASE_URL + seasonURL, 'TV_Episodes_nbc', 'null')

        xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))

        return

        ########## ########## for future work with clips and webisodes

        slider=re.compile('VideoSlider\(.+, ({.+})').findall(content)[0]
        del content

        # get seasons and episodes per season; also determine how many episodes in total
        seasons=re.compile('.+?s(\d+): (\d+)').findall(re.search('episode: {.+?}', slider).group(0))
        episodeCount=re.compile('.+?all: (\d+)').findall(re.search('episode: {.+?}', slider).group(0))[0]

        # URL for the slider call and the showID to plug into it
        sliderURL=re.search('url: \"(.+?)\"', slider).group(1)
        show_id=re.search('show_id: (\d+)', slider).group(1)

        # only add episodes if we have any
        if int(episodeCount) > 0:
            # are we flat/1 season?
            if common.settings['flat_season'] == 1 or (len(seasons) == 1 and common.settings['flat_season'] == 0):
                common.args.mode='TV_Episodes_nbc'
                common.args.url="%s?type=episode&show_id=%s&items_per_page=%s" % (sliderURL, show_id, episodeCount)
                self.addEpisodeList()
            else:
                # one folder per season
                for seasonID, seasonEpisodeCount in seasons:
                    if int(seasonEpisodeCount) > 0:  # some seasons in the list have 0 episodes
                        name="Season %s" % (seasonID)
                        common.args.url="%s?type=episode&show_id=%s&season=%s&items_per_page=%s" % (sliderURL, show_id, seasonID, seasonEpisodeCount)
                        common.addDirectory(name, common.args.url, 'TV_Episodes_nbc')

        # add clips folder if not indicated otherwise
        if not(common.settings['only_full_episodes']):
            clipCount=re.compile('.+?all: (\d+)').findall(re.search('clip: {.+?}', slider).group(0))[0]
            if int(clipCount) > 0:
                common.args.url="%s?type=clip&show_id=%s&items_per_page=%s" % (sliderURL, show_id, clipCount)
                if int(episodeCount) > 0: # only add a clips folder if we have episodes, otherwise go straight to the clips
                    common.addDirectory(xbmc.getLocalizedString(30095), common.args.url, 'TV_Clips')
                else:
                    self.addClipsList()

        xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ))