diff --git a/simplerss/src/Makefile.am b/simplerss/src/Makefile.am index d8f048122..55c3a7d79 100644 --- a/simplerss/src/Makefile.am +++ b/simplerss/src/Makefile.am @@ -4,4 +4,4 @@ installdir = $(libdir)/enigma2/python/Plugins/Extensions/SimpleRSS install_PYTHON = *.py -install_DATA = *.xml maintainer.info plugin.png +install_DATA = maintainer.info plugin.png diff --git a/simplerss/src/plugin.py b/simplerss/src/plugin.py index 420f34c6d..499106414 100644 --- a/simplerss/src/plugin.py +++ b/simplerss/src/plugin.py @@ -9,7 +9,7 @@ from shutil import copy, rmtree from traceback import print_exc from twisted.internet.reactor import callInThread -from xml.etree.ElementTree import tostring, parse, fromstring +from xml.etree.ElementTree import tostring, fromstring # current feed: # self.feed: <, "Title", "Description", 5 items> @@ -26,7 +26,6 @@ from Components.ScrollLabel import ScrollLabel from Components.Sources.List import List from Components.Sources.StaticText import StaticText -from Plugins.Extensions.PicturePlayer import ui from Plugins.Plugin import PluginDescriptor from Plugins.SystemPlugins.Toolkit.TagStrip import strip, strip_readable from Screens.ChoiceBox import ChoiceBox @@ -42,10 +41,18 @@ from . import _ # for localized messages # GLOBALS +MODULE_NAME = __name__.split(".")[-2] +try: + from Plugins.Extensions.PicturePlayer import ui + PICTUREPLAYER = True +except ImportError as err: + PICTUREPLAYER = False + print(f"[{MODULE_NAME}] Import WARNING: Plugin 'PicturePlayer' was not found.") + rssPoller = None tickerView = None update_callbacks = [] -MODULE_NAME = __name__.split(".")[-2] +RESOLUTION = "fHD" if getDesktop(0).size().width() > 1300 else "HD" TEMPPATH = join("/tmp/", MODULE_NAME.lower()) # /tmp/simplerss/ PLUGINPATH = resolveFilename(SCOPE_PLUGINS, "Extensions/%s" % MODULE_NAME) # /usr/lib/enigma2/python/Plugins/Extensions/SimpleRSS/ NOLOGO = "no_logo.png" @@ -98,7 +105,6 @@ def main(session, **kwargs): # Main Function else: # Show Setup otherwise session.openWithCallback(closed, RSS_Setup, rssPoller) # Plugin window has been closed - def closed(): # If SimpleRSS should not run in Background: shutdown if not (config.plugins.simpleRSS.autostart.value or config.plugins.simpleRSS.keep_running.value): global rssPoller # Get Global rssPoller-Object @@ -106,7 +112,6 @@ def closed(): # If SimpleRSS should not run in Background: shutdown rssPoller.shutdown() rssPoller = None - def autostart(reason, **kwargs): # Autostart global rssPoller, tickerView if "session" in kwargs: @@ -121,24 +126,6 @@ def autostart(reason, **kwargs): # Autostart rssPoller = None -def readSkin(skin): - skintext = "" - skinfile = join(PLUGINPATH, "skin_%s.xml" % ("fHD" if getDesktop(0).size().width() > 1300 else "HD")) - try: - with open(skinfile, "r") as file: - try: - domskin = parse(file).getroot() - for element in domskin: - if element.tag == "screen" and element.attrib["name"] == skin: - skintext = tostring(element).decode() - break - except Exception as error: - print("[Skin] Error: Unable to parse skin data in '%s' - '%s'!" % (skinfile, error)) - except OSError as error: - print("[Skin] Error: Unexpected error opening skin file '%s'! (%s)" % (skinfile, error)) - return skintext - - def downloadPicfile(url, picfile, resize=None, fixedname=None, callback=None): if url and picfile: try: @@ -188,28 +175,36 @@ def cleanupUrl(url): def isExtensionSupported(name, supportlist=MIMEIMAGES): - return name[name.rfind("."):] in [".%s" % type[type.rfind("/") + 1:] for type in supportlist] # extension supported? + return name[name.rfind("."):] in [".%s" % type[type.rfind("/") + 1:] for type in supportlist] # extension supported? class RSS_TickerView(Screen): + skin = """ + + + + + + Format:%H:%M + + """ def __init__(self, session): - self.session = session - skin = readSkin("RSS_TickerView") - oldpos = search(r' 1300 else 6.84) * int(config.plugins.simpleRSS.ticker_ypos.value))) - skin = skin.replace('position="%s"' % oldpos. group(2), 'position="%s"' % newpos) + newpos = "%s,%s" % (oldpos.group(2).split(",")[0], int(10.26 * int(config.plugins.simpleRSS.ticker_ypos.value))) + self.skin = self.skin.replace('position="%s"' % oldpos. group(2), 'position="%s"' % newpos) newoptions = ["steptime=%d,step=%d" % (config.plugins.simpleRSS.ticker_frequency.value, config.plugins.simpleRSS.ticker_scrollspeed.value)] - options = search(r'options\s*="(.*?)"', skin) + options = search(r'options\s*="(.*?)"', self.skin) if options: options = options.group(1) for option in options.split(","): if "step" not in option: # remove entries 'steptime=' and 'step='… newoptions.append(option) newoptions = ",".join(newoptions) - skin = skin.replace(options, newoptions) # …and add/replace it with own entries - self.skin = skin - Screen.__init__(self, session, skin) + self.skin = self.skin.replace(options, newoptions) # …and add/replace it with own entries + if RESOLUTION == "HD": + self.skin = self.skin.replace("_fHD.png", "_HD.png") + Screen.__init__(self, session) self["newsLabel"] = StaticText() def updateText(self, feed): @@ -245,10 +240,39 @@ def save(self): class RSS_Setup(ConfigListScreen, Screen): # Setup for SimpleRSS, quick-edit for Feed-URIs and settings present. + skin = """ + + + + + Default + + + Format:%A + + + Format:%e. %B + + + + + + + + + + + + + + + + """ def __init__(self, session, rssPoller=None): self.session = session - self.skin = readSkin("RSS_Setup") - Screen.__init__(self, session, self.skin) + if RESOLUTION == "HD": + self.skin = self.skin.replace("_fHD.png", "_HD.png") + Screen.__init__(self, session) self.rssPoller = rssPoller config.plugins.simpleRSS.autostart.addNotifier(self.elementChanged, initial_call=False) ConfigListScreen.__init__(self, self.getSetupList(), on_change=self.elementChanged) @@ -412,11 +436,18 @@ def keyCancel(self): self.close() -class RSSSummary(Screen): +class RSS_Summary(Screen): + skin = """ + + + + + WithSeconds + + """ def __init__(self, session, parent): self.session = session - self.skin = readSkin("RSSSummary") - Screen.__init__(self, session, parent, self.skin) + Screen.__init__(self, session, parent) self["entry"] = StaticText("") parent.onChangedEntry.append(self.selectionChanged) self.onShow.append(parent.updateInfo) @@ -437,7 +468,7 @@ def __init__(self, session, poller): self.pollDialog = None def createSummary(self): - return RSSSummary + return RSS_Summary def errorPolling(self, errmsg=""): # An error occured while polling self.session.open(MessageBox, _("Error while parsing Feed, this usually means there is something wrong with it."), type=MessageBox.TYPE_ERROR, timeout=3) @@ -461,6 +492,32 @@ def findEnclosure(self, enclosures): class RSS_EntryView(RSSBaseView): # Shows a RSS Item + skin = """ + + + + + Default + + + Format:%A + + + Format:%e. %B + + + + + + + + + + {"template": [MultiContentEntryText(pos=(0,0), size=(381,48), font=0, flags=RT_HALIGN_CENTER|RT_VALIGN_CENTER, text=0)], "fonts": [gFont("Regular",30)], "itemHeight":48} + + + + """ def __init__(self, session, data, cur_idx=None, entries=None, feedTitle="", feedLogo=""): RSSBaseView.__init__(self, session, None) self.session = session @@ -471,9 +528,8 @@ def __init__(self, session, data, cur_idx=None, entries=None, feedTitle="", feed self.feedpng = feedLogo self.enclist = [] self.pngfile = join(TEMPPATH, "entrypic.png") - self.picsize = (382, 214) if getDesktop(0).size().width() > 1300 else (255, 143) - self.skin = readSkin("RSS_EntryView") - Screen.__init__(self, session, self.skin) + self.picsize = (382, 214) if RESOLUTION == "fHD" else (255, 143) + Screen.__init__(self, session) self["title"] = StaticText(_("Simple RSS Reader EntryView")) self["info"] = StaticText(_("Entry %s/%s") % (cur_idx + 1, entries)) if cur_idx is not None and entries is not None else StaticText() self["feedlogo"] = Pixmap() @@ -552,7 +608,10 @@ def showFullpic(self): if exists(pngfile): piclist.append(((pngfile, False), None)) if piclist: - self.session.open(ui.Pic_Full_View, piclist, 0, TEMPPATH) + if PICTUREPLAYER: + self.session.open(ui.Pic_Full_View, piclist, 0, TEMPPATH) + else: + self.session.open(MessageBox, _("Plugin 'PicturePlayer' not found!\n\nIn order to view pictures, please install it from plugin feed"), type=MessageBox.TYPE_ERROR, timeout=5) def keyUp(self): if self.enclist: @@ -579,18 +638,55 @@ def __close(self): class RSS_FeedView(RSSBaseView): # Shows a RSS-Feed + skin = """ + + + + + Default + + + Format:%A + + + Format:%e. %B + + + + + + + + {"templates": + {"default": (120,[ + MultiContentEntryPixmap(pos=(0,0), size=(1050,10), png=1), # line separator + MultiContentEntryPixmapAlphaBlend(pos=(7,7), size=(225,105), flags=BT_SCALE|BT_KEEP_ASPECT_RATIO|BT_HALIGN_CENTER|BT_VALIGN_CENTER, png=2), # entrypicture + MultiContentEntryPixmapAlphaBlend(pos=(82,22), size=(75,75), png=3), # streamicon + MultiContentEntryText(pos=(240,7), size=(795,105), font=0, flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text=0) # feedtext + ]), + "news": (120,[ + MultiContentEntryPixmap(pos=(0,0), size=(1050,10), png=1), # line separator + MultiContentEntryText(pos=(15,7), size=(990,110), font=0, flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text=0) # feedtext + ]) + }, + "fonts": [gFont("Regular",30)], + "itemHeight":120 + } + + + + """ def __init__(self, session, feed=None, newItems=False, rssPoller=None, parent=None, ident=None): # structure of feed.history: ["titletext", "homepage-URL", "summarytext", "picture-URL"] RSSBaseView.__init__(self, session, rssPoller) self.session = session - self.skin = readSkin("RSS_FeedView") - Screen.__init__(self, session, self.skin) + Screen.__init__(self, session) self.feed = feed self.newItems = newItems self.parent = parent # restore, because 'Screen.__init' will set self.parent = 'Screen of Skin' self.ident = ident self.nopic = join(TEMPPATH, NOPIC) - self.picsize = (225, 105) if getDesktop(0).size().width() > 1300 else (150, 70) + self.picsize = (225, 105) if RESOLUTION == "fHD" else (150, 70) self["feedlogo"] = Pixmap() self["title"] = StaticText(_("Simple RSS Reader Feedview")) self["content"] = List([]) @@ -617,9 +713,9 @@ def __init__(self, session, feed=None, newItems=False, rssPoller=None, parent=No self.timer = eTimer() self.timer.callback.append(self.timerTick) self.onExecBegin.append(self.startTimer) - linefile = join(PLUGINPATH, "icons/line_%s.png" % ("fHD" if getDesktop(0).size().width() > 1300 else "HD")) + linefile = join(PLUGINPATH, "icons/line_%s.png" % RESOLUTION) self.linepix = LoadPixmap(cached=True, path=linefile if exists(linefile) else join(TEMPPATH, NOPIC)) - streamfile = join(PLUGINPATH, "icons/streamicon_%s.png" % ("fHD" if getDesktop(0).size().width() > 1300 else "HD")) + streamfile = join(PLUGINPATH, "icons/streamicon_%s.png" % RESOLUTION) self.streampix = LoadPixmap(cached=True, path=streamfile) if exists(streamfile) else None self["content"].onSelectionChanged.append(self.updateInfo) self.onLayoutFinish.append(self.onLayoutFinished) @@ -783,12 +879,46 @@ def keyPageDown(self): class RSS_Overview(RSSBaseView): # Shows an Overview over all RSS-Feeds known to rssPoller + skin = """ + + + + + Default + + + Format:%A + + + Format:%e. %B + + + + + + + + {"template": [ + MultiContentEntryPixmap(pos=(0,0), size=(1740,10), png=2), # line separator + MultiContentEntryPixmapAlphaBlend(pos=(7,18), size=(225,105), flags=BT_SCALE|BT_KEEP_ASPECT_RATIO|BT_HALIGN_CENTER|BT_VALIGN_CENTER, png=3), # feedlogo + MultiContentEntryText(pos=(240,7), size=(1482,45), font=0, flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text=0), # title + MultiContentEntryText(pos=(240,54), size=(1482,80), font=1, flags=RT_HALIGN_LEFT|RT_VALIGN_TOP|RT_WRAP, text=1) # description + ], + "fonts": [gFont("Regular",33), gFont("Regular",30)], + "itemHeight":141 + } + + + + + """ def __init__(self, session, poller): self.session = session RSSBaseView.__init__(self, session, poller) - self.skin = readSkin("RSS_Overview") - Screen.__init__(self, session, self.skin) - self.logosize = (225, 105) if getDesktop(0).size().width() > 1300 else (150, 70) + if RESOLUTION == "HD": + self.skin = self.skin.replace("_fHD.png", "_HD.png") + Screen.__init__(self, session) + self.logosize = (225, 105) if RESOLUTION == "fHD" else (150, 70) self.fillFeeds() self["title"] = StaticText(_("Simple RSS Reader Overview")) self["content"] = List([]) @@ -807,7 +937,7 @@ def __init__(self, session, poller): "chminus": self.keyPageDown, "chplus": self.keyPageUp }, -1) - linefile = join(PLUGINPATH, "icons/line_%s.png" % ("fHD" if getDesktop(0).size().width() > 1300 else "HD")) + linefile = join(PLUGINPATH, "icons/line_%s.png" % RESOLUTION) self.linepix = LoadPixmap(cached=True, path=linefile) if exists(linefile) else None self.onLayoutFinish.append(self.__show) self.onClose.append(self.__close) @@ -1142,7 +1272,7 @@ class PEAEntryWrapper(ElementWrapper): def __getattr__(self, tag): if tag == "link": for elem in self._element.findall("%s%s" % (self._ns, tag)): - if not elem.get("rel") == "enclosure": + if elem.get("rel") != "enclosure": return elem.get("href") return '' elif tag == "enclosures": diff --git a/simplerss/src/skin_HD.xml b/simplerss/src/skin_HD.xml deleted file mode 100644 index 4e2d4573d..000000000 --- a/simplerss/src/skin_HD.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - Default - - - Format:%A - - - Format:%e. %B - - - - - - - - - - - - - - - - - - - - - - Default - - - Format:%A - - - Format:%e. %B - - - - - - - - - - {"template": [MultiContentEntryText(pos=(0,0), size=(254,32), font=0, flags=RT_HALIGN_CENTER|RT_VALIGN_CENTER, text=0)], "fonts": [gFont("Regular",20)], "itemHeight":32} - - - - - - - - - - Default - - - Format:%A - - - Format:%e. %B - - - - - - - - {"templates": - {"default": (80,[ - MultiContentEntryPixmap(pos=(0,0), size=(700,6), png=1), # index 1 is the line separator - MultiContentEntryPixmapAlphaBlend(pos=(4,4), size=(150,70), flags=BT_SCALE|BT_KEEP_ASPECT_RATIO|BT_HALIGN_CENTER|BT_VALIGN_CENTER, png=2), # entrypicture - MultiContentEntryPixmapAlphaBlend(pos=(54,14), size=(50,50), png=3), # streamicon - MultiContentEntryText(pos=(160,4), size=(530,70), font=0, flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text=0) # feedtext - ]), - "news": (80,[ - MultiContentEntryPixmap(pos=(0,0), size=(700,6), png=1), # index 1 is the line separator - MultiContentEntryText(pos=(10,4), size=(660,73), font=0, flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text=0) # feedtext - ]) - }, - "fonts": [gFont("Regular",20)], - "itemHeight":80 - } - - - - - - - - - - Default - - - Format:%A - - - Format:%e. %B - - - - - - - - {"template": [ - MultiContentEntryPixmap(pos=(0,0), size=(1160,6), png=2), # index 2 is the line separator - MultiContentEntryPixmapAlphaBlend(pos=(4,12), size=(150,70), flags=BT_SCALE|BT_KEEP_ASPECT_RATIO|BT_HALIGN_CENTER|BT_VALIGN_CENTER, png=3), # feedlogo - MultiContentEntryText(pos=(160,4), size=(988,30), font=0, flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text=0), # title - MultiContentEntryText(pos=(160,36), size=(988,53), font=1, flags=RT_HALIGN_LEFT|RT_VALIGN_TOP|RT_WRAP, text=1) # description - ], - "fonts": [gFont("Regular",22), gFont("Regular",20)], - "itemHeight":94 - } - - - - - - - - - - - - Format:%H:%M - - - - diff --git a/simplerss/src/skin_fHD.xml b/simplerss/src/skin_fHD.xml deleted file mode 100644 index 207768b76..000000000 --- a/simplerss/src/skin_fHD.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - Default - - - Format:%A - - - Format:%e. %B - - - - - - - - - - - - - - - - - - - - - - Default - - - Format:%A - - - Format:%e. %B - - - - - - - - - - {"template": [MultiContentEntryText(pos=(0,0), size=(381,48), font=0, flags=RT_HALIGN_CENTER|RT_VALIGN_CENTER, text=0)], "fonts": [gFont("Regular",30)], "itemHeight":48} - - - - - - - - - - Default - - - Format:%A - - - Format:%e. %B - - - - - - - - {"templates": - {"default": (120,[ - MultiContentEntryPixmap(pos=(0,0), size=(1050,10), png=1), # index 1 is the line separator - MultiContentEntryPixmapAlphaBlend(pos=(7,7), size=(225,105), flags=BT_SCALE|BT_KEEP_ASPECT_RATIO|BT_HALIGN_CENTER|BT_VALIGN_CENTER, png=2), # entrypicture - MultiContentEntryPixmapAlphaBlend(pos=(82,22), size=(75,75), png=3), # streamicon - MultiContentEntryText(pos=(240,7), size=(795,105), font=0, flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text=0) # feedtext - ]), - "news": (120,[ - MultiContentEntryPixmap(pos=(0,0), size=(1050,10), png=1), # index 1 is the line separator - MultiContentEntryText(pos=(15,7), size=(990,110), font=0, flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text=0) # feedtext - ]) - }, - "fonts": [gFont("Regular",30)], - "itemHeight":120 - } - - - - - - - - - - Default - - - Format:%A - - - Format:%e. %B - - - - - - - - {"template": [ - MultiContentEntryPixmap(pos=(0,0), size=(1740,10), png=2), # index 2 is the line separator - MultiContentEntryPixmapAlphaBlend(pos=(7,18), size=(225,105), flags=BT_SCALE|BT_KEEP_ASPECT_RATIO|BT_HALIGN_CENTER|BT_VALIGN_CENTER, png=3), # feedlogo - MultiContentEntryText(pos=(240,7), size=(1482,45), font=0, flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text=0), # title - MultiContentEntryText(pos=(240,54), size=(1482,80), font=1, flags=RT_HALIGN_LEFT|RT_VALIGN_TOP|RT_WRAP, text=1) # description - ], - "fonts": [gFont("Regular",33), gFont("Regular",30)], - "itemHeight":141 - } - - - - - - - - - - - - Format:%H:%M - - - -