def main_list(params): lutil.log("tv5monde.main_list "+repr(params)) # Loads the list of videos of the selected category based on the json object retrieved from the server. buffer_json = lutil.get_json(params.get("url")) pattern_videos = '<a title="([^"]+)" href="/video/([^/]+)/[^"]+"> <img src="([^"]+)" .*?<div class="bookmark" id="book_([0-9]+)">' videolist = lutil.find_multiple(buffer_json['content'], pattern_videos) for title, day, thumbnail, videoid in videolist: video_url = 'http://www.tv5mondeplus.com/video-xml/get/%s' % videoid title = title.replace('"', '"') lutil.log('videolist: URL: "%s" Descripcion: "%s" Date: "%s" Thumbnail: "%s"' % (video_url, title, day, thumbnail)) plot = title lutil.addLink(action="play_video", title='%s (%s)' % (title, day), plot=plot, url=video_url, thumbnail=thumbnail) if buffer_json['pager'] is not None: pattern_page = 'pg=([0-9]+)' pattern_total = '<ul class="pager" total="([0-9]+)"' pattern_genre = 'sort=([0-9]+)' last_page = int(lutil.find_first(buffer_json['pager'], pattern_total)) - 1 next_page = int(lutil.find_first(params.get("url"), pattern_page)) + 1 if last_page != next_page: genre = lutil.find_first(params.get("url"), pattern_genre) next_page_url = 'http://www.tv5mondeplus.com/get/videos?pg=%s&type=genre&sort=%s&loadpg=false&order=date' % (next_page, genre) lutil.log('next_page=%s last_page=%s next_page_url="%s"' % (next_page, last_page, next_page_url)) lutil.addDir(action="main_list", title=">> %s" % translation(30010), url=next_page_url) lutil.close_dir(pluginhandle)
def main_list(params): lutil.log("eso.main_list "+repr(params)) # Loads the web page from ESO with the video list. page_url = params.get("url") reset_cache = params.get("reset_cache") genre = params.get("genre") array_index = 0 if eso_url in page_url else 1 root_url = (eso_url, space_url)[array_index] buffer_web = lutil.carga_web(page_url) # Extract video items from the html content pattern_nextpage = '<a href="([^"]*?)">Next</a>' pattern_prevpage = '<a href="([^"]*?)">Previous</a>' pattern_lastpage = '<a href="[^"]*?">([0-9]+)</a>' pattern_pagenum = '/([0-9]+)/' pattern_videos = ('</span><img src="([^"]+)" class="[^"]+" alt="([^"]+)">.*?<a href="(/public/videos/[^"]*?)">', '</span><img src="([^"]+)" class="[^"]+" alt="([^"]+)">.*?<a href="(/videos/[^"]*?)">')[array_index] lutil.set_content_list(pluginhandle, 'tvshows') lutil.set_plugin_category(pluginhandle, genre) # We must setup the previous page entry from the second page onwards. prev_page_url = lutil.find_first(buffer_web, pattern_prevpage) if prev_page_url: prev_page = lutil.find_first(prev_page_url, pattern_pagenum) lutil.log('eso.main_list Value of prev_page: %s prev_page_url: "%s%s"' % (prev_page, root_url, prev_page_url)) prev_page_url = "%s%s" % (root_url, prev_page_url.replace('&', '&').replace('"', '"')) reset_cache = "yes" lutil.addDir(action="main_list", title="<< %s (%s)" % (translation(30106), prev_page), url=prev_page_url, reset_cache=reset_cache, genre=genre) # This is to force ".." option to go back to main index instead of previous page list. updateListing = reset_cache == "yes" for thumbnail, title, video_link in lutil.find_multiple(buffer_web, pattern_videos): video_info = {} url = '%s%s' % (root_url, video_link) if not thumbnail.startswith('http'): thumbnail = '%s%s' % (root_url, thumbnail) title = title.strip().replace('"', '"').replace(''', '´').replace('&', '&') # Cleanup the title. video_info['Genre'] = genre video_info['Plot'] = title # Appends a new item to the xbmc item list lutil.addLink(action="play_video", title=title, url=url, thumbnail=thumbnail, video_info=video_info) # Here we get the next page URL to add it at the end of the current video list page. next_page_url = lutil.find_first(buffer_web, pattern_nextpage) if next_page_url: last_page = lutil.find_multiple(buffer_web, pattern_lastpage)[-1] next_page = lutil.find_first(next_page_url, pattern_pagenum) lutil.log('eso.main_list Value of next_page: %s last_page: %s next_page_url: "%s%s"' % (next_page, last_page, root_url, next_page_url)) next_page_url = "%s%s" % (root_url, next_page_url.replace('&', '&').replace('"', '"')) lutil.addDir(action="main_list", title=">> %s (%s/%s)" % (translation(30010), next_page, last_page), url=next_page_url, reset_cache=reset_cache, genre=genre) lutil.close_dir(pluginhandle, updateListing=updateListing)
def main_list(params): lutil.log("eso.main_list "+repr(params)) # Loads the web page from ESO with the video list. page_url = params.get("url") reset_cache = params.get("reset_cache") genre = params.get("genre") array_index = 0 if eso_url in page_url else 1 root_url = (eso_url, space_url)[array_index] buffer_web = lutil.carga_web(page_url) # Extract video items from the html content pattern_nextpage = '<a href="([^"]*?)">Next</a>' pattern_prevpage = '<a href="([^"]*?)">Previous</a>' pattern_lastpage = '<a href="[^"]*?">([0-9]+)</a>' pattern_pagenum = '/([0-9]+)/' pattern_videos = ('</span><img src="([^"]+)" class="[^"]+" alt="([^"]+)">.*?<a href="(/public/videos/[^"]*?)">', '</span><img src="([^"]+)" class="[^"]+" alt="([^"]+)">.*?<a href="(/videos/[^"]*?)">')[array_index] lutil.set_content_list(pluginhandle, 'tvshows') lutil.set_plugin_category(pluginhandle, genre) # We must setup the previous page entry from the second page onwards. prev_page_url = lutil.find_first(buffer_web, pattern_prevpage) if prev_page_url: prev_page = lutil.find_first(prev_page_url, pattern_pagenum) lutil.log('eso.main_list Value of prev_page: %s prev_page_url: "%s%s"' % (prev_page, root_url, prev_page_url)) prev_page_url = "%s%s" % (root_url, prev_page_url.replace('&', '&').replace('"', '"')) reset_cache = "yes" lutil.addDir(action="main_list", title="<< %s (%s)" % (translation(30106), prev_page), url=prev_page_url, reset_cache=reset_cache, genre=genre) # This is to force ".." option to go back to main index instead of previous page list. updateListing = reset_cache == "yes" for thumbnail, title, video_link in lutil.find_multiple(buffer_web, pattern_videos): video_info = {} url = '%s%s' % (root_url, video_link) if not 'http:' in thumbnail: thumbnail = '%s%s' % (root_url, thumbnail) title = title.strip().replace('"', '"').replace(''', '´').replace('&', '&') # Cleanup the title. video_info['Genre'] = genre video_info['Plot'] = title # Appends a new item to the xbmc item list lutil.addLink(action="play_video", title=title, url=url, thumbnail=thumbnail, video_info=video_info) # Here we get the next page URL to add it at the end of the current video list page. next_page_url = lutil.find_first(buffer_web, pattern_nextpage) if next_page_url: last_page = lutil.find_multiple(buffer_web, pattern_lastpage)[-1] next_page = lutil.find_first(next_page_url, pattern_pagenum) lutil.log('eso.main_list Value of next_page: %s last_page: %s next_page_url: "%s%s"' % (next_page, last_page, root_url, next_page_url)) next_page_url = "%s%s" % (root_url, next_page_url.replace('&', '&').replace('"', '"')) lutil.addDir(action="main_list", title=">> %s (%s/%s)" % (translation(30010), next_page, last_page), url=next_page_url, reset_cache=reset_cache, genre=genre) lutil.close_dir(pluginhandle, updateListing=updateListing)
def index(params): lutil.log("tv5monde.index "+repr(params)) url = 'http://www.tv5mondeplus.com/videos' buffer_html = lutil.carga_web(url) list_pattern = '<div id="tri-par-genre"(.+?)</ul>' lista_genre = lutil.find_first(buffer_html, list_pattern) genre_pattern = '<li><a id="([0-9]+)" [^>]+>([^<]+)<' for genre, label in lutil.find_multiple(lista_genre, genre_pattern): genre_url = 'http://www.tv5mondeplus.com/get/videos?pg=0&type=genre&sort=%s&loadpg=false&order=date' % genre lutil.log('tv5monde.index url=["%s"] genre=["%s"]' % (genre_url, label)) lutil.addDir(action="main_list", title=label, url=genre_url) lutil.close_dir(pluginhandle)
def other_categories(params): lutil.log("esa.other_categories "+repr(params)) action = 'main_list' page_url = 'http://www.esa.int/spaceinvideos/Videos' buffer_web = lutil.carga_web(page_url) category_pattern = '<a href="(/spaceinvideos/Directorates/[^"]*?)">([^<]*?)</a>' for category_link, title in lutil.find_multiple(buffer_web, category_pattern): url = '%s%s/(sortBy)/%s' % (root_url, category_link, sort_method) title = title.replace('"', '"').replace(''', '´').replace('&', '&') # Cleanup the title. lutil.log('esa.other_categories action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) lutil.close_dir(pluginhandle, updateListing=False)
def other_categories(params): lutil.log("esa.other_categories " + repr(params)) action = 'main_list' page_url = 'http://www.esa.int/spaceinvideos/Videos' buffer_web = lutil.carga_web(page_url) category_pattern = '<a href="(/spaceinvideos/Directorates/[^"]*?)">([^<]*?)</a>' for category_link, title in lutil.find_multiple(buffer_web, category_pattern): url = '%s%s/(sortBy)/%s' % (root_url, category_link, sort_method) title = title.replace('"', '"').replace(''', '´').replace( '&', '&') # Cleanup the title. lutil.log( 'esa.other_categories action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) lutil.close_dir(pluginhandle, updateListing=False)
def create_index(params): lutil.log("eso.create_index "+repr(params)) action = 'main_list' # All Videos entry url = params.get("url", 'http://www.eso.org/public/videos/list/1/') + sort_url_param title = translation(30107) genre = 'All the Videos' lutil.log('eso.create_index action=["%s"] title=["All the Videos"] url=["%s"]' % (action, url)) lutil.addDir(action=action, title=title, url=url, genre=genre) array_index = 0 if eso_url in url else 1 root_url = (eso_url, space_url)[array_index] buffer_web = lutil.carga_web(url) pattern_genre= ('<a href="(/public/videos/archive/category/[^"]+)">([^<]+)</a>', '<a href="(/videos/archive/category/[^"]+)">([^<]+)</a>')[array_index] # Category list # This is a hack to avoid repeat the category list at the same time it uses the old order list. category_list = [] for genre_url, genre_title in lutil.find_multiple(buffer_web, pattern_genre): url = '%s%s%s' % (root_url, genre_url, '' if 'sort=' in genre_url else sort_url_param) title = genre_title.strip().replace('"', '"').replace(''', '´').replace('&', '&') # Cleanup the title. if title not in category_list: category_list.append(title) lutil.log('eso.create_index action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) # Spacetelescope web site if root_url == eso_url: action = 'create_index' url = 'http://www.spacetelescope.org/videos/' title = 'Hubble Space Telescope' lutil.log('eso.create_index action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) # Search action = 'search' url = ('http://www.eso.org/public/videos/?search=', 'http://www.spacetelescope.org/videos/?search=')[array_index] title = translation(30104) genre = 'Search' lutil.log('eso.create_index action=["%s"] title=["Search"] url=["%s"]' % (action, url)) lutil.addDir(action=action, title=title, url=url, genre=genre) lutil.close_dir(pluginhandle, updateListing=False)
def create_index(params): lutil.log("esa.create_index " + repr(params)) action = 'main_list' # All Videos entry url = 'http://www.esa.int/spaceinvideos/content/search?SearchText=&result_type=videos_online&sortBy=%s' % sort_method title = translation(30107) genre = 'All the Videos' lutil.log( 'esa.create_index action=["%s"] title=["All the Videos"] url=["%s"]' % (action, url)) lutil.addDir(action=action, title=title, url=url, genre=genre) # Euronews url = 'http://www.esa.int/spaceinvideos/content/search?SearchText=&result_type=euronews&sortBy=published' title = 'Euronews' lutil.log('esa.create_index action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) # Earth from Space url = 'http://www.esa.int/spaceinvideos/content/search?SearchText=%22Earth+from+Space%3A%22&SearchButton=Go' title = 'Earth from Space' lutil.log('esa.create_index action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) # Science@ESA url = 'http://www.esa.int/spaceinvideos/content/search?SearchText=%22Science@ESA%3A%22&sortBy=published&SearchButton=Go' title = 'Science@ESA' lutil.log('esa.create_index action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) # Other Categories action = 'other_categories' url = '' title = translation(30108) genre = 'Other Categories' lutil.log( 'esa.create_index action=["%s"] title=["Other Categories"] url=["%s"]' % (action, url)) lutil.addDir(action=action, title=title, url=url, genre=genre) # Search action = 'search' url = '' title = translation(30104) genre = 'Search' lutil.log('esa.create_index action=["%s"] title=["Search"] url=["%s"]' % (action, url)) lutil.addDir(action=action, title=title, url=url, genre=genre) lutil.close_dir(pluginhandle, updateListing=False)
def main_list(params): lutil.log("esa.main_list " + repr(params)) # Loads the web page from ESA with the video list. page_url = params.get("url") reset_cache = params.get("reset_cache") genre = params.get("genre") buffer_web = lutil.carga_web(page_url) # Extract video items from the html content pattern_currentpage = '<span class="current">([^<]*?)</span>' pattern_page_url = '^%s([^\?]+)' pattern_nextpage = '<span class="next"><a href="([^"]*?)">' pattern_prevpage = '<span class="previous"><a href="([^"]*?)">' pattern_last = '<span class="other"><a href="[^"]*?">([^<]+)</a></span>' pattern_videos = '<div class="psr_item_grid">(.*?)</div>' pattern_videolink = '<a href="([^"]*?)"' pattern_thumbnail = '<img src="([^"]*?)"' pattern_title = '<span class="line2hell">([^<]+)</span>' pattern_date = '<span class="date">([^<]*?)</span>' pattern_year = '([0-9]{4})' lutil.set_content_list(pluginhandle, 'tvshows') lutil.set_plugin_category(pluginhandle, genre) page_current = lutil.find_first(buffer_web, pattern_currentpage) or '1' page_url_pref = lutil.find_first(page_url, pattern_page_url % root_url) # We must setup the previous page entry from the second page onwards. if page_current != '1': prev_page_url = lutil.find_first(buffer_web, pattern_prevpage) lutil.log('esa.main_list Value of current_page_url: "%s"' % page_url) prev_page_pref = lutil.find_first(prev_page_url, pattern_page_url % '') prev_page_url = page_url.replace(page_url_pref, prev_page_pref) reset_cache = "yes" lutil.addDir(action="main_list", title="<< %s (%s)" % (translation(30106), (int(page_current) - 1)), url=prev_page_url, reset_cache=reset_cache, genre=genre) # This is to force ".." option to go back to main index instead of previous page list. updateListing = reset_cache == "yes" videolist = lutil.find_multiple(buffer_web, pattern_videos) for video_entry in videolist: video_info = {} video_link = lutil.find_first(video_entry, pattern_videolink) thumbnail_link = lutil.find_first(video_entry, pattern_thumbnail) title = lutil.find_first(video_entry, pattern_title) title = title.replace('"', '"').replace(''', '´').replace( '&', '&') # Cleanup the title. date = lutil.find_first(video_entry, pattern_date).strip().replace(' ', '') if date: video_info['Year'] = lutil.find_first(date, pattern_year) title = '%s (%s)' % (title, date) url = '%s%s' % (root_url, video_link) thumbnail = '%s%s' % (root_url, thumbnail_link) video_info['Genre'] = genre video_info[ 'Plot'] = title # The description only appears when we load the link. lutil.log( 'esa.main_list Videolist: URL: "%s" Title: "%s" Thumbnail: "%s"' % (url, title, thumbnail)) # Appends a new item to the xbmc item list lutil.addLink(action="play_video", title=title, url=url, thumbnail=thumbnail, video_info=video_info, show_fanart=show_fanart) # Here we get the next page URL to add it at the end of the current video list page. next_page_url = lutil.find_first(buffer_web, pattern_nextpage) if next_page_url: next_page_pref = lutil.find_first(next_page_url, pattern_page_url % '') last_page = lutil.find_multiple(buffer_web, pattern_last)[-1] or '' lutil.log("esa.main_list Value of last_page: %s" % last_page) lutil.log('esa.main_list Value of current_page_url: "%s"' % page_url) next_page_url = page_url.replace(page_url_pref, next_page_pref) lutil.addDir(action="main_list", title=">> %s (%s/%s)" % (translation(30010), int(page_current) + 1, last_page), url=next_page_url, reset_cache=reset_cache, genre=genre) lutil.close_dir(pluginhandle, updateListing=updateListing)
def create_index(params): lutil.log("esa.create_index "+repr(params)) action = 'main_list' # All Videos entry url = 'http://www.esa.int/spaceinvideos/content/search?SearchText=&result_type=videos_online&sortBy=%s' % sort_method title = translation(30107) genre = 'All the Videos' lutil.log('esa.create_index action=["%s"] title=["All the Videos"] url=["%s"]' % (action, url)) lutil.addDir(action=action, title=title, url=url, genre=genre) # Euronews url = 'http://www.esa.int/spaceinvideos/content/search?SearchText=&result_type=euronews&sortBy=published' title = 'Euronews' lutil.log('esa.create_index action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) # Earth from Space url = 'http://www.esa.int/spaceinvideos/content/search?SearchText=%22Earth+from+Space%3A%22&SearchButton=Go' title = 'Earth from Space' lutil.log('esa.create_index action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) # Science@ESA url = 'http://www.esa.int/spaceinvideos/content/search?SearchText=%22Science@ESA%3A%22&sortBy=published&SearchButton=Go' title = 'Science@ESA' lutil.log('esa.create_index action=["%s"] title=["%s"] url=["%s"]' % (action, title, url)) lutil.addDir(action=action, title=title, url=url, genre=title) # Other Categories action = 'other_categories' url = '' title = translation(30108) genre = 'Other Categories' lutil.log('esa.create_index action=["%s"] title=["Other Categories"] url=["%s"]' % (action, url)) lutil.addDir(action=action, title=title, url=url, genre=genre) # Search action = 'search' url = '' title = translation(30104) genre = 'Search' lutil.log('esa.create_index action=["%s"] title=["Search"] url=["%s"]' % (action, url)) lutil.addDir(action=action, title=title, url=url, genre=genre) lutil.close_dir(pluginhandle, updateListing=False)
def main_list(params): lutil.log("esa.main_list "+repr(params)) # Loads the web page from ESA with the video list. page_url = params.get("url") reset_cache = params.get("reset_cache") genre = params.get("genre") buffer_web = lutil.carga_web(page_url) # Extract video items from the html content pattern_currentpage = '<span class="current">([^<]*?)</span>' pattern_page_url = '^%s([^\?]+)' pattern_nextpage = '<span class="next"><a href="([^"]*?)">' pattern_prevpage = '<span class="previous"><a href="([^"]*?)">' pattern_last = '<span class="other"><a href="[^"]*?">([^<]+)</a></span>' pattern_videos = '<div class="psr_item_grid">(.*?)</div>' pattern_videolink = '<a href="([^"]*?)"' pattern_thumbnail = '<img src="([^"]*?)"' pattern_title = '<span class="line2hell">([^<]+)</span>' pattern_date = '<span class="date">([^<]*?)</span>' pattern_year = '([0-9]{4})' lutil.set_content_list(pluginhandle, 'tvshows') lutil.set_plugin_category(pluginhandle, genre) page_current = lutil.find_first(buffer_web, pattern_currentpage) or '1' page_url_pref = lutil.find_first(page_url, pattern_page_url % root_url) # We must setup the previous page entry from the second page onwards. if page_current != '1': prev_page_url = lutil.find_first(buffer_web, pattern_prevpage) lutil.log('esa.main_list Value of current_page_url: "%s"' % page_url) prev_page_pref = lutil.find_first(prev_page_url, pattern_page_url % '') prev_page_url = page_url.replace(page_url_pref, prev_page_pref) reset_cache = "yes" lutil.addDir(action="main_list", title="<< %s (%s)" % (translation(30106), (int(page_current) - 1)), url=prev_page_url, reset_cache=reset_cache, genre=genre) # This is to force ".." option to go back to main index instead of previous page list. updateListing = reset_cache == "yes" videolist = lutil.find_multiple(buffer_web, pattern_videos) for video_entry in videolist: video_info = {} video_link = lutil.find_first(video_entry, pattern_videolink) thumbnail_link = lutil.find_first(video_entry, pattern_thumbnail) title = lutil.find_first(video_entry, pattern_title) title = title.replace('"', '"').replace(''', '´').replace('&', '&') # Cleanup the title. date = lutil.find_first(video_entry, pattern_date).strip().replace(' ', '') if date: video_info['Year'] = lutil.find_first(date, pattern_year) title = '%s (%s)' % (title, date) url = '%s%s' % (root_url, video_link) thumbnail = '%s%s' % (root_url, thumbnail_link) video_info['Genre'] = genre video_info['Plot'] = title # The description only appears when we load the link. lutil.log('esa.main_list Videolist: URL: "%s" Title: "%s" Thumbnail: "%s"' % (url, title, thumbnail)) # Appends a new item to the xbmc item list lutil.addLink(action="play_video", title=title, url=url, thumbnail=thumbnail, video_info=video_info, show_fanart=show_fanart) # Here we get the next page URL to add it at the end of the current video list page. next_page_url = lutil.find_first(buffer_web, pattern_nextpage) if next_page_url: next_page_pref = lutil.find_first(next_page_url, pattern_page_url % '') last_page = lutil.find_multiple(buffer_web, pattern_last)[-1] or '' lutil.log("esa.main_list Value of last_page: %s" % last_page) lutil.log('esa.main_list Value of current_page_url: "%s"' % page_url) next_page_url = page_url.replace(page_url_pref, next_page_pref) lutil.addDir(action="main_list", title=">> %s (%s/%s)" % (translation(30010), int(page_current) + 1, last_page), url=next_page_url, reset_cache=reset_cache, genre=genre) lutil.close_dir(pluginhandle, updateListing=updateListing)