예제 #1
0
파일: web_app.py 프로젝트: armooo/rtsptogo
    def GET(self, tivo_address, path):
        if not tivo_address in [t["address"] for t in discover.get_tivos()]:
            raise Exception("Bad tivo address")
        if not path:
            path = "/"
        else:
            path = "/" + path

        tivo = tivoapi.get_server(tivo_address, config.get("main", "mak"))
        items = tivo.get_container(path)

        def patch_item(item):
            item = item.copy()
            if item["type"] == "container":
                path = item["path"]
                del item["path"]
                url = "http://%s/%s%s" % (web.ctx.env["HTTP_HOST"], tivo_address, path)
                item["url"] = url

            elif item["type"] == "video":
                hostname = web.ctx.env["HTTP_HOST"].split(":")[0]
                url = urlparse.urlparse(item["url"])
                rtsp_port = config.get("main", "rtsp_port")
                item["url"] = "rtsp://%s:%s/%s%s?%s" % (hostname, rtsp_port, tivo_address, url.path, url.query)
            return item

        items = [patch_item(item) for item in items]

        if web.ctx.env["HTTP_ACCEPT"] == "application/json":
            web.header("Content-Type", "application/json")
            return json.dumps([items])
        else:
            return render.listing(items)
예제 #2
0
파일: rtspd.py 프로젝트: armooo/rtsptogo
 def get_video(self):
     url = urlparse.urlparse(self.url)
     host, path = url.path[1:].split('/', 1)
     path = path + '?' + url.query
     server = tivoapi.get_server(host, config.get('main', 'mak'))
     return server.get_video(path)