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 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')
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')
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')
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)
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')
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')
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 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 ): 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
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]))