Example #1
0
    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)
Example #2
0
        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
Example #3
0
def get_tivodecode():
        mak = config.get('main', 'mak')
        tivodecode_command = ('tivodecode -m %s -' % mak).split()
        tivodecode = subprocess.Popen(tivodecode_command, stdout=subprocess.PIPE,
            stdin=subprocess.PIPE)
        return tivodecode
Example #4
0
 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)