1 # for localized messages
4 from Components.config import config, ConfigSubsection, ConfigSubList, \
5 ConfigOnOff, ConfigNumber, ConfigText, ConfigSelection, \
6 ConfigYesNo, ConfigPassword
8 from Components.PluginComponent import plugins
10 # Initialize Configuration
11 config.plugins.simpleRSS = ConfigSubsection()
12 simpleRSS = config.plugins.simpleRSS
13 simpleRSS.update_notification = ConfigSelection(
15 ("notification", _("Notification")),
16 ("preview", _("Preview")),
17 ("ticker", _("Ticker")),
22 simpleRSS.interval = ConfigNumber(default=15)
23 simpleRSS.feedcount = ConfigNumber(default=0)
24 simpleRSS.autostart = ConfigOnOff(default=False)
25 simpleRSS.keep_running = ConfigOnOff(default=True)
26 simpleRSS.feed = ConfigSubList()
28 while i < simpleRSS.feedcount.value:
29 s = ConfigSubsection()
30 s.uri = ConfigText(default="http://", fixed_size=False)
31 s.autoupdate = ConfigOnOff(default=True)
32 simpleRSS.feed.append(s)
35 simpleRSS.enable_google_reader = ConfigYesNo(default=False)
36 simpleRSS.google_username = ConfigText(default="", fixed_size=False)
37 simpleRSS.google_password = ConfigPassword(default="")
41 # Global Poller-Object
45 def main(session, **kwargs):
46 # Get Global rssPoller-Object
49 # Create one if we have none (no autostart)
51 from RSSPoller import RSSPoller
52 rssPoller = RSSPoller()
54 # Show Overview when we have feeds (or retrieving them from google)
55 if rssPoller.feeds or config.plugins.simpleRSS.enable_google_reader.value:
56 from RSSScreens import RSSOverview
57 session.openWithCallback(closed, RSSOverview, rssPoller)
58 # Show Setup otherwise
60 from RSSSetup import RSSSetup
61 session.openWithCallback(closed, RSSSetup, rssPoller)
63 # Plugin window has been closed
65 # If SimpleRSS should not run in Background: shutdown
66 if not (config.plugins.simpleRSS.autostart.value or \
67 config.plugins.simpleRSS.keep_running.value):
69 # Get Global rssPoller-Object
76 def autostart(reason, **kwargs):
79 if "session" in kwargs and config.plugins.simpleRSS.update_notification.value == "ticker":
80 import RSSTickerView as tv
81 if tv.tickerView is None:
82 tv.tickerView = kwargs["session"].instantiateDialog(tv.RSSTickerView)
84 # Instanciate when enigma2 is launching, autostart active and session present or installed during runtime
85 if reason == 0 and config.plugins.simpleRSS.autostart.value and \
86 (not plugins.firstRun or "session" in kwargs):
88 from RSSPoller import RSSPoller
89 rssPoller = RSSPoller()
91 if rssPoller is not None:
96 def filescan_open(item, session, **kwargs):
97 from RSSSetup import addFeed
103 from Screens.MessageBox import MessageBox
108 _("%d Feed(s) were added to configuration.") % (len(item)),
109 type = MessageBox.TYPE_INFO,
114 def filescan(**kwargs):
115 from Components.Scanner import Scanner, ScanPath
117 # Overwrite checkFile to detect remote files
118 class RemoteScanner(Scanner):
119 def checkFile(self, file):
120 return file.path.startswith(("http://", "https://"))
124 mimetypes = ("application/rss+xml", "application/atom+xml"),
127 ScanPath(path = "", with_subdirs = False),
130 description = _("Subscribe Newsfeed..."),
131 openfnc = filescan_open,
135 def Plugins(**kwargs):
136 from Plugins.Plugin import PluginDescriptor
140 description = _("A simple to use RSS reader"),
141 where = PluginDescriptor.WHERE_PLUGINMENU,
146 where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART],
151 name = _("View RSS..."),
152 description = "Let's you view current RSS entries",
153 where = PluginDescriptor.WHERE_EXTENSIONSMENU,
158 where = PluginDescriptor.WHERE_FILESCAN,