def Start(): Plugin.AddRequestHandler(CHANNELS_PLUGIN_PREFIX, HandleRequest, "CHANNELS", "icon-default.jpg", "art-default.jpg") Plugin.AddViewGroup("InfoList", viewMode="InfoList", contentType="items") Plugin.AddViewGroup("List", viewMode="List", contentType="items") Prefs.Expose("device_code", "Device Code (from Channels User Profile)") Prefs.Expose("user_id", "User ID (from Channels User Profile)")
def Start(): Plugin.AddPrefixHandler(APPLICATIONS_PREFIX, ApplicationsMainMenu, L('ApplicationsTitle'), ART, ICON) Plugin.AddViewGroup("Details", viewMode="InfoList", mediaType="items") MediaContainer.art = R(ART) MediaContainer.title1 = NAME DirectoryItem.thumb = R(ICON)
def Start(): Plugin.AddPrefixHandler(PLUGIN_PREFIX, MainMenu, 'JT France2', 'icon-default.jpg', 'art-default.jpg') Plugin.AddViewGroup("Details", viewMode="InfoList", mediaType="items") Plugin.AddViewGroup("ShowList", viewMode="List", mediaType="items") MediaContainer.title1 = 'Journal de France2' MediaContainer.content = 'Items' MediaContainer.art = R('art-default.jpg') HTTP.SetCacheTime(CACHE_INTERVAL)
def Start(): # default cache time HTTP.SetCacheTime(C["CACHE_TTL"]) # Prefetch some content # HTTP.PreCache(_GameListURL(), cacheTime=C["GAME_CACHE_TTL"]) Plugin.AddPrefixHandler(C["PLUGIN_PREFIX"], MainMenu, C["PLUGIN_NAME"] + ((" (" + str(C["PLUGIN_VERSION"]) + ")") if C["VERSION_IN_PLUGIN_NAME"] else ""), 'icon-default.png', 'art-default.jpg') Plugin.AddViewGroup("List", viewMode="List", mediaType="items") Plugin.AddViewGroup("Details", viewMode="InfoList", mediaType="items")
def Start(): Plugin.AddRequestHandler(TIVO_PLUGIN_PREFIX, HandleRequest, "TiVo", "icon-default.jpg", "art-default.jpg") Plugin.AddViewGroup("InfoList", viewMode="InfoList", contentType="items") Prefs.Expose("MAC", "Media Access Key") path = Plugin.DataPath + CookiesFile tvd = Plugin.ResourceFilePath("tivodecode") os.chmod(tvd, 0755) if os.path.isfile(path): CookiesJar.load(path)
def TivoVideo(count, pathNouns): thread.start_new_thread(TivoServerThread, ("127.0.0.1", TIVO_PORT)) #playlist = PLS() #playlist.AppendTrack("http://127.0.0.1:" + str(TIVO_PORT) + "/" + pathNouns[1] + "/" + pathNouns[2], base64.b64decode(pathNouns[3], "_;")) #Plugin.Response["Content-Type"] = playlist.ContentType #return playlist.Content() url = "http://127.0.0.1:" + str( TIVO_PORT) + "/" + pathNouns[1] + "/" + pathNouns[2] return Plugin.Redirect(url)
def do_GET(self): ip = string.split(self.path[1:], "/")[0] url = base64.b64decode(string.split(self.path[1:], "/", 1)[1], "_;") try: self.send_response(200) self.send_header('Content-type', 'video/mpeg2') self.end_headers() tvd = Plugin.ResourceFilePath("tivodecode") # authhandler = urllib2.HTTPDigestAuthHandler() # authhandler.add_password("TiVo DVR", "http://" + ip + ":80/", "tivo", Prefs.Get("MAC")) # Log.Add("Starting httpstuff1") # opener = urllib2.build_opener(authhandler, urllib2.HTTPCookieProcessor(CookiesJar)) # Log.Add("Starting httpstuff2 : " + url) # urlhandle = opener.open(url) # tivodecode = Popen([tvd, "-m", Prefs.Get("MAC"), "-"], stdin=urlhandle, stdout=PIPE) curlp = Popen([ "/usr/bin/curl", url, "--digest", "-s", "-u", "tivo:" + Prefs.Get("MAC"), "-c", "/tmp/cookies.txt" ], stdout=PIPE) tivodecode = Popen([tvd, "-m", Prefs.Get("MAC"), "-"], stdin=curlp.stdout, stdout=PIPE) while True: data = tivodecode.stdout.read(4192) if not data: break self.wfile.write(data) #tivodecode.communicate() except IOError, e: Log.Add("Got an IO Error") if hasattr(e, 'code'): Log.Add("Failed with code : %s" % e.code) if hasattr(e, 'reason'): Log.Add("Failed with reason :" + e.reason)
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 Start(): Plugin.AddRequestHandler(PLUGIN_PREFIX, HandleRequest, "Remedie", "icon-default.png", "art-default.jpg") Plugin.AddViewGroup("InfoList", viewMode="InfoList", contentType="items") Plugin.AddViewGroup("List", viewMode="List", contentType="items")
def Start(): Plugin.AddRequestHandler(IGN_PREFIX, HandleRequest, TEXT_IGN, FILE_DEFAULT_ICON, FILE_DEFAULT_ART)
def Start(): Plugin.AddRequestHandler(DTV_PLUGIN_PREFIX, HandleVideosRequest, "demoscene.tv", "icon-default.png", "art-default.png") Plugin.AddViewGroup("Details", viewMode="InfoList", contentType="episode")
def Start(): Plugin.AddRequestHandler(PLUGIN_PREFIX, HandlePhotosRequest, "dinosaurcomics", "icon-default.png", "art-default.jpg") Plugin.AddViewGroup("InfoList", viewMode="InfoList", contentType="items")
def HandleRequest(pathNouns, count): user_id = Prefs.Get("user_id") device_code = Prefs.Get("device_code") Log.Add("Handling request for paths " + (",".join(pathNouns))) if count == 0: dir = MediaContainer('art-default.jpg', None, "Channels") dir.AppendItem( DirectoryItem("most_watched_week", "Most Watched This Week", "")) dir.AppendItem( DirectoryItem("most_watched_all", "Most Watched All Time", "")) dir.AppendItem( DirectoryItem("most_watched_month", "Most Watched This Month", "")) dir.AppendItem( DirectoryItem("newest_videos_week", "Newest Videos This Week", "")) dir.AppendItem( DirectoryItem("newest_videos_today", "Newest Videos Today", "")) dir.AppendItem( SearchDirectoryItem("search", "Search", "Search Channels.com", Plugin.ExposedResourcePath("search.png"))) dir.AppendItem(DirectoryItem("my_feed", "My Feed", "")) if user_id != None: dir.AppendItem( SearchDirectoryItem( "pref^user_id", "Change Channels User Id [" + user_id + "]", "Change your Channels User ID.", "")) else: dir.AppendItem( SearchDirectoryItem( "pref^user_id", "Set your User ID", "Go to Edit Profile - Tools and see your user ID.", "")) if device_code != None: dir.AppendItem( SearchDirectoryItem( "pref^device_code", "Change Channels Device Code [" + device_code + "]", "Change your Channels Device Code.", "")) else: dir.AppendItem( SearchDirectoryItem( "pref^device_code", "Set your Device Code", "Go to Edit Profile - Tools and see your Device Code.", "")) return dir.ToXML() elif pathNouns[0] == "most_watched_week": url = CHANNELS_URL + "popular/videos/week?format=rss" Log.Add("Loading " + url) return populateFromFeed(url, "Most Watched This Week") elif pathNouns[0] == "most_watched_month": url = CHANNELS_URL + "popular/videos/month?format=rss" Log.Add("Loading " + url) return populateFromFeed(url, "Most Watched This Month") elif pathNouns[0] == "most_watched_all": url = CHANNELS_URL + "popular/videos/all?format=rss" Log.Add("Loading " + url) return populateFromFeed(url, "Most Watched All Time") elif pathNouns[0] == "newest_videos_today": url = CHANNELS_URL + "newest/videos/today?format=rss" Log.Add("Loading " + url) return populateFromFeed(url, "Newest Videos Today") elif pathNouns[0] == "newest_videos_week": url = CHANNELS_URL + "newest/videos/week?format=rss" Log.Add("Loading " + url) return populateFromFeed(url, "Newest Videos This Week") elif pathNouns[0] == "my_feed": Log.Add("Handling my feed only if user_id and device_code are there.") if user_id != None and device_code != None: url = CHANNELS_URL + "device_feed?format=rss&user_id=" + user_id + "&device_code=" + device_code Log.Add("Loading " + url) return populateFromFeed(url, "My Feed") elif pathNouns[0].startswith("pref"): if count == 2: field = pathNouns[0].split("^")[1] Prefs.Set(field, pathNouns[1]) if field == "user_id": dir.SetMessage("Channels Preferences", "Channels User ID Set.") else: dir.SetMessage("Channels Preferences", "Channels Device Code Set") elif pathNouns[0] == "search": if count > 1: query = pathNouns[1] if count > 2: for i in range(2, len(pathNouns)): query += "/%s" % pathNouns[i] return populateFromFeed( CHANNELS_SEARCH_URL + urllib.quote_plus(query), "Query: " + query)