#!/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 time import localtime, strftime
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__ = 1644596120.776262
__CHEETAH_genTimestamp__ = 'Fri Feb 11 16:15:20 2022'
__CHEETAH_src__ = '/home/nonsolosat/openpli-dreambox-oe-core/build/tmp/work/dm520-oe-linux/enigma2-plugin-extensions-openwebif/gitAUTOINC+81b15e17ab-r0/git/plugin/controllers/views/ajax/movies.tmpl'
__CHEETAH_srcLastModified__ = 'Fri Feb 11 15:59:45 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'''<div id="content_main" class="ui-widget-content" style="min-height: 500px;">
\t<div id="tvcontentmain">
\t\t<div id="toolbar-header" class="ui-widget-header">
\t\t<div style=display:inline-block;float:left;>
\t\t\t<select id="moviesort">
''')
        count = 0
        da = VFFSL(SL,"tstrings",True)['date']
        na = VFFSL(SL,"tstrings",True)['name']
        sortnames = [VFFSL(SL,"na",True),VFFSL(SL,"na",True),VFFSL(SL,"da",True),VFFSL(SL,"da",True)]
        sorttypes = ['name','named','date','dated']
        sortimg = ['fa-sort-alpha-asc','fa-sort-alpha-desc','fa-sort-numeric-asc','fa-sort-numeric-desc']
        for title in VFFSL(SL,"sortnames",True): # generated from line 15, col 4
            write(u'''\t\t\t\t<option value="''')
            _v = VFFSL(SL,"sorttypes",True)[VFFSL(SL,"count",True)] # u'$sorttypes[$count]' on line 16, col 20
            if _v is not None: write(_filter(_v, rawExpr=u'$sorttypes[$count]')) # from line 16, col 20.
            write(u'''"
''')
            if VFFSL(SL,"sorttypes",True)[VFFSL(SL,"count",True)] == VFFSL(SL,"sort",True): # generated from line 17, col 5
                write(u'''\t\t\t\t\tselected="selected"
''')
            write(u'''\t\t\t\t data-class="''')
            _v = VFFSL(SL,"sortimg",True)[VFFSL(SL,"count",True)] # u'$sortimg[$count]' on line 20, col 18
            if _v is not None: write(_filter(_v, rawExpr=u'$sortimg[$count]')) # from line 20, col 18.
            write(u'''">''')
            _v = VFFSL(SL,"title",True) # u'$title' on line 20, col 36
            if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 20, col 36.
            write(u'''</option>
''')
            count += 1
        write(u'''\t\t</select>
\t\t</div>
\t\t<span id="toolbar">
''')
        path = ''
        write(u'''\t\t<span id="moviebuttons">
\t\t\t<!-- <button onclick="load_maincontent_spin(\'ajax/movies?dirname=/\'); return false">''')
        _v = VFFSL(SL,"tstrings",True)['Root'] # u"$tstrings['Root']" on line 28, col 88
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['Root']")) # from line 28, col 88.
        write(u'''</button>-->
''')
        for dir in VFN(VFFSL(SL,"directory",True)[0:-1],"split",False)("/")[1:-1]: # generated from line 29, col 4
            path += '/' + VFFSL(SL,"dir",True)
            write(u'''\t\t\t\t<button onclick="load_maincontent_spin(\'ajax/movies?dirname=\'+escape(\'''')
            _v = VFFSL(SL,"path",True) # u'$path' on line 31, col 75
            if _v is not None: write(_filter(_v, rawExpr=u'$path')) # from line 31, col 75.
            write(u'''\'));">''')
            _v = VFFSL(SL,"dir",True) # u'$dir' on line 31, col 86
            if _v is not None: write(_filter(_v, rawExpr=u'$dir')) # from line 31, col 86.
            write(u'''</button>
''')
        if VFFSL(SL,"directory",True) != '/': # generated from line 33, col 4
            write(u'''\t\t\t\t<button class="ui-state-active"><span style="font-weight: bold;">
''')
            _v = VFN(VFFSL(SL,"directory",True)[0:-1],"split",False)("/")[-1]
            if _v is not None: write(_filter(_v))
            write(u'''\t\t\t\t</span></button>
''')
        write(u'''\t\t</span>

''')
        if VFFSL(SL,"len",False)(VFFSL(SL,"bookmarks",True)): # generated from line 40, col 3
            write(u'''\t\t\t<select id="directory">
\t\t\t<option>Subdirs:</option>
''')
            for bookmark in VFFSL(SL,"bookmarks",True): # generated from line 43, col 4
                write(u'''\t\t\t\t<option value="''')
                _v = VFFSL(SL,"directory",True) # u'$directory' on line 44, col 20
                if _v is not None: write(_filter(_v, rawExpr=u'$directory')) # from line 44, col 20.
                _v = VFFSL(SL,"bookmark",True) # u'$bookmark' on line 44, col 30
                if _v is not None: write(_filter(_v, rawExpr=u'$bookmark')) # from line 44, col 30.
                write(u'''">''')
                _v = VFFSL(SL,"bookmark",True) # u'$bookmark' on line 44, col 41
                if _v is not None: write(_filter(_v, rawExpr=u'$bookmark')) # from line 44, col 41.
                write(u'''</option>
''')
            write(u'''\t\t\t</select>
''')
        write(u'''\t\t</span>
\t\t</div>
\t\t<div id="movies">
''')
        count = 0
        for movie in VFFSL(SL,"movies",True): # generated from line 52, col 3
            mname = VFN(VFFSL(SL,"movie.eventname",True),"replace",False)("\"", r"'")
            write(u'''\t\t\t<div class="tm_row ui-widget-content ui-state-default" id="''')
            _v = VFFSL(SL,"count",True) # u'$count' on line 54, col 63
            if _v is not None: write(_filter(_v, rawExpr=u'$count')) # from line 54, col 63.
            write(u'''" data-title="''')
            _v = VFFSL(SL,"mname",True) # u'$mname' on line 54, col 83
            if _v is not None: write(_filter(_v, rawExpr=u'$mname')) # from line 54, col 83.
            write(u'''" data-start="''')
            _v = VFFSL(SL,"movie.recordingtime",True) # u'$movie.recordingtime' on line 54, col 103
            if _v is not None: write(_filter(_v, rawExpr=u'$movie.recordingtime')) # from line 54, col 103.
            write(u'''">
\t\t\t\t<div class="m_buttons tm_buttons">
\t\t\t\t\t\t<div>
\t\t\t\t\t\t<a href=\'#\' onclick="playRecording(\'''')
            _v = VFFSL(SL,"quote",False)(VFFSL(SL,"movie.serviceref",True)) # u'$quote($movie.serviceref)' on line 57, col 43
            if _v is not None: write(_filter(_v, rawExpr=u'$quote($movie.serviceref)')) # from line 57, col 43.
            write(u'''\');" title="''')
            _v = VFFSL(SL,"tstrings",True)['playback'] # u"$tstrings['playback']" on line 57, col 80
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['playback']")) # from line 57, col 80.
            write(u'''"><div><i class="fa fa-play"></i></div></a>
''')
            if VFFSL(SL,"transcoding",True): # generated from line 58, col 7
                write(u'''\t\t\t\t\t\t<a href="#" onclick="jumper80(\'''')
                _v = VFFSL(SL,"quote",False)(VFFSL(SL,"movie.filename",True)) # u'$quote($movie.filename)' on line 59, col 38
                if _v is not None: write(_filter(_v, rawExpr=u'$quote($movie.filename)')) # from line 59, col 38.
                write(u'''\');" title="''')
                _v = VFFSL(SL,"tstrings",True)['stream'] # u"$tstrings['stream']" on line 59, col 73
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['stream']")) # from line 59, col 73.
                write(u''': ''')
                _v = VFFSL(SL,"mname",True) # u'$mname' on line 59, col 94
                if _v is not None: write(_filter(_v, rawExpr=u'$mname')) # from line 59, col 94.
                write(u'''"><div><i class="fa fa-desktop"></i></div></a>
\t\t\t\t\t\t<a href="#" onclick="jumper8003(\'''')
                _v = VFFSL(SL,"quote",False)(VFFSL(SL,"movie.filename",True)) # u'$quote($movie.filename)' on line 60, col 40
                if _v is not None: write(_filter(_v, rawExpr=u'$quote($movie.filename)')) # from line 60, col 40.
                write(u'''\');" title="''')
                _v = VFFSL(SL,"tstrings",True)['stream'] # u"$tstrings['stream']" on line 60, col 75
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['stream']")) # from line 60, col 75.
                write(u''' (''')
                _v = VFFSL(SL,"tstrings",True)['transcoded'] # u"$tstrings['transcoded']" on line 60, col 96
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['transcoded']")) # from line 60, col 96.
                write(u'''): ''')
                _v = VFFSL(SL,"mname",True) # u'$mname' on line 60, col 122
                if _v is not None: write(_filter(_v, rawExpr=u'$mname')) # from line 60, col 122.
                write(u'''"><div><i class="fa fa-mobile"></i></div></a>
''')
            else: # generated from line 61, col 7
                write(u'''\t\t\t\t\t\t<a target="_blank" href=\'web/ts.m3u?file=''')
                _v = VFFSL(SL,"quote",False)(VFFSL(SL,"movie.filename",True)) # u'$quote($movie.filename)' on line 62, col 48
                if _v is not None: write(_filter(_v, rawExpr=u'$quote($movie.filename)')) # from line 62, col 48.
                write(u'''\' title="''')
                _v = VFFSL(SL,"tstrings",True)['stream'] # u"$tstrings['stream']" on line 62, col 80
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['stream']")) # from line 62, col 80.
                write(u''' ''')
                _v = VFFSL(SL,"mname",True) # u'$mname' on line 62, col 100
                if _v is not None: write(_filter(_v, rawExpr=u'$mname')) # from line 62, col 100.
                write(u'''"><div><i class="fa fa-desktop"></i></div></a>
''')
            write(u'''\t\t\t\t\t\t<br><br>
''')
            w = VFFSL(SL,"movie.lastseen",True)
            if VFFSL(SL,"w",True) > 0: # generated from line 66, col 7
                w = VFFSL(SL,"w",True) * 70 / 100
                size = str(VFFSL(SL,"w",True)) + '%'
                write(u'''\t\t\t\t\t\t\t<div class="ui-progressbar ui-corner-all ui-widget ui-widget-content">
\t\t\t\t\t\t\t\t<div class="ui-progressbar-value ui-corner-left ui-widget-header" style="width: ''')
                _v = VFFSL(SL,"size",True) # u'$size' on line 70, col 89
                if _v is not None: write(_filter(_v, rawExpr=u'$size')) # from line 70, col 89.
                write(u''';"></div>
\t\t\t\t\t\t\t</div>
''')
            write(u'''\t\t\t\t\t\t<br>
''')
            eventname_escaped = VFN(VFN(VFFSL(SL,"movie.eventname",True),"replace",False)("'", r"\'"),"replace",False)('"', r"\'")
            write(u"""\t\t\t\t\t\t<a href='/file?action=download&file=""")
            _v = VFFSL(SL,"quote",False)(VFFSL(SL,"movie.filename",True)) # u'$quote($movie.filename)' on line 75, col 43
            if _v is not None: write(_filter(_v, rawExpr=u'$quote($movie.filename)')) # from line 75, col 43.
            write(u'''\' title="''')
            _v = VFFSL(SL,"tstrings",True)['download'] # u"$tstrings['download']" on line 75, col 75
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['download']")) # from line 75, col 75.
            write(u''' ''')
            _v = VFFSL(SL,"mname",True) # u'$mname' on line 75, col 97
            if _v is not None: write(_filter(_v, rawExpr=u'$mname')) # from line 75, col 97.
            write(u'''"><div><i class="fa fa-save"></i></div></a>
\t\t\t\t\t\t<a href=\'#\' onclick="editmovie(\'''')
            _v = VFFSL(SL,"quote",False)(VFFSL(SL,"movie.serviceref",True)) # u'$quote($movie.serviceref)' on line 76, col 39
            if _v is not None: write(_filter(_v, rawExpr=u'$quote($movie.serviceref)')) # from line 76, col 39.
            write(u"""','""")
            _v = VFFSL(SL,"eventname_escaped",True) # u'$eventname_escaped' on line 76, col 67
            if _v is not None: write(_filter(_v, rawExpr=u'$eventname_escaped')) # from line 76, col 67.
            write(u"""', escape('""")
            _v = VFFSL(SL,"directory",True) # u'$directory' on line 76, col 96
            if _v is not None: write(_filter(_v, rawExpr=u'$directory')) # from line 76, col 96.
            write(u'''\').replace(\'+\',\'%2B\'));" title="''')
            _v = VFFSL(SL,"tstrings",True)['edit_recording'] # u"$tstrings['edit_recording']" on line 76, col 138
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['edit_recording']")) # from line 76, col 138.
            write(u'''"><div><i class="fa fa-edit"></i></div></a>
\t\t\t\t\t\t<a href=\'#\' onclick="deleteMovie(\'''')
            _v = VFFSL(SL,"quote",False)(VFFSL(SL,"movie.serviceref",True)) # u'$quote($movie.serviceref)' on line 77, col 41
            if _v is not None: write(_filter(_v, rawExpr=u'$quote($movie.serviceref)')) # from line 77, col 41.
            write(u"""', '""")
            _v = VFFSL(SL,"count",True) # u'$count' on line 77, col 70
            if _v is not None: write(_filter(_v, rawExpr=u'$count')) # from line 77, col 70.
            write(u"""', '""")
            _v = VFFSL(SL,"eventname_escaped",True) # u'$eventname_escaped' on line 77, col 80
            if _v is not None: write(_filter(_v, rawExpr=u'$eventname_escaped')) # from line 77, col 80.
            write(u'''\'); return false;" title="''')
            _v = VFFSL(SL,"tstrings",True)['delete_recording'] # u"$tstrings['delete_recording']" on line 77, col 124
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['delete_recording']")) # from line 77, col 124.
            write(u'''"><div><i class="fa fa-trash-o"></i></div></a>

\t\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="tm_text">
''')
            if VFFSL(SL,"movie.eventname",True) != "": # generated from line 82, col 6
                write(u'''\t\t\t\t\t\t<div>
\t\t\t\t\t\t\t<span class="tm_title">''')
                _v = VFFSL(SL,"movie.eventname",True) # u'$movie.eventname' on line 84, col 31
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.eventname')) # from line 84, col 31.
                write(u'''</span><br /> ''')
                _v = VFFSL(SL,"movie.servicename",True) # u'$movie.servicename' on line 84, col 61
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.servicename')) # from line 84, col 61.
                write(u''' / ''')
                _v = VFFSL(SL,"movie.begintime",True) # u'$movie.begintime' on line 84, col 82
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.begintime')) # from line 84, col 82.
                write(u'''<br /> ''')
                _v = VFFSL(SL,"movie.length",True) # u'$movie.length' on line 84, col 105
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.length')) # from line 84, col 105.
                write(u''' min. / ''')
                _v = VFFSL(SL,"movie.filesize_readable",True) # u'$movie.filesize_readable' on line 84, col 126
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.filesize_readable')) # from line 84, col 126.
                write(u'''
\t\t\t\t\t\t</div>
\t\t\t\t\t\t<div>
\t\t\t\t\t\t\t<span class="tm_desc" style="font-weight: bold;">''')
                _v = VFFSL(SL,"movie.description",True) # u'$movie.description' on line 87, col 57
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.description')) # from line 87, col 57.
                write(u'''</span>
\t\t\t\t\t\t</div>
\t\t\t\t\t\t<div>
\t\t\t\t\t\t\t<span class="tm_desc">''')
                _v = VFFSL(SL,"movie.descriptionExtended",True) # u'$movie.descriptionExtended' on line 90, col 30
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.descriptionExtended')) # from line 90, col 30.
                write(u'''</span>
\t\t\t\t\t\t</div>
''')
            else: # generated from line 92, col 6
                write(u'''\t\t\t\t\t\t<div>
\t\t\t\t\t\t\t<span class="tm_title">''')
                _v = VFFSL(SL,"movie.filename",True) # u'$movie.filename' on line 94, col 31
                if _v is not None: write(_filter(_v, rawExpr=u'$movie.filename')) # from line 94, col 31.
                write(u'''</span>
\t\t\t\t\t\t</div>
''')
            write(u'''\t\t\t\t</div>
''')
            count += 1
            write(u'''\t\t\t</div>
''')
        write(u'''\t\t</div>
\t</div>
</div>

<script type="text/javascript">

$( function() {
\t$(\'#moviebuttons\').buttonset();
\tMLHelper.Load(\'''')
        _v = VFFSL(SL,"sort",True) # u'$sort' on line 109, col 17
        if _v is not None: write(_filter(_v, rawExpr=u'$sort')) # from line 109, col 17.
        write(u"""');
\tsetTMHover();
});

""")
        if VFFSL(SL,"len",False)(VFFSL(SL,"bookmarks",True)): # generated from line 113, col 1
            write(u'''$("#directory").selectmenu({change: function(event, ui) {
\tload_maincontent_spin(\'ajax/movies?dirname=\'+escape(ui.item.value).replace(\'+\',\'%2B\'))
}
});

''')
        write(u'''
</script>
''')
        
        ########################################
        ## 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()


