WebM transcoding added
[vpproxy.git] / plugins / m3u_plugin.py
index 4104e43240ea63e8d6e81fc5b8332d2834e66850..2263dfe930007cbe2bcfe58fbf3121fba8362c98 100644 (file)
@@ -17,7 +17,7 @@ import os
 
 class M3u(VPProxyPlugin):
 
-    handlers = ('m3u', )
+    handlers = ('m3u', 'm3ut' )
 
     logger = logging.getLogger('plugin_m3u')
     playlist = None
@@ -28,6 +28,15 @@ class M3u(VPProxyPlugin):
 
         self.splitted_path=connection.path.split('/')
         
+        if self.splitted_path[1]=='m3u':
+          prefix='get'
+        elif self.splitted_path[1]=='m3uw':
+          prefix='webm'  
+        elif self.splitted_path[1]=='m3ut':
+          prefix='mp4'  
+        else:
+          connection.dieWithError(404)  
+        
         if len(self.splitted_path)>3:
             connection.dieWithError()
             return
@@ -61,7 +70,7 @@ class M3u(VPProxyPlugin):
         try:
             playlist=parseM3U(m3u_file)
         except:
-            connection.dieWithError()
+            connection.dieWithError(404)
             return    
 
         if not playlist:
@@ -76,7 +85,7 @@ class M3u(VPProxyPlugin):
             channel['url']=record.path.decode('utf-8')            
             playlistgen.addItem(channel)
 
-        exported = playlistgen.exportm3u(hostport)
+        exported = playlistgen.exportm3u(hostport,prefix)
         exported = exported.encode('utf-8')
         connection.wfile.write(exported)