diff options
| author | Antti Ajanki <antti.ajanki@iki.fi> | 2010-11-17 20:02:47 +0200 |
|---|---|---|
| committer | Antti Ajanki <antti.ajanki@iki.fi> | 2010-11-17 20:02:47 +0200 |
| commit | b854b2f1fd419e636364f0111e070203d1031ed0 (patch) | |
| tree | e6156c913e0679a4ea1c4c2bd93d16dc701e7a56 /examples | |
| parent | 0c998299e3b91a36821b2ede65c1333bfd31e381 (diff) | |
| download | vdr-plugin-webvideo-b854b2f1fd419e636364f0111e070203d1031ed0.tar.gz vdr-plugin-webvideo-b854b2f1fd419e636364f0111e070203d1031ed0.tar.bz2 | |
play using xineliboutput if url points to a video
Diffstat (limited to 'examples')
| -rwxr-xr-x | examples/watchonvdr_proxy.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/examples/watchonvdr_proxy.py b/examples/watchonvdr_proxy.py index 808e526..2ade294 100755 --- a/examples/watchonvdr_proxy.py +++ b/examples/watchonvdr_proxy.py @@ -13,8 +13,10 @@ import urllib import socket +import os.path from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from optparse import OptionParser +from urlparse import urlparse SVDRP_ADDRESS = ('', 2001) # default port is 6419 starting from VDR 1.7.15 @@ -23,6 +25,10 @@ class SVDRPRequestHandler(BaseHTTPRequestHandler): self.sock.sendall(cmd) self.sock.sendall('\r\n') + def is_video_file(self, url): + ext = os.path.splitext(urlparse(url).path)[1] + return ext not in ('', '.html', '.html') + def do_GET(self): if self.path.startswith('/play?url='): videopage = urllib.unquote(self.path[len('/play?url='):]) @@ -35,7 +41,15 @@ class SVDRPRequestHandler(BaseHTTPRequestHandler): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(10) self.sock.connect(SVDRP_ADDRESS) - self.send('plug webvideo play %s' % videopage) + + # If this is a video file ask xineliboutput to play + # it. Otherwise assume it is a video page from one of + # the supported sites and let webvideo extract the + # video address from the page. + if self.is_video_file(videopage): + self.send('plug xineliboutput pmda %s' % videopage) + else: + self.send('plug webvideo play %s' % videopage) self.send('quit') while len(self.sock.recv(4096)) > 0: pass |
