1 from Components.config import config, ConfigSubsection, ConfigSubList, \
2 ConfigEnableDisable, ConfigNumber, ConfigText, ConfigSelection
4 # Initialize Configuration
5 config.plugins.simpleRSS = ConfigSubsection()
6 config.plugins.simpleRSS.update_notification = ConfigSelection(
8 ("notification", _("Notification")),
9 ("preview", _("Preview")),
14 config.plugins.simpleRSS.interval = ConfigNumber(default=15)
15 config.plugins.simpleRSS.feedcount = ConfigNumber(default=0)
16 config.plugins.simpleRSS.autostart = ConfigEnableDisable(default=False)
17 config.plugins.simpleRSS.keep_running = ConfigEnableDisable(default=True)
18 config.plugins.simpleRSS.feed = ConfigSubList()
19 for i in range(0, config.plugins.simpleRSS.feedcount.value):
20 config.plugins.simpleRSS.feed.append(ConfigSubsection())
21 config.plugins.simpleRSS.feed[i].uri = ConfigText(default="http://", fixed_size = False)
22 config.plugins.simpleRSS.feed[i].autoupdate = ConfigEnableDisable(default=True)
24 # Global Poller-Object
28 def main(session, **kwargs):
29 # Get Global rssPoller-Object
32 # Create one if we have none (no autostart)
34 from RSSPoller import RSSPoller
35 rssPoller = RSSPoller(session)
37 # Show Overview when we have feeds
38 if len(rssPoller.feeds):
39 from RSSScreens import RSSOverview
40 session.openWithCallback(closed, RSSOverview, rssPoller)
41 # Show Setup otherwise
43 from RSSSetup import RSSSetup
44 session.openWithCallback(closed, RSSSetup, rssPoller)
46 # Plugin window has been closed
48 # If SimpleRSS should not run in Background: shutdown
49 if not config.plugins.simpleRSS.autostart.value and \
50 not config.plugins.simpleRSS.keep_running.value:
52 # Get Global rssPoller-Object
59 def autostart(reason, **kwargs):
62 # Instanciate when autostart active, session present and enigma2 is launching
63 if config.plugins.simpleRSS.autostart.value and \
64 kwargs.has_key("session") and reason == 0:
66 from RSSPoller import RSSPoller
67 rssPoller = RSSPoller(kwargs["session"])
69 if rssPoller is not None:
74 def filescan_open(item, session, **kwargs):
75 from RSSSetup import addFeed
81 from Screens.MessageBox import MessageBox
86 _("%d Feed(s) were added to configuration.") % (len(item)),
87 type = MessageBox.TYPE_INFO,
92 def filescan(**kwargs):
93 from Components.Scanner import Scanner, ScanPath
95 # Overwrite checkFile to detect remote files
96 class RemoteScanner(Scanner):
97 def checkFile(self, file):
98 return file.path.startswith(("http://", "https://"))
102 mimetypes = ["application/rss+xml", "application/atom+xml"],
105 ScanPath(path = "", with_subdirs = False),
108 description = "Subscribe Newsfeed...",
109 openfnc = filescan_open,
113 def Plugins(**kwargs):
114 from Plugins.Plugin import PluginDescriptor
115 return [ PluginDescriptor(name="RSS Reader", description="A simple to use RSS reader", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
116 PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart),
117 PluginDescriptor(name="View RSS", description="Let's you view current RSS entries", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main),
118 PluginDescriptor(where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)]