def GET(self, id): flattr = Flattr() if id == "": id = "1" video = flattr.getVideoById(id) if video is None or video.embeddedcode == "": return "No Oembed data found for that flattr thing!" else: return render.single("Flattr Video Browser", "Flattr Video Browser", "A Flattr API proof of concept", video)
def GET(self, id): flattr = Flattr() if id == "": video = flattr.getRandomVideo(True) thingid = video.thingid return web.seeother('/movie/'+str(thingid)) else: video = flattr.getVideoById(id, True) if video is None or video.embeddedcode == "": return "No Oembed data found for that flattr thing!" else: return renderStatic.movie("Flattr Video Browser", "Flattr Video Browser", "A Flattr API proof of concept", video)
def GET(self, page = u"1"): try: cacheFile = open('data.pkl', 'rb') cache = pickle.load(cacheFile) except: # This takes care of case when no data.pkl file exists (only needed once). cache={} flattr = Flattr() listOfVideos = flattr.getVideoList(page, 8) cache["cache"] = listOfVideos cache["time"] = time() output = open('data.pkl', 'wb') pickle.dump(cache, output) print "Initialize cache" # Input santiation if page == u'': page = u"1" if not page.isdigit(): return "Sorry, that is not a number!" # If it is first browse page, either serve som cache or refresh cache if page == u"1" and (time() - cache["time"] < 60): listOfVideos = cache["cache"] print "Serving from cache" elif page == u"1": flattr = Flattr() listOfVideos = flattr.getVideoList(page, 8) cache["cache"] = listOfVideos cache["time"] = time() output = open('data.pkl', 'wb') pickle.dump(cache, output) print "Refresh cache" else: flattr = Flattr() listOfVideos = flattr.getVideoList(page, 8) return render.browse("Flattr Video Browser", "Flattr Video Browser", "A Flattr API proof of concept", page, listOfVideos)
def GET(self): flattr = Flattr() video = flattr.getRandomVideo() return render.single("Flattr Video Browser", "Flattr Video Browser", "A Flattr API proof of concept", video)
def GET(self): flattr = Flattr() video = flattr.getRandomVideo() thingid = video.thingid return web.seeother('/id/'+str(thingid))