正在显示
1 个修改的文件
包含
13 行增加
和
8 行删除
| @@ -36,7 +36,7 @@ reload(sys) | @@ -36,7 +36,7 @@ reload(sys) | ||
| 36 | exec("sys.setdefaultencoding('utf-8')") | 36 | exec("sys.setdefaultencoding('utf-8')") |
| 37 | assert sys.getdefaultencoding().lower() == "utf-8" | 37 | assert sys.getdefaultencoding().lower() == "utf-8" |
| 38 | 38 | ||
| 39 | -import os, json, time, datetime, cherrypy, threading | 39 | +import os, json, time, datetime, cherrypy, threading, urllib2 |
| 40 | 40 | ||
| 41 | # simple log functions. | 41 | # simple log functions. |
| 42 | def trace(msg): | 42 | def trace(msg): |
| @@ -329,14 +329,19 @@ class RESTProxy(object): | @@ -329,14 +329,19 @@ class RESTProxy(object): | ||
| 329 | def GET(self, *args, **kwargs): | 329 | def GET(self, *args, **kwargs): |
| 330 | enable_crossdomain() | 330 | enable_crossdomain() |
| 331 | 331 | ||
| 332 | - hls = { | ||
| 333 | - "args": args, | ||
| 334 | - "kwargs": kwargs | ||
| 335 | - } | 332 | + url = "http://" + "/".join(args); |
| 333 | + print "start to proxy url: %s"%url | ||
| 336 | 334 | ||
| 337 | - ret = json.dumps(hls) | ||
| 338 | - print ret | ||
| 339 | - return ret | 335 | + f = None |
| 336 | + try: | ||
| 337 | + f = urllib2.urlopen(url) | ||
| 338 | + f.read() | ||
| 339 | + except: | ||
| 340 | + print "error proxy url: %s"%url | ||
| 341 | + finally: | ||
| 342 | + if f: f.close() | ||
| 343 | + print "completed proxy url: %s"%url | ||
| 344 | + return url | ||
| 340 | 345 | ||
| 341 | ''' | 346 | ''' |
| 342 | handle the hls requests: hls stream. | 347 | handle the hls requests: hls stream. |
-
请 注册 或 登录 后发表评论