Skip to content

Commit

Permalink
Sync VTi Openwebif
Browse files Browse the repository at this point in the history
  • Loading branch information
jbleyel committed Apr 12, 2020
1 parent 201805e commit a83f6f0
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 15 deletions.
21 changes: 20 additions & 1 deletion plugin/controllers/ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from models.services import getBouquets, getChannels, getSatellites, getProviders, getEventDesc, getChannelEpg, getSearchEpg, getCurrentFullInfo, getMultiEpg, getEvent
from models.info import getInfo
from models.movies import getMovieList
from models.movies import getMovieList, getMovieSearchList
from models.timers import getTimers
from models.config import getConfigs, getConfigsSections
from models.stream import GetSession
Expand Down Expand Up @@ -203,6 +203,25 @@ def P_movies(self, request):
movies['sort'] = sorttype
return movies

def P_moviesearch(self, request):
movies = getMovieSearchList(request.args)
movies['transcoding'] = TRANSCODING

sorttype = config.OpenWebif.webcache.moviesort.value
unsort = movies['movies']

if sorttype == 'name':
movies['movies'] = sorted(unsort, key=lambda k: k['eventname'])
elif sorttype == 'named':
movies['movies'] = sorted(unsort, key=lambda k: k['eventname'],reverse=True)
elif sorttype == 'date':
movies['movies'] = sorted(unsort, key=lambda k: k['recordingtime'])
elif sorttype == 'dated':
movies['movies'] = sorted(unsort, key=lambda k: k['recordingtime'],reverse=True)

movies['sort'] = sorttype
return movies

def P_timers(self, request):

timers = getTimers(self.session)
Expand Down
123 changes: 123 additions & 0 deletions plugin/controllers/models/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
from ..utilities import _moviePlayState
pass

try:
from Components.DataBaseAPI import moviedb
except ImportError:
# from ..utilities import _moviePlayState
pass


MOVIETAGFILE = "/etc/enigma2/movietags"
TRASHDIRNAME = "movie_trash"

Expand Down Expand Up @@ -235,6 +242,122 @@ def getMovieList(rargs=None, locations=None):
"locations": locations
}

def getMovieSearchList(rargs=None, locations=None):
movieliste = []
tag = None
directory = None
fields = None
short = None
extended = None
searchstr = None

if rargs and "find" in rargs.keys():
searchstr = rargs["find"][0]

if rargs and "short" in rargs.keys():
short = rargs["short"][0]

if rargs and "extended" in rargs.keys():
extended = rargs["extended"][0]

s = { 'title' : str(searchstr) }
if short is not None:
s['shortDesc'] = str(searchstr)
if extended is not None:
s['extDesc'] = str(searchstr)

movielist = MovieList(None)
vdir_list = []
for x in moviedb.searchContent(s,'ref', query_type = "OR", exactmatch = False):
vdir_list.append(eServiceReference(x[0]))
root = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + "/")
movielist.load(root, None)
movielist.reload(root = None, vdir = 5, vdir_list = vdir_list)

for (serviceref, info, begin, unknown) in movielist.list:
if serviceref.flags & eServiceReference.mustDescent:
continue

length_minutes = 0
txtdesc = ""
filename = '/'.join(serviceref.toString().split("/")[1:])
filename = '/' + filename
name, ext = os.path.splitext(filename)

sourceRef = ServiceReference(
info.getInfoString(
serviceref, iServiceInformation.sServiceref))
rtime = info.getInfo(serviceref, iServiceInformation.sTimeCreate)

movie = {
'filename': filename,
'filename_stripped': filename.split("/")[-1],
'serviceref': serviceref.toString(),
'length': "?:??",
'lastseen': 0,
'filesize_readable': '',
'recordingtime': rtime,
'begintime': 'undefined',
'eventname': ServiceReference(serviceref).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''),
'servicename': sourceRef.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''),
'tags': info.getInfoString(serviceref, iServiceInformation.sTags),
'fullname': serviceref.toString(),
}

if rtime > 0:
fuzzy_rtime = FuzzyTime(rtime)
movie['begintime'] = fuzzy_rtime[0] + ", " + fuzzy_rtime[1]

try:
length_minutes = info.getLength(serviceref)
except:
pass

if length_minutes:
movie['length'] = "%d:%02d" % (length_minutes / 60, length_minutes % 60)
if fields is None or 'pos' in fields:
movie['lastseen'] = getPosition(filename + '.cuts', length_minutes)

if fields is None or 'desc' in fields:
txtfile = name + '.txt'
if ext.lower() != '.ts' and os.path.isfile(txtfile):
with open(txtfile, "rb") as handle:
txtdesc = ''.join(handle.readlines())

event = info.getEvent(serviceref)
extended_description = event and event.getExtendedDescription() or ""
if extended_description == '' and txtdesc != '':
extended_description = txtdesc
movie['descriptionExtended'] = unicode(extended_description,'utf_8', errors='ignore').encode('utf_8', 'ignore')

desc = info.getInfoString(serviceref, iServiceInformation.sDescription)
movie['description'] = unicode(desc,'utf_8', errors='ignore').encode('utf_8', 'ignore')

if fields is None or 'size' in fields:
size = 0
sz = ''

try:
size = os.stat(filename).st_size
if size > 1073741824:
sz = "%.2f %s" % ((size / 1073741824.),_("GB"))
elif size > 1048576:
sz = "%.2f %s" % ((size / 1048576.),_("MB"))
elif size > 1024:
sz = "%.2f %s" % ((size / 1024.),_("kB"))
except:
pass

movie['filesize'] = size
movie['filesize_readable'] = sz

movieliste.append(movie)

return {
"movies": movieliste,
"locations": []
}


def getAllMovies():
locations = config.movielist.videodirs.value[:] or []
Expand Down
42 changes: 38 additions & 4 deletions plugin/controllers/models/timers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def getTimers(session):
rt = session.nav.RecordTimer
timers = []
for timer in rt.timer_list + rt.processed_timers:

if hasattr(timer, "wakeup_t"):
energytimer = timer.wakeup_t or timer.standby_t or timer.shutdown_t or timer.fnc_t != "off" or 0
if energytimer:
continue

descriptionextended = "N/A"
filename = None
nextactivation = None
Expand All @@ -50,6 +56,16 @@ def getTimers(session):
if timer.justplay:
justplay = 1

if hasattr(timer, "allow_duplicate"):
allow_duplicate = timer.allow_duplicate and 1 or 0
else:
allow_duplicate = 1

if hasattr(timer, "autoadjust"):
autoadjust = timer.autoadjust and 1 or 0
else:
autoadjust = config.recording.adjust_time_to_event.value and 1 or 0

if timer.dirname:
dirname = timer.dirname
else:
Expand Down Expand Up @@ -141,6 +157,8 @@ def getTimers(session):
"always_zap": always_zap,
"pipzap": pipzap,
"isAutoTimer": isAutoTimer
"allow_duplicate":allow_duplicate,
"autoadjust":autoadjust,
})

return {
Expand All @@ -149,7 +167,7 @@ def getTimers(session):
}


def addTimer(session, serviceref, begin, end, name, description, disabled, justplay, afterevent, dirname, tags, repeated, vpsinfo=None, logentries=None, eit=0, always_zap=-1, pipzap=-1):
def addTimer(session, serviceref, begin, end, name, description, disabled, justplay, afterevent, dirname, tags, repeated, vpsinfo=None, logentries=None, eit=0, always_zap=-1, pipzap=-1, allow_duplicate=1, autoadjust=-1):
rt = session.nav.RecordTimer

if not dirname:
Expand Down Expand Up @@ -205,6 +223,14 @@ def addTimer(session, serviceref, begin, end, name, description, disabled, justp
if hasattr(timer, "always_zap"):
timer.always_zap = always_zap == 1

if hasattr(timer, "autoadjust"):
if autoadjust == -1:
autoadjust = config.recording.adjust_time_to_event.value and 1 or 0
autoadjust = autoadjust

if hasattr(timer, "allow_duplicate"):
allow_duplicate=allow_duplicate

if pipzap != -1:
if hasattr(timer, "pipzap"):
timer.pipzap = pipzap == 1
Expand All @@ -222,7 +248,7 @@ def addTimer(session, serviceref, begin, end, name, description, disabled, justp
}


def addTimerByEventId(session, eventid, serviceref, justplay, dirname, tags, vpsinfo, always_zap, afterevent, pipzap):
def addTimerByEventId(session, eventid, serviceref, justplay, dirname, tags, vpsinfo, always_zap, afterevent, pipzap, allow_duplicate, autoadjust):
event = eEPGCache.getInstance().lookupEventId(eServiceReference(serviceref), eventid)
if event is None:
return {
Expand Down Expand Up @@ -253,14 +279,16 @@ def addTimerByEventId(session, eventid, serviceref, justplay, dirname, tags, vps
None,
eit,
always_zap,
pipzap
pipzap,
allow_duplicate,
autoadjust
)


# NEW editTimer function to prevent delete + add on change
# !!! This new function must be tested !!!!
# TODO: exception handling
def editTimer(session, serviceref, begin, end, name, description, disabled, justplay, afterEvent, dirname, tags, repeated, channelOld, beginOld, endOld, vpsinfo, always_zap, pipzap):
def editTimer(session, serviceref, begin, end, name, description, disabled, justplay, afterEvent, dirname, tags, repeated, channelOld, beginOld, endOld, vpsinfo, always_zap, pipzap, allow_duplicate, autoadjust):
channelOld_str = ':'.join(str(channelOld).split(':')[:11])
rt = session.nav.RecordTimer
for timer in rt.timer_list + rt.processed_timers:
Expand Down Expand Up @@ -294,6 +322,12 @@ def editTimer(session, serviceref, begin, end, name, description, disabled, just
if hasattr(timer, "pipzap"):
timer.pipzap = pipzap == 1

if hasattr(timer, "allow_duplicate"):
timer.allow_duplicate = allow_duplicate

if hasattr(timer, "autoadjust"):
timer.autoadjust = autoadjust

# TODO: multi tuner test
sanity = TimerSanityCheck(rt.timer_list, timer)
conflicts = None
Expand Down
3 changes: 3 additions & 0 deletions plugin/controllers/views/ajax/at.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ input#to,input#from,.text.number {width:60px;}
<option value="partial" selected="selected">$tstrings['at_partial_match']</option>
<option value="exact">$tstrings['at_exact_match']</option>
<option value="description">$tstrings['at_description_match']</option>
<option value="full">$tstrings['at_title_or_description_match']</option>
<option value="shortdesc">$tstrings['at_short_description_match']</option>
<option value="title_shortdesc">$tstrings['at_title_or_short_description_match']</option>
#if $types.has_key('start')
<option value="start">$tstrings['at_start_match']</option>
#end if
Expand Down
31 changes: 30 additions & 1 deletion plugin/controllers/views/responsive/ajax/at.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,35 @@
</div>
</span>
</div>
<div class="row clearfix">
<div class="col-xs-12 col-sm-4">
<div class="row clearfix">
<div class="col-xs-12">
<label style="float:left;">$tstrings['autoadjust']:&nbsp;</label>
<input type="checkbox" class="form-control chk-col-$skinColor" id="autoadjust">
<label for="autoadjust">&nbsp;</label>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div class="row clearfix">
<div class="col-xs-12">
<label style="float:left;">$tstrings['avoidDuplicateMovies']:&nbsp;</label>
<input type="checkbox" class="form-control chk-col-$skinColor" id="avoidDuplicateMovies">
<label for="avoidDuplicateMovies">&nbsp;</label>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div class="row clearfix">
<div class="col-xs-12">
<label style="float:left;">$tstrings['allow_duplicate']:&nbsp;</label>
<input type="checkbox" class="form-control chk-col-$skinColor" id="allow_duplicate">
<label for="allow_duplicate">&nbsp;</label>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-xs-12 col-sm-4">
<div class="row clearfix">
Expand Down Expand Up @@ -813,7 +842,7 @@

<script src="/themes/absb/plugins/jquery-inputmask/jquery.inputmask.bundle.js"></script>
<script src="/js/at-2.8.min.js"></script>
<script src="/themes/absb/js/vti-responsive-at.js"></script>
<script src="/themes/absb/js/vti-responsive-at-2.8.js"></script>
<script type="text/javascript">

#raw
Expand Down
8 changes: 4 additions & 4 deletions plugin/controllers/views/responsive/main.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<li class="osd-toggle" id="responsive_vol_value"><a><div class="dropdown-toggle" id="volumevalue"><b><span class="curvolume"></span></b></div></a></li>
<!-- Call Search -->
<li><a href="javascript:void(0);" class="js-search-epg" data-close="true" title="$tstrings['epgsearch']" ><i class="material-icons">search</i></a></li>
<!--<li><a href="javascript:void(0);" class="js-search-movie" data-close="true" title="$tstrings['moviesearch']"><i class="material-icons">youtube_searched_for</i></a></li> -->
<li><a href="javascript:void(0);" class="js-search-movie" data-close="true" title="$tstrings['moviesearch']"><i class="material-icons">youtube_searched_for</i></a></li>
<!-- #END# Call Search -->
<li class="dropdown" id="responsive_rec_info"></li>
<li class="dropdown" id="responsive_stream_info"></li>
Expand Down Expand Up @@ -558,7 +558,7 @@
<!-- it is not allowed to remove this copyright and link when using the materialize (aka responsive) design for openwebif -->
<div class="legal" id="leftfooter">
<div class="copyright">
Materialize design - <b>Version: </b> 1.0.1</br>&copy; 2017 <a href="https://www.vuplus-support.org" target="_blank">VTi - vuplus-support.org</a>.
Materialize design - <b>Version: </b> 1.2.0</br>&copy; 2017 <a href="https://www.vuplus-support.org" target="_blank">VTi - vuplus-support.org</a>.
</div>
</div>
<!-- END COPYRIGHT -->
Expand Down Expand Up @@ -588,7 +588,7 @@
</div>
</li>
</ul>
<!-- <p>$tstrings['moviesearch']</p>
<p>$tstrings['moviesearch']</p>
<ul class="setting-list">
<li>
<span>$tstrings['inc_shortdesc']</span>
Expand All @@ -603,7 +603,7 @@
</div>
</li>
</ul>
-->

<p>$tstrings['common_settings']</p>
<ul class="setting-list">
<li>
Expand Down
Loading

1 comment on commit a83f6f0

@ims21
Copy link
Contributor

@ims21 ims21 commented on a83f6f0 Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now is OpenWebif as VTI propertis or what ?
This totaly damaged PartnerBox plugin and other web comunnications about timers ...

Please sign in to comment.