Skip to content

Commit

Permalink
0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dream-alpha committed May 31, 2024
1 parent 418cf8a commit 6806778
Show file tree
Hide file tree
Showing 19 changed files with 364 additions and 161 deletions.
2 changes: 1 addition & 1 deletion CONTROL/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Description: TVMagazineCockpit
Maintainer: dream-alpha
Package: enigma2-plugin-extensions-tvmagazinecockpit
Version: 0.8.4
Version: 0.9.0
Architecture: all
Depends: enigma2-plugin-skincomponents-extmultilistselection
2 changes: 1 addition & 1 deletion src/ConfigInit.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self):
default="programm",
choices=[
("main", _("Tv Spielfilm Main")),
("tipps", _("Tv Spielfilm Tips")),
("tips", _("Tv Spielfilm Tips")),
("programm", _("Tv Spielfilm Programm Standard")),
("programmfavo", _("Tv Spielfilm Programm Favourites")),
("programmsky", _("Tv Spielfilm Programm Sky")),
Expand Down
144 changes: 25 additions & 119 deletions src/EventDetails.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding=utf-8

from time import strftime, localtime
from os import remove as os_remove
from twisted.internet.defer import DeferredSemaphore
from Screens.Screen import Screen
Expand All @@ -24,11 +25,16 @@
from MYSimpleSummary import MYSimpleSummary
from .__init__ import _
from .Debug import logger
from .Constants import EVENT_IDX_TITLE, EVENT_IDX_TIME_START, EVENT_IDX_TIME_END, EVENT_IDX_TEXT
from .PictureUtils import getPicon, getVideo, getEventPicUrl


class EventDetails(Screen):
def __init__(self, session, mlist):
def __init__(self, session, index, list_events):
logger.info("...")
self.index = index
self.list_events = list_events
self.list_event = list_events[index]
Screen.__init__(self, session)
self.skinName = "EventDetails"
self["description"] = ScrollLabel()
Expand All @@ -42,8 +48,6 @@ def __init__(self, session, mlist):
"down": self["description"].pageDown
}
)
self.mlist = mlist

self["bigpixmap"] = Pixmap()
self["channelpix"] = Pixmap()
self["daumenpix"] = Pixmap()
Expand All @@ -57,15 +61,15 @@ def __init__(self, session, mlist):
self["channel"] = Label()
self["time"] = Label()
self["headingtext"] = Label()
self["heading"] = Label(_('Loading...'))
self["heading"] = Label()
self["infoicon"] = Label()
self["progress"] = Progress()
self["progresspix"] = Pixmap()
self["progresspro"] = Label()
self["remaining"] = Label()
self["duration"] = Label()
self["trailer"] = Boolean(False)
self["liste"] = MultiListSummary(mlist[:])
self["liste"] = MultiListSummary()

self.filename = ''
self.videourl = ''
Expand All @@ -87,40 +91,18 @@ def makebigpixmap(self, myfile=None):

def createsetup(self):
logger.info("...")
self.deferCanceler()
ds = DeferredSemaphore(tokens=1)
dr = ds.run(MygetPage, url=self.mlist[mindex['urlsendung']], headers=headers_gzip).addCallbacks(self.result_back_details).addErrback(http_failed)
self.deferreds.append(dr)

self.setTitle(self.mlist[mindex['title']])
self["channel"].setText(self.mlist[mindex['channel']])
self["time"].setText(self.mlist[mindex['time']])
self["headingtext"].setText(self.mlist[mindex['tvsearch']])
if self.mlist[mindex['progress']]:
self["progress"].setValue(self.mlist[mindex['progress']])
if self.mlist[mindex['progresspix']]:
self["progresspix"].instance.setPixmap(self.mlist[mindex['progresspix']])
if self.mlist[mindex['progresspro']]:
self["progresspro"].setText(self.mlist[mindex['progresspro']])
if self.mlist[mindex['remaining']]:
self["remaining"].setText(self.mlist[mindex['remaining']])
if self.mlist[mindex['duration']]:
self["duration"].setText(self.mlist[mindex['duration']])
if self.mlist[mindex['channelpix']]:
self["channelpix"].instance.setPixmap(self.mlist[mindex['channelpix']])
if self.mlist[mindex['daumen']]:
self["daumenpix"].instance.setPixmap(self.mlist[mindex['daumen']])
if self.mlist[mindex['trailer']]:
self["trailer"].boolean = True

pixmap = Load_My_Pixmap(plugindir + 'icons/icon_rating_0.png')
if pixmap:
self["anspruch"].instance.setPixmap(pixmap)
self["humor"].instance.setPixmap(pixmap)
self["action"].instance.setPixmap(pixmap)
self["spannung"].instance.setPixmap(pixmap)
self["erotik"].instance.setPixmap(pixmap)
self["community"].instance.setPixmap(pixmap)
logger.debug("list_event: %s", self.list_event)
self.setTitle(self.list_event[EVENT_IDX_TITLE])
self["channel"].setText(self.list_event[EVENT_IDX_TITLE])
self["time"].setText(strftime('%H:%M', localtime(int(self.list_event[EVENT_IDX_TIME_START]))))
self["duration"].setText(str((int(self.list_event[EVENT_IDX_TIME_END]) - int(self.list_event[EVENT_IDX_TIME_START])) / 60))
self["channelpix"].setPixmap(getPicon(self.list_event))
self["description"].setText(self.list_event[EVENT_IDX_TEXT])
self.video_title, self.video_pic, self.video_url = getVideo(self.list_event)
# if self.mlist[mindex['daumen']]:
# self["daumenpix"].instance.setPixmap(self.mlist[mindex['daumen']])
# if self.mlist[mindex['trailer']]:
# self["trailer"].boolean = True

def __finish_decode(self, _picInfo):
logger.info("...")
Expand All @@ -135,83 +117,7 @@ def __finish_decode(self, _picInfo):
if pathExists(self.filename):
os_remove(self.filename)

def result_back_details(self, result):
logger.info("...")
error_message = _("Error during download")
if result:
val = parse_details(result)
if val and len(val) >= dindex['listend']:
if val[dindex['videourl']] and val[dindex['videourl']].endswith(('mp4')):
self.videourl = val[dindex['videourl']]
self["trailer"].boolean = True
if val[dindex['imageurl']] and val[dindex['imageurl']].endswith(('.jpg', '.png', '.svg')):
self.filename = '/tmp/.tvtemp' + val[dindex['imageurl']][-4:]
self.deferCanceler()
ds = DeferredSemaphore(tokens=1)
dr = ds.run(MydownloadPage, url=val[dindex['imageurl']], file=self.filename, headers=_headers_jpeg).addCallback(self.back_resultneu).addErrback(http_failed)
self.deferreds.append(dr)
else:
self.makebigpixmap(plugindir + 'icons/default.png')
currtmp = self["liste"].list
if not self.mlist[mindex['channel']] and val[dindex['channel']]:
self["channel"].setText(val[dindex['channel']])
currtmp[mindex['channel']] = val[dindex['channel']]
if not self.mlist[mindex['id']] and val[dindex['id']]:
currtmp[mindex['id']] = val[dindex['id']]
if not self.mlist[mindex['time']] and val[dindex['time']]:
self["time"].setText(val[dindex['time']])
currtmp[mindex['time']] = val[dindex['time']]
if not self.mlist[mindex['daumen']] and val[dindex['daumen']]:
self["daumenpix"].instance.setPixmap(val[dindex['daumen']])
currtmp[mindex['daumen']] = val[dindex['daumen']]
if val[dindex['heading']]:
self["headingtext"].setText(val[dindex['heading']])
if val[dindex['headingtext']]:
self["heading"].setText(val[dindex['headingtext']])
currtmp[mindex['description']] = val[dindex['headingtext']]

if val[dindex['tipp']] or val[dindex['neu']]:
self["infoicon"].setText(val[dindex['tipp']] + ' ' + val[dindex['neu']])
currtmp[mindex['tipp']] = val[dindex['tipp']]
currtmp[mindex['neu']] = val[dindex['neu']]

self["liste"].setList(currtmp)

if val[dindex['anspruch']]:
self["anspruch"].instance.setPixmap(val[dindex['anspruch']])
if val[dindex['humor']]:
self["humor"].instance.setPixmap(val[dindex['humor']])
if val[dindex['action']]:
self["action"].instance.setPixmap(val[dindex['action']])
if val[dindex['spannung']]:
self["spannung"].instance.setPixmap(val[dindex['spannung']])
if val[dindex['erotik']]:
self["erotik"].instance.setPixmap(val[dindex['erotik']])
if val[dindex['community']]:
self["community"].instance.setPixmap(val[dindex['community']])
textstr = ''
if val[dindex['infotext']]:
textstr += val[dindex['infotext']] + '\n\n'
if val[dindex['deheadline']]:
textstr += val[dindex['deheadline']] + '\n\n'
if val[dindex['description']]:
textstr += val[dindex['description']] + '\n'
if val[dindex['strong']]:
textstr += val[dindex['strong']] + '\n'
if textstr == '':
textstr += self.mlist[mindex['tvsearch']] + '\n\n'
if val[dindex['castlist']]:
textstr += val[dindex['castlist']] + '\n'
if val[dindex['actorslist']]:
textstr += val[dindex['actorslist']] + '\n'
if textstr:
self["description"].setText(textstr)
else:
self["heading"].setText(error_message)
else:
self["heading"].setText(error_message)

def back_resultneu(self, result):
def back_result(self, result):
logger.info("...")
if result is None:
self.makebigpixmap(self.filename)
Expand Down Expand Up @@ -242,9 +148,9 @@ def deferCanceler(self):

def key_ok(self):
logger.info("...")
if self.videourl and self.videourl.endswith(('mp4')):
sref = eServiceReference(eServiceReference.idGST, 0, self.videourl)
sref.setName(self.mlist[mindex['title']])
if self.video_url and self.video_url.endswith(('mp4')):
sref = eServiceReference(eServiceReference.idGST, 0, self.video_url)
sref.setName(self.video_title)
self.session.open(StreamPlayer, sref)
else:
self.close()
Expand Down
57 changes: 57 additions & 0 deletions src/PictureUtils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# !/usr/bin/python
# coding=utf-8
#
# Copyright (C) 2018-2024 by dream-alpha
#
# In case of reuse of this source code please do not remove this copyright.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For more information on the GNU General Public License see:
# <http://www.gnu.org/licenses/>.


from .tools import Load_My_Pixmap
from .Constants import EVENT_IDX_BROADCASTER_ID, EVENT_IDX_IMAGES, EVENT_IDX_VIDEOS
from .ConfigInit import plugindir
from .Debug import logger


def getPicon(list_event):
picon = str(list_event[EVENT_IDX_BROADCASTER_ID]) + ".png"
picon_file = '%slogos/%s' % (plugindir, picon)
logger.debug("picon_file: %s", picon_file)
pixmap_ptr = Load_My_Pixmap(picon_file)
return pixmap_ptr


def getVideo(list_event):
videos = list_event[EVENT_IDX_VIDEOS]
logger.debug("videos: %s", videos)
title = video_url = still_image_url = ""
if len(videos) > 0:
video_list = videos[0].get("video", "")
video = video_list[0]
title = video.get("title", "")
still_image_url = video.get("stillImage", "")
video_url = video.get("url", "")
return title, still_image_url, video_url


def getEventPicUrl(list_event):
images = list_event[EVENT_IDX_IMAGES]
logger.debug("images: %s", images)
url = ""
if len(images) > 0:
image = images[0]
url = image.get("size1", "")
logger.debug("programmpix url: %s", url)
return url
11 changes: 6 additions & 5 deletions src/ProgramColumns.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def showMenuCallback(self, page_index=None):

def key_tipps(self):
logger.info("...")
self.close("tipps")
self.close("tips")

def key_programm(self):
logger.info("...")
Expand Down Expand Up @@ -297,17 +297,18 @@ def key_back(self):

def key_ok(self):
logger.info("...")
curr = self["liste%s" % self.listindex].l.getCurrentSelection()
logger.debug("curr: %s", curr)
self.session.open(EventDetails, self.list_events[curr[listprogresindex["id"]]])
current_selection = self["liste%s" % self.listindex].l.getCurrentSelection()
current_index = self["liste%s" % self.listindex].getCurrentIndex()
logger.debug("current_selection: %s", current_selection)
self.session.open(EventDetails, current_index, self.list_events[current_selection[listprogresindex["id"]]])

def key_red(self):
logger.info("...")
self.close("main")

def key_green(self):
logger.info("...")
self.close("tipps")
self.close("tips")

def key_yellow(self):
logger.info("...")
Expand Down
30 changes: 6 additions & 24 deletions src/tvspielfilmtipps.py → src/ProgramTips.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
from time import strftime, localtime, time as nowtime
from twisted.internet.defer import DeferredSemaphore
from Screens.Screen import Screen
from enigma import eSlider
from Downloader import _headers_jpeg, headers_gzip, MygetPage, MydownloadPage, http_failed
from tools import Piconchannelname, mastxval_list, listmainindex as mindex
from _tvdict import _channelreference, _pixmap_cache, listtippsindex
from tvconfig import read_ServiceReference
from Tools.LoadPixmap import LoadPixmap
from Components.ActionMap import ActionMap
from Components.HTMLComponent import HTMLComponent
from Components.GUIComponent import GUIComponent
from Components.Label import Label
from Components.Sources.StaticText import StaticText
from .EasyMenu import EasyMenu
Expand All @@ -24,25 +21,10 @@
from .__init__ import _
from .Debug import logger
from .XMLTipps import XMLTipps
from .Slider import Slider


class Slider(HTMLComponent, GUIComponent):
def __init__(self, min_value=0, max_value=6):
logger.info("...")
GUIComponent.__init__(self)
self.min = min_value
self.max = max_value

GUI_WIDGET = eSlider

def postWidgetCreate(self, instance):
logger.info("...")
instance.setRange(self.min, self.max)
instance.setOrientation(eSlider.orVertical, False, True)
instance.setBorderWidth(0)


class TvSpielfilmTipps(Screen, EasyMenu):
class ProgramTips(Screen, EasyMenu):
def __init__(self, session):
logger.info("...")
Screen.__init__(self, session)
Expand Down Expand Up @@ -82,7 +64,7 @@ def __init__(self, session):
mytime = mytime - 86400

self.timelist = []
for _tre in range(0, 15):
for _day in range(0, 15):
self.timelist.append([strftime("%A, %d. %b %y", localtime(mytime)), strftime("&date=%Y-%m-%d", localtime(mytime))])
mytime = mytime + 86400

Expand Down Expand Up @@ -136,7 +118,7 @@ def download_page(self):

def updateTitle(self):
logger.info("...")
self.setTitle('Tv Spielfilm Tv Tipps')
self.setTitle('TV Spielfilm - Tips')

def result_back(self, result):
logger.info("result: %s", result)
Expand All @@ -160,7 +142,7 @@ def result_back(self, result):

def result_pixmax(self, _result, args):
logger.info("...")
if self.has_key(args['id']):
if args['id'] in self:
ptr = LoadPixmap(args['file'])
if ptr:
os_remove(args['file'])
Expand All @@ -178,7 +160,7 @@ def result_pixmax(self, _result, args):

def buildEntry(self, *args):
logger.info("...")
if args[listtippsindex['dict']] and args[listtippsindex['dict']].has_key('url'):
if "url" in args[listtippsindex['dict']] and args[listtippsindex['dict']]:
self.download.run(MydownloadPage, url=args[listtippsindex['dict']]['url'], file=args[listtippsindex['dict']]['file'], headers=_headers_jpeg).addCallback(self.result_pixmax, args[listtippsindex['dict']]).addErrback(http_failed)
del args[listtippsindex['dict']]['url']
return args
Expand Down
Loading

0 comments on commit 6806778

Please sign in to comment.