#!/usr/bin/env python




##################################################
## DEPENDENCIES
import sys
import os
import os.path
try:
    import builtins as builtin
except ImportError:
    import __builtin__ as builtin
from os.path import getmtime, exists
import time
import types
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import *
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
from six.moves.urllib.parse import quote
from Plugins.Extensions.OpenWebif.controllers.i18n import tstrings

##################################################
## MODULE CONSTANTS
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.4.4'
__CHEETAH_versionTuple__ = (2, 4, 4, 'development', 0)
__CHEETAH_genTime__ = 1644610943.356035
__CHEETAH_genTimestamp__ = 'Fri Feb 11 20:22:23 2022'
__CHEETAH_src__ = '/home/nonsolosat/openpli-dreambox-oe-core/build/tmp/work/dm7080-oe-linux/enigma2-plugin-extensions-openwebif/gitAUTOINC+81b15e17ab-r0/git/plugin/controllers/views/mobile/movies.tmpl'
__CHEETAH_srcLastModified__ = 'Fri Feb 11 20:05:52 2022'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'

if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
    raise AssertionError(
      'This template was compiled with Cheetah version'
      ' %s. Templates compiled before version %s must be recompiled.'%(
         __CHEETAH_version__, RequiredCheetahVersion))

##################################################
## CLASSES

class movies(Template):

    ##################################################
    ## CHEETAH GENERATED METHODS


    def __init__(self, *args, **KWs):

        super(movies, self).__init__(*args, **KWs)
        if not self._CHEETAH__instanceInitialized:
            cheetahKWArgs = {}
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
            for k,v in KWs.items():
                if k in allowedKWs: cheetahKWArgs[k] = v
            self._initCheetahInstance(**cheetahKWArgs)
        

    def respond(self, trans=None):



        ## CHEETAH: main method generated for this template
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write(u'''<body>
\t<div data-role="page">
\t\t<div id="header">
\t\t\t<div class="button" onclick="history.back()">''')
        _v = VFFSL(SL,"tstrings",True)['back'] # u"$tstrings['back']" on line 6, col 49
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['back']")) # from line 6, col 49.
        write(u'''</div>
\t\t\t<h1><a style="color:#FFF;text-decoration:none;" href=\'/mobile\'>OpenWebif</a></h1>
\t\t\t<h2>''')
        _v = VFFSL(SL,"tstrings",True)['movies'] # u"$tstrings['movies']" on line 8, col 8
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['movies']")) # from line 8, col 8.
        write(u'''</h2>
\t\t</div>
\t\t<div data-role="fieldcontain">
\t\t\t<select name="select-choice-1" id="select-choice-moviedir" onChange="window.location.href=\'/mobile/movies?dirname=\'+escape(options[selectedIndex].value);">
\t\t\t\t<option value="''')
        _v = VFFSL(SL,"directory",True) # u'$directory' on line 12, col 20
        if _v is not None: write(_filter(_v, rawExpr=u'$directory')) # from line 12, col 20.
        write(u'''">''')
        _v = VFFSL(SL,"directory",True) # u'$directory' on line 12, col 32
        if _v is not None: write(_filter(_v, rawExpr=u'$directory')) # from line 12, col 32.
        write(u'''</option>
''')
        for bookmark in VFFSL(SL,"bookmarks",True): # generated from line 13, col 5
            write(u'''\t\t\t\t<option value="''')
            _v = VFFSL(SL,"directory",True) # u'$directory' on line 14, col 20
            if _v is not None: write(_filter(_v, rawExpr=u'$directory')) # from line 14, col 20.
            _v = VFFSL(SL,"bookmark",True) # u'$bookmark' on line 14, col 30
            if _v is not None: write(_filter(_v, rawExpr=u'$bookmark')) # from line 14, col 30.
            write(u'''">''')
            _v = VFFSL(SL,"bookmark",True) # u'$bookmark' on line 14, col 41
            if _v is not None: write(_filter(_v, rawExpr=u'$bookmark')) # from line 14, col 41.
            write(u'''</option>
''')
        write(u'''\t\t\t</select>
\t\t</div>
\t\t<div id="contentContainer">
\t\t\t<ul data-role="listview" data-inset="true" data-theme="d">
\t\t\t\t<li data-role="list-divider" role="heading" data-theme="b">''')
        _v = VFFSL(SL,"tstrings",True)['movies'] # u"$tstrings['movies']" on line 20, col 64
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['movies']")) # from line 20, col 64.
        write(u'''</li>
''')
        for movie in VFFSL(SL,"movies",True): # generated from line 21, col 5
            write(u'''\t\t\t\t<li data-icon="false">
\t\t\t\t<a href="#" onclick="dlg(\'''')
            _v = VFFSL(SL,"quote",False)(VFFSL(SL,"movie.serviceref",True)) # u'$quote($movie.serviceref)' on line 23, col 31
            if _v is not None: write(_filter(_v, rawExpr=u'$quote($movie.serviceref)')) # from line 23, col 31.
            write(u"""', '""")
            _v = VFFSL(SL,"quote",False)(VFFSL(SL,"movie.filename",True)) # u'$quote($movie.filename)' on line 23, col 60
            if _v is not None: write(_filter(_v, rawExpr=u'$quote($movie.filename)')) # from line 23, col 60.
            write(u'''\');return false;" style="padding: 3px;">
''')
            if VFFSL(SL,"movie.eventname",True) != "": # generated from line 24, col 5
                write(u'''\t\t\t\t<h3>''')
                _v = VFFSL(SL,"movie.eventname",True) # u'$movie.eventname' on line 25, col 9
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.eventname')) # from line 25, col 9.
                write(u'''</h3>
''')
            else: # generated from line 26, col 5
                write(u'''\t\t\t\t<h3>''')
                _v = VFFSL(SL,"movie.filename",True) # u'$movie.filename' on line 27, col 9
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.filename')) # from line 27, col 9.
                write(u'''</h3>
''')
            write(u'''\t\t\t\t<p>...</p>
\t\t\t\t</a>
\t\t\t\t</li>
''')
        write(u'''\t\t\t</ul>
\t\t</div>
\t\t<div id="footer">
\t\t\t<p>OpenWebif Mobile</p>
\t\t\t<a onclick="document.location.href=\'/index?mode=fullpage\';return false;" href="#">''')
        _v = VFFSL(SL,"tstrings",True)['show_full_openwebif'] # u"$tstrings['show_full_openwebif']" on line 37, col 86
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['show_full_openwebif']")) # from line 37, col 86.
        write(u'''</a>
\t\t</div>

\t<div data-role="popup" id="stream" data-theme="b">
\t\t<div data-role="content" data-theme="b">
\t\t\t<span class="title">Stream</span>
\t\t\t<a href="#home" onclick="playRecording();" data-role="button" data-theme="a">''')
        _v = VFFSL(SL,"tstrings",True)['playback'] # u"$tstrings['playback']" on line 43, col 81
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['playback']")) # from line 43, col 81.
        write(u'''</a>
\t\t\t<a href="#home" onclick="jumper(\'etc\');" data-role="button" data-theme="a">''')
        _v = VFFSL(SL,"tstrings",True)['stream'] # u"$tstrings['stream']" on line 44, col 79
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['stream']")) # from line 44, col 79.
        write(u'''</a>
''')
        if VFFSL(SL,"transcoding",True): # generated from line 45, col 4
            write(u'''\t\t\t<a href="#home" onclick="jumper(\'phone\');" data-role="button" data-theme="a">''')
            _v = VFFSL(SL,"tstrings",True)['stream'] # u"$tstrings['stream']" on line 46, col 81
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['stream']")) # from line 46, col 81.
            write(u''' (''')
            _v = VFFSL(SL,"tstrings",True)['transcoded'] # u"$tstrings['transcoded']" on line 46, col 102
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['transcoded']")) # from line 46, col 102.
            write(u''')</a>
''')
        write(u'''\t\t\t<a href="#home" data-role="button" data-theme="d" data-rel="back">Cancel</a>
\t\t</div>
\t</div>
\t
\t<form name="portForm" action="/web/ts.m3u" method="GET" target="_blank">
\t\t<input type="hidden" name="file">
\t\t<input type="hidden" name="device">
\t</form>
<script>
$(document).ready(function(){
\t$("#stream").popup();
});
var sRef=\'\';
var file=\'\';
function playRecording() {
\tvar sr = sRef.replace(/-/g,\'%2D\').replace(/_/g,\'%5F\').replace(/\\//g,\'%2F\');
\t$.ajax(\'/api/zap?sRef=\' + sref);
}
function jumper(mode) {
\tdocument.portForm.file.value = file;
\tdocument.portForm.name.value = sname;
\tdocument.portForm.device.value = mode;
\tdocument.portForm.submit();
}
function dlg(a,b)
{
\tsref = a;
\tfile = b;
\t$("#stream").popup("open"); 
}
</script>
</div>
</body>
</html>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        
    ##################################################
    ## CHEETAH GENERATED ATTRIBUTES


    _CHEETAH__instanceInitialized = False

    _CHEETAH_version = __CHEETAH_version__

    _CHEETAH_versionTuple = __CHEETAH_versionTuple__

    _CHEETAH_genTime = __CHEETAH_genTime__

    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__

    _CHEETAH_src = __CHEETAH_src__

    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__

    _mainCheetahMethod_for_movies= 'respond'

## END CLASS DEFINITION

if not hasattr(movies, '_initCheetahAttributes'):
    templateAPIClass = getattr(movies, '_CHEETAH_templateClass', Template)
    templateAPIClass._addCheetahPlumbingCodeToClass(movies)


# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/

##################################################
## if run from command line:
if __name__ == '__main__':
    from Cheetah.TemplateCmdLineIface import CmdLineIface
    CmdLineIface(templateObj=movies()).run()


