def GetArgs(pathNouns): # Empty args, should only happen in main menu if len(pathNouns) == 0: return ('','','') # We only care about the last pathNoun (index -1), it should have the format "key||encodedUrl||title". (key, url, title) = pathNouns[-1].split('||') return (key, _D(url), title)
def HandleRequest(pathNouns, count): try: title2 = pathNouns[count-1].split("||")[1] pathNouns[count-1] = pathNouns[count-1].split("||")[0] except: title2 = "" dir = MediaContainer("art-default.jpg", viewGroup="List", title1="Remedie", title2=title2.decode("utf-8")) if count == 0: dict = JSON.DictFromURL(FEED_URL + "rpc/channel/load"); for e in dict[u'channels']: id = e[u'id'] title = e[u'name'] if e[u'unwatched_count']: title += ' (' + str(e[u'unwatched_count']) + ')' thumb = "icon-default.png" if u'thumbnail' in e[u'props']: thumb = e[u'props'][u'thumbnail'][u'url'] Log.Add(thumb) dir.AppendItem(DirectoryItem("feed^" + str(id) + "||" + title, title, _R(thumb))) elif pathNouns[0].startswith("feed"): channel_id = pathNouns[0].split("^")[1] dict = JSON.DictFromURL(FEED_URL + "rpc/channel/show?id=" + channel_id) dir.SetViewGroup("InfoList") for e in dict[u'items']: type = e[u'props'][u'type'] id = PLUGIN_PREFIX + "/play^" + _E(e[u'ident']) + "^" + type title = e[u'name'] summary = e[u'props'][u'description'] duration = "" thumb = "" if u'thumbnail' in e[u'props']: thumb = e[u'props'][u'thumbnail'][u'url'] elif u'thumbnail' in dict[u'channel'][u'props']: thumb = dict[u'channel'][u'props'][u'thumbnail'][u'url'] # TODO maybe special case YouTube # TODO rtmp or mms seems not to work with Redirects if re.match('^video/', type): vidItem = VideoItem(id, e[u'name'], summary, duration, thumb) else: Log.Add(e[u'props'][u'link']) vidItem = WebVideoItem(e[u'props'][u'link'], e[u'name'], summary, duration, thumb) dir.AppendItem(vidItem) elif pathNouns[0].startswith("play"): # TODO mark it read paths = pathNouns[0].split("^") Log.Add(paths) url = _D(paths[1]) type = paths[2] Log.Add(url) return Plugin.Redirect(url) return dir.ToXML()
def SelectedVideoSeries(url, title, limit=9999): dir = MediaContainer(FILE_DEFAULT_ART, title1=TEXT_IGN, title2=_D(title)) xml = LoadUrl(url, CACHE_INT_VIDEO_SERIES) for episode in xml.xpath(XPATH_VIDEO_SERIES_EP): limit = limit - 1 if limit < 0: dir.AppendItem(DirectoryItem(_E(url) + "||" + title, TEXT_ALL_EPISODES, None)) break thumb = episode.find("a/img").get("src") desc = episode.find("a/img").get("alt") epUrl = episode.find("a").get("href") dir.AppendItem(CreateVideoItemFromPage(epUrl, thumb, desc)) return dir.ToXML()
def SelectedVideoSeries(url, title, limit=9999): dir = MediaContainer(FILE_DEFAULT_ART, title1=TEXT_IGN, title2=_D(title)) xml = LoadUrl(url, CACHE_INT_VIDEO_SERIES) for episode in xml.xpath(XPATH_VIDEO_SERIES_EP): limit = limit - 1 if limit < 0: dir.AppendItem( DirectoryItem(_E(url) + "||" + title, TEXT_ALL_EPISODES, None)) break thumb = episode.find("a/img").get("src") desc = episode.find("a/img").get("alt") epUrl = episode.find("a").get("href") dir.AppendItem(CreateVideoItemFromPage(epUrl, thumb, desc)) return dir.ToXML()
def HandleRequest(pathNouns, count): if count == 0: return Index() if count > 1 and (pathNouns[1] != "all" or count > 2): (url, title) = pathNouns[count-1].split("||") if pathNouns[0] != PATH_HIT_LIST: url = _D(url) if pathNouns[0] == PATH_TOP_VIDEOS: return TopVideos() elif pathNouns[0] == PATH_LATEST_VIDEOS: return Latest() elif pathNouns[0] == PATH_GAME_TRAILERS: return GameTrailers() elif pathNouns[0] == PATH_MOVIE_TRAILERS: return MovieTrailers() elif pathNouns[0] == PATH_REVIEWS: return Reviews() elif pathNouns[0] == PATH_PREVIEWS: return Previews() elif pathNouns[0] == PATH_VIDEO_SERIES: if count == 1: return VideoSeries() elif pathNouns[1] == "all": count = count - 1 if count == 1: return VideoSeries(True) elif count == 2: return SelectedVideoSeries(url, title, LIMIT_SERIES_EPISODES) else: return SelectedVideoSeries(url, title) elif pathNouns[0] == PATH_HIT_LIST: if count == 1: return HitList() elif count == 2: return SelectedHit(url, title) elif pathNouns[0] == PATH_RECENT_VIDEOS: if count == 1: return RecentVideos() else: return RecentVideosPage(url, title)
def HandleRequest(pathNouns, count): if count == 0: return Index() if count > 1 and (pathNouns[1] != "all" or count > 2): (url, title) = pathNouns[count - 1].split("||") if pathNouns[0] != PATH_HIT_LIST: url = _D(url) if pathNouns[0] == PATH_TOP_VIDEOS: return TopVideos() elif pathNouns[0] == PATH_LATEST_VIDEOS: return Latest() elif pathNouns[0] == PATH_GAME_TRAILERS: return GameTrailers() elif pathNouns[0] == PATH_MOVIE_TRAILERS: return MovieTrailers() elif pathNouns[0] == PATH_REVIEWS: return Reviews() elif pathNouns[0] == PATH_PREVIEWS: return Previews() elif pathNouns[0] == PATH_VIDEO_SERIES: if count == 1: return VideoSeries() elif pathNouns[1] == "all": count = count - 1 if count == 1: return VideoSeries(True) elif count == 2: return SelectedVideoSeries(url, title, LIMIT_SERIES_EPISODES) else: return SelectedVideoSeries(url, title) elif pathNouns[0] == PATH_HIT_LIST: if count == 1: return HitList() elif count == 2: return SelectedHit(url, title) elif pathNouns[0] == PATH_RECENT_VIDEOS: if count == 1: return RecentVideos() else: return RecentVideosPage(url, title)
def HandleRequest(pathNouns, count): try: title2 = pathNouns[count - 1].split("||")[1] pathNouns[count - 1] = pathNouns[count - 1].split("||")[0] except: title2 = "" dir = MediaContainer("art-default.jpg", viewGroup="List", title1="Remedie", title2=title2.decode("utf-8")) if count == 0: dict = JSON.DictFromURL(FEED_URL + "rpc/channel/load") for e in dict[u'channels']: id = e[u'id'] title = e[u'name'] if e[u'unwatched_count']: title += ' (' + str(e[u'unwatched_count']) + ')' thumb = "icon-default.png" if u'thumbnail' in e[u'props']: thumb = e[u'props'][u'thumbnail'][u'url'] Log.Add(thumb) dir.AppendItem( DirectoryItem("feed^" + str(id) + "||" + title, title, _R(thumb))) elif pathNouns[0].startswith("feed"): channel_id = pathNouns[0].split("^")[1] dict = JSON.DictFromURL(FEED_URL + "rpc/channel/show?id=" + channel_id) dir.SetViewGroup("InfoList") for e in dict[u'items']: type = e[u'props'][u'type'] id = PLUGIN_PREFIX + "/play^" + _E(e[u'ident']) + "^" + type title = e[u'name'] summary = e[u'props'][u'description'] duration = "" thumb = "" if u'thumbnail' in e[u'props']: thumb = e[u'props'][u'thumbnail'][u'url'] elif u'thumbnail' in dict[u'channel'][u'props']: thumb = dict[u'channel'][u'props'][u'thumbnail'][u'url'] # TODO maybe special case YouTube # TODO rtmp or mms seems not to work with Redirects if re.match('^video/', type): vidItem = VideoItem(id, e[u'name'], summary, duration, thumb) else: Log.Add(e[u'props'][u'link']) vidItem = WebVideoItem(e[u'props'][u'link'], e[u'name'], summary, duration, thumb) dir.AppendItem(vidItem) elif pathNouns[0].startswith("play"): # TODO mark it read paths = pathNouns[0].split("^") Log.Add(paths) url = _D(paths[1]) type = paths[2] Log.Add(url) return Plugin.Redirect(url) return dir.ToXML()