[MerlinSkinThemes] - fix crash when themes.xml is missing reported by ultravi
[enigma2-plugins.git] / streamserverseek / src / plugin.py
1 from Plugins.Plugin import PluginDescriptor
2
3 from enigma import eEnv
4 from Plugins.Extensions.WebInterface.WebChilds.Toplevel import addExternalChild
5 from WebChilds.ScreenPageCORS import ScreenPageCORS
6
7 from twisted.web import static
8 from twisted.python import util
9 from twisted.web.server import GzipEncoderFactory
10 from twisted.web.resource import EncodingResourceWrapper
11
12 from Plugins.Extensions.StreamServerSeek.StreamServerSeek import StreamServerSeek
13 from WebChilds.Stream import StreamResource
14 from WebChilds.Proxy import ProxyResource
15 from WebChilds.Vod import VodResource
16
17 if hasattr(static.File, 'render_GET'):
18         class File(static.File):
19                 def render_POST(self, request):
20                         return self.render_GET(request)
21 else:
22         File = static.File
23
24 class M3u8GzipEncoderFactory(GzipEncoderFactory):
25         def encoderForRequest(self, request):
26                 if request.postpath[0].startswith("stream.m3u8"):
27                         return GzipEncoderFactory.encoderForRequest(self, request)
28
29 def autostart(reason,**kwargs):
30         if "session" in kwargs:
31                 sss = StreamServerSeek(session = kwargs["session"])
32                 print "session %s" % sss
33
34                 root = File(eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/StreamServerSeek/web-data"))
35                 root.putChild("web", ScreenPageCORS(kwargs["session"], util.sibpath(__file__, "web"), True) )
36                 root.putChild("stream", StreamResource(kwargs["session"]))
37                 root.putChild("proxy", ProxyResource(kwargs["session"]))
38                 root.putChild("vod", EncodingResourceWrapper(VodResource(kwargs["session"]), [M3u8GzipEncoderFactory()]))
39                 addExternalChild( ("streamserverseek", root) )
40
41 def Plugins(**kwargs): 
42         return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], fnc = autostart)]