Exemple #1
0
    def get(self):
        bind_id = self.get_argument("bind_id")
        youtube_id = self.get_argument("youtube_id", "-1")
        time_watched = self.get_argument("time_watched", -1)
        logger.debug(
            "Set-top box list request received: bind_id: %s, youtube_id: %s, time_watched: %s",
            bind_id,
            youtube_id,
            time_watched,
        )

        try:
            if youtube_id != "-1" and youtube_id != "Title":
                Video.mark_watched(bind_id=bind_id, youtube_id=youtube_id, time_watched=time_watched)
        except:
            dbutils.Session.rollback()

        try:
            container = Video.get_list(bind_id=bind_id, is_stb=True)
            playback_url = fetch_yt_link(container["nowplaying"]["url"])
            playback_url = escape(playback_url + "&title=.mp4")
            container["nowplaying"]["url"] = escape(container["nowplaying"]["url"])
            container["nowplaying"]["title"] = escape(container["nowplaying"]["title"])
            container["nowplaying"]["youtube_id"] = escape(container["nowplaying"]["youtube_id"])
            container["nowplaying"]["playback_url"] = playback_url
        except:
            dbutils.Session.rollback()
            container = []
        logger.info("timewatched: %s youtube_id:%s bind_id:%s", time_watched, youtube_id, bind_id)
        #        self.content_type = 'text/xml' //HACK wtf why doesn't this work..?
        self._headers["Content-Type"] = "text/xml; charset=UTF-8"
        if container != []:
            self.write(dict2xml({"nowplaying": container["nowplaying"]}))
        dbutils.Session.remove()
        self.finish()
Exemple #2
0
    def get(self):
        bind_id = self.get_argument("bind_id")
        youtube_id = self.get_argument("youtube_id", "-1")
        response_format = self.get_argument("response_format", "xml")
        time_watched = self.get_argument("time_watched", -1)
        limit = self.get_argument("limit", 50)

        logger.debug(
            "List request received: bind_id: %s, youtube_id (just watched): %s, response_format: %s, time_watched:%s",
            bind_id,
            youtube_id,
            response_format,
            time_watched,
        )

        try:
            if youtube_id != "-1" and youtube_id != "Title":
                Video.mark_watched(bind_id=bind_id, youtube_id=youtube_id, time_watched=time_watched)
        except:
            dbutils.Session.rollback()
        try:
            container = Video.get_list(bind_id=bind_id, limit=int(limit))
        except:
            dbutils.Session.rollback()
            container = {}
        if response_format == "json":
            self.content_type = "application/json"
            self.write(json.dumps(container))
        else:
            self.content_type = "text/xml"
            self.write(dict2xml(container))
        dbutils.Session.remove()
        self.finish()
Exemple #3
0
    def get(self):
        bind_id = self.get_argument("bind_id")
        youtube_id = self.get_argument("youtube_id", "-1")
        time_watched = self.get_argument("time_watched", -1)

        logger.info(
            "Mark watch request received: bind_id: %s, youtube_id (just watched): %s, time_watched:%s",
            bind_id,
            youtube_id,
            time_watched,
        )

        try:
            if youtube_id != "-1" and youtube_id != "Title":
                Video.mark_watched(bind_id=bind_id, youtube_id=youtube_id, time_watched=time_watched)
        except:
            dbutils.Session.rollback()
        dbutils.Session.remove()
        self.finish()