[StreamServerSeek] Stream-Button in MovieList
[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
10 from Plugins.Extensions.StreamServerSeek.StreamServerSeek import StreamServerSeek
11 from WebChilds.Stream import StreamResource
12 from WebChilds.Proxy import ProxyResource
13
14 import Plugins.Extensions.WebInterface.WebChilds.Toplevel
15
16 if hasattr(static.File, 'render_GET'):
17         class File(static.File):
18                 def render_POST(self, request):
19                         return self.render_GET(request)
20 else:
21         File = static.File
22
23 class MyFile(File):
24         def getChild(self, path, request):
25                 if (request.path == '/web-data/tpl/default/tplMovieList.htm'):
26                         print "[StreamserverSeek] Serve own version of /web-data/tpl/default/tplMovieList.htm"
27                         return self.createSimilarFile(util.sibpath(__file__, "webinterface-data/tpl/default/tplMovieList.htm"))
28
29                 return File.getChild(self, path, request)
30
31 Orig_Toplevel_getToplevel = Plugins.Extensions.WebInterface.WebChilds.Toplevel.getToplevel
32
33 def Toplevel_getToplevel(session):
34         result = Orig_Toplevel_getToplevel(session)
35         result.putChild("web-data", MyFile(util.sibpath(__file__, "../WebInterface/web-data")))
36         print "[StreamserverSeek] hooked WebInterface.WebChilds.Toplevel.getToplevel"
37         return result
38
39 Plugins.Extensions.WebInterface.WebChilds.Toplevel.getToplevel = Toplevel_getToplevel
40
41 def autostart(reason,**kwargs):
42         if "session" in kwargs:
43                 sss = StreamServerSeek(session = kwargs["session"])
44                 print "session %s" % sss
45
46                 root = File(eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/StreamServerSeek/web-data"))
47                 root.putChild("web", ScreenPageCORS(kwargs["session"], util.sibpath(__file__, "web"), True) )
48                 root.putChild("stream", StreamResource(kwargs["session"]))
49                 root.putChild("proxy", ProxyResource(kwargs["session"]))
50                 addExternalChild( ("streamserverseek", root) )
51
52 def Plugins(**kwargs): 
53         return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], fnc = autostart)]