[EasyMedia] Bugfix if only a few entries
[enigma2-plugins.git] / easymedia / src / plugin.py
1 #######################################################################
2 #
3 #    EasyMedia for Dreambox-Enigma2
4 #    Coded by Vali (c)2010-2011
5 #
6 #  This plugin is licensed under the Creative Commons 
7 #  Attribution-NonCommercial-ShareAlike 3.0 Unported License.
8 #  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
9 #  or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
10 #
11 #  Alternatively, this plugin may be distributed and executed on hardware which
12 #  is licensed by Dream Multimedia GmbH.
13 #
14 #  This plugin is NOT free software. It is open source, you are allowed to
15 #  modify it (if you keep the license), but it may not be commercially 
16 #  distributed other than under the conditions noted above.
17 #
18 #######################################################################
19
20
21
22 from __init__ import _
23 from Screens.Screen import Screen
24 from Screens.MessageBox import MessageBox
25 from Screens.InfoBarGenerics import InfoBarPlugins
26 from Screens.InfoBar import InfoBar
27 from Screens.ChoiceBox import ChoiceBox
28 from Plugins.Plugin import PluginDescriptor
29 from Components.ActionMap import ActionMap
30 from Components.MenuList import MenuList
31 from Components.Label import Label
32 from Components.ConfigList import ConfigListScreen
33 from Components.PluginComponent import plugins
34 from Components.PluginList import *
35 from Components.Sources.StaticText import StaticText
36 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection
37 from Tools.Directories import fileExists, pathExists, resolveFilename, SCOPE_PLUGINS
38 from Tools.LoadPixmap import LoadPixmap
39 from Tools.HardwareInfo import HardwareInfo
40 from enigma import RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont, getDesktop
41 import pickle
42 from os import system as os_system
43 from os import listdir as os_listdir
44
45
46
47 EMbaseInfoBarPlugins__init__ = None
48 EMStartOnlyOneTime = False
49 EMsession = None
50 InfoBar_instance = None
51
52
53
54 config.plugins.easyMedia  = ConfigSubsection()
55 config.plugins.easyMedia.music = ConfigSelection(default="mediaplayer", choices = [("no", _("Disabled")), ("mediaplayer", _("MediaPlayer")), ("merlinmp", _("MerlinMusicPlayer"))])
56 config.plugins.easyMedia.files = ConfigSelection(default="dreamexplorer", choices = [("no", _("Disabled")), ("filebrowser", _("Filebrowser")), ("dreamexplorer", _("DreamExplorer")), ("tuxcom", _("TuxCom"))])
57 config.plugins.easyMedia.videodb = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
58 config.plugins.easyMedia.bookmarks = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
59 config.plugins.easyMedia.pictures = ConfigSelection(default="yes", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
60 config.plugins.easyMedia.mytube = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
61 config.plugins.easyMedia.vlc = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
62 config.plugins.easyMedia.dvd = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
63 config.plugins.easyMedia.weather = ConfigSelection(default="yes", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
64 config.plugins.easyMedia.iradio = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
65 config.plugins.easyMedia.idream = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
66 config.plugins.easyMedia.zdfmedia = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
67 config.plugins.easyMedia.radio = ConfigSelection(default="yes", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
68 config.plugins.easyMedia.myvideo = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
69 config.plugins.easyMedia.timers = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
70
71
72
73 def Plugins(**kwargs):
74         return [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = EasyMediaAutostart),
75                         PluginDescriptor(name="EasyMedia", description=_("Not easy way to start EasyMedia"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=notEasy),]
76
77
78
79 def EasyMediaAutostart(reason, **kwargs):
80         global EMbaseInfoBarPlugins__init__
81         if "session" in kwargs:
82                 global EMsession
83                 EMsession = kwargs["session"]
84                 if EMbaseInfoBarPlugins__init__ is None:
85                         EMbaseInfoBarPlugins__init__ = InfoBarPlugins.__init__
86                 InfoBarPlugins.__init__ = InfoBarPlugins__init__
87                 InfoBarPlugins.pvr = pvr
88
89
90
91 def InfoBarPlugins__init__(self):
92         global EMStartOnlyOneTime
93         if not EMStartOnlyOneTime: 
94                 EMStartOnlyOneTime = True
95                 global InfoBar_instance
96                 InfoBar_instance = self
97                 self["EasyMediaActions"] = ActionMap(["EasyMediaActions"],
98                         {"video_but": self.pvr}, -1)
99         else:
100                 InfoBarPlugins.__init__ = InfoBarPlugins.__init__
101                 InfoBarPlugins.pvr = None
102         EMbaseInfoBarPlugins__init__(self)
103
104
105
106 def pvr(self):
107         self.session.openWithCallback(MPcallbackFunc, EasyMedia)
108
109
110
111 def notEasy(session, **kwargs):
112         session.openWithCallback(MPcallbackFunc, EasyMedia)
113
114
115
116 def MPanelEntryComponent(key, text, cell):
117         res = [ text ]
118         res.append((eListboxPythonMultiContent.TYPE_TEXT, 150, 17, 300, 60, 0, RT_HALIGN_LEFT, text[0]))
119         if cell<5:
120                 bpng = LoadPixmap('/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/key-' + str(cell) + ".png")
121                 if bpng is not None:
122                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 5, 5, 50, bpng))
123         png = LoadPixmap(EasyMedia.EMiconspath + key + '.png')
124         if png is not None:
125                 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 25, 5, 100, 50, png))
126         else:
127                 png = LoadPixmap(EasyMedia.EMiconspath + 'default.png')
128                 if png is not None:
129                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 25, 5, 100, 50, png))
130         return res
131
132
133
134 class MPanelList(MenuList):
135         def __init__(self, list, selection = 0, enableWrapAround=True):
136                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
137                 self.l.setFont(0, gFont("Regular", 20))
138                 self.l.setItemHeight(60)
139                 self.selection = selection
140         def postWidgetCreate(self, instance):
141                 MenuList.postWidgetCreate(self, instance)
142                 self.moveToIndex(self.selection)
143
144
145
146 def BookmarksCallback(choice):
147         choice = choice and choice[1]
148         if choice:
149                 config.movielist.last_videodir.value = choice
150                 config.movielist.last_videodir.save()
151                 if InfoBar_instance:
152                         InfoBar_instance.showMovies()
153
154
155
156 def TvRadioCallback(choice):
157         choice = choice and choice[1]
158         if choice == "TM":
159                 if InfoBar_instance:
160                         InfoBar_instance.showTv()
161         elif choice == "RM":
162                 if InfoBar_instance:
163                         InfoBar_instance.showRadio()
164
165
166
167 class ConfigEasyMedia(ConfigListScreen, Screen):
168         skin = """
169                 <screen name="ConfigEasyMedia" position="center,center" size="600,410" title="EasyMedia settings...">
170                         <widget name="config" position="5,5" scrollbarMode="showOnDemand" size="590,380"/>
171                         <eLabel font="Regular;20" foregroundColor="#00ff4A3C" halign="center" position="20,388" size="140,26" text="Cancel"/>
172                         <eLabel font="Regular;20" foregroundColor="#0056C856" halign="center" position="165,388" size="140,26" text="Save"/>
173                         <eLabel font="Regular;20" foregroundColor="#00f3ca09" halign="center" position="310,388" size="140,26" text="Plugins"/>
174                 </screen>"""
175         def __init__(self, session):
176                 Screen.__init__(self, session)
177                 self.setTitle(_("EasyMedia settings..."))
178                 self.session = session
179                 list = []
180                 list.append(getConfigListEntry(_("Video database:"), config.plugins.easyMedia.videodb))
181                 list.append(getConfigListEntry(_("Music player:"), config.plugins.easyMedia.music))
182                 list.append(getConfigListEntry(_("Files browser:"), config.plugins.easyMedia.files))
183                 list.append(getConfigListEntry(_("Show bookmarks:"), config.plugins.easyMedia.bookmarks))
184                 list.append(getConfigListEntry(_("Timer:"), config.plugins.easyMedia.timers))
185                 list.append(getConfigListEntry(_("PicturePlayer:"), config.plugins.easyMedia.pictures))
186                 list.append(getConfigListEntry(_("Show tv/radio switch:"), config.plugins.easyMedia.radio))
187                 list.append(getConfigListEntry(_("YouTube player:"), config.plugins.easyMedia.mytube))
188                 list.append(getConfigListEntry(_("VLC player:"), config.plugins.easyMedia.vlc))
189                 list.append(getConfigListEntry(_("DVD player:"), config.plugins.easyMedia.dvd))
190                 list.append(getConfigListEntry(_("Weather plugin:"), config.plugins.easyMedia.weather))
191                 list.append(getConfigListEntry(_("NetRadio player:"), config.plugins.easyMedia.iradio))
192                 list.append(getConfigListEntry(_("Show Merlin-iDream:"), config.plugins.easyMedia.idream))
193                 list.append(getConfigListEntry(_("ZDFmediathek player:"), config.plugins.easyMedia.zdfmedia))
194                 list.append(getConfigListEntry(_("MyVideo player:"), config.plugins.easyMedia.myvideo))
195                 ConfigListScreen.__init__(self, list)
196                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "red": self.exit, "cancel": self.exit, "yellow": self.plug}, -1)
197
198         def save(self):
199                 for x in self["config"].list:
200                         x[1].save()
201                 self.close()
202
203         def exit(self):
204                 for x in self["config"].list:
205                         x[1].cancel()
206                 self.close()
207
208         def plug(self):
209                 self.session.open(AddPlug)
210
211
212
213 class AddPlug(Screen):
214         skin = """
215                 <screen name="AddPlug" position="center,center" size="440,375" title="EasyMedia...">
216                         <widget name="list" position="0,10" size="440,355" scrollbarMode="showOnDemand" />
217                 </screen>"""
218         def __init__(self, session):
219                 Screen.__init__(self, session)
220                 self.setTitle(_("Add/remove plugin"))
221                 plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
222                 self.session = session
223                 self.list = []
224                 self["list"] = PluginList(self.list)
225                 self.updateList()
226                 self["actions"] = ActionMap(["WizardActions"],
227                 {
228                         "ok": self.save,
229                         "back": self.close
230                 }, -1)
231                 self.onExecBegin.append(self.checkWarnings)
232
233         def checkWarnings(self):
234                 if len(plugins.warnings):
235                         text = _("Some plugins are not available:\n")
236                         for (pluginname, error) in plugins.warnings:
237                                 text += _("%s (%s)\n") % (pluginname, error)
238                         plugins.resetWarnings()
239                         self.session.open(MessageBox, text = text, type = MessageBox.TYPE_WARNING)
240
241         def updateList(self):
242                 self.list = [ ]
243                 self.pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
244                 for plugin in self.pluginlist:
245                         self.list.append(PluginEntryComponent(plugin))
246                 self["list"].l.setList(self.list)
247
248         def save(self):
249                 plugin = self["list"].l.getCurrentSelection()[0]
250                 plugin.icon = None
251                 if not fileExists("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/" + plugin.name + ".plug"):
252                         try:
253                                 outf = open(("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/" + plugin.name + ".plug"), 'wb')
254                                 pickle.dump(plugin, outf)
255                                 outf.close()
256                                 self.session.open(MessageBox, text = (plugin.name + _(" added to EasyMedia")), type = MessageBox.TYPE_INFO)
257                         except: self.session.open(MessageBox, text = "Write Error!", type = MessageBox.TYPE_WARNING)
258                 else:
259                         order = 'rm -f \"' + '/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/' + plugin.name + '.plug' + '\"'
260                         try:
261                                 os_system(order)
262                                 self.session.open(MessageBox, text = (plugin.name + _(" removed from EasyMedia")), type = MessageBox.TYPE_INFO)
263                         except: self.session.open(MessageBox, text = "Write Error!", type = MessageBox.TYPE_WARNING)
264
265
266
267 class EasyMediaSummary(Screen):
268         if "800se" in HardwareInfo().get_device_name():
269                 skin = """
270                         <screen position="0,0" size="96,64" id="2">
271                                 <eLabel text="EasyMedia:" foregroundColor="#fcc000" position="0,0" size="96,24" font="Regular;16"/>
272                                 <widget name="text1" position="0,24" size="96,40" font="Regular;18"/>
273                         </screen>"""
274         else:
275                 skin = """
276                         <screen position="0,0" size="132,64">
277                                 <eLabel text="EasyMedia:" position="0,0" size="132,24" font="Regular;14"/>
278                                 <widget name="text1" position="0,24" size="132,40" font="Regular;16"/>
279                         </screen>"""
280         def __init__(self, session, parent):
281                 Screen.__init__(self, session)
282                 self["text1"] = Label()
283                 self.onLayoutFinish.append(self.layoutEnd)
284
285         def layoutEnd(self):
286                 self["text1"].setText(_("Movies"))
287
288         def setText(self, text, line):
289                 self["text1"].setText(text)
290
291
292
293 class EasyMedia(Screen):
294         sz_w = getDesktop(0).size().width()
295         if sz_w > 1100:
296                 skin = """
297                 <screen flags="wfNoBorder" position="0,0" size="450,720" title="Easy Media">
298                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg.png" position="0,0" size="450,576"/>
299                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg.png" position="0,576" size="450,145"/>
300                         <widget name="list" position="60,30" size="350,660" scrollbarMode="showNever" transparent="1" zPosition="2"/>
301                 </screen>"""
302         elif sz_w > 1000:
303                 skin = """
304                 <screen flags="wfNoBorder" position="-20,0" size="450,576" title="Easy Media">
305                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg.png" position="0,0" size="450,576"/>
306                         <widget name="list" position="70,48" size="320,480" scrollbarMode="showNever" transparent="1" zPosition="2"/>
307                 </screen>"""
308         else:
309                 skin = """
310                 <screen position="center,center" size="320,440" title="Easy Media">
311                         <widget name="list" position="10,10" size="300,420" scrollbarMode="showOnDemand" />
312                 </screen>"""
313         if pathExists('/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/icons/'):
314                 EMiconspath = '/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/icons/'
315         else:
316                 EMiconspath = '/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/'
317         def __init__(self, session):
318                 Screen.__init__(self, session)
319                 self.session = session
320                 self.list = []
321                 self.__keys = []
322                 MPaskList = []
323                 self["key_pvr"] = StaticText(" ")
324                 self["key_yellow"] = StaticText(" ")
325                 self["key_green"] = StaticText(" ")
326                 self["key_red"] = StaticText(" ")
327                 self["key_blue"] = StaticText(" ")
328                 if True:
329                         self.__keys.append("movies")
330                         MPaskList.append((_("Movies"), "PLAYMOVIES"))
331                 if config.plugins.easyMedia.bookmarks.value != "no":
332                         self.__keys.append("bookmarks")
333                         MPaskList.append((_("Bookmarks"), "BOOKMARKS"))
334                 if config.plugins.easyMedia.timers.value != "no":
335                         self.__keys.append("timers")
336                         MPaskList.append((_("Timer"), "TIMERS"))
337                 if config.plugins.easyMedia.videodb.value != "no":
338                         self.__keys.append("videodb")
339                         MPaskList.append((_("VideoDB"), "VIDEODB"))
340                 if config.plugins.easyMedia.pictures.value != "no":
341                         self.__keys.append("pictures")
342                         MPaskList.append((_("Pictures"), "PICTURES"))
343                 if config.plugins.easyMedia.music.value != "no":
344                         self.__keys.append("music")
345                         MPaskList.append((_("Music"), "MUSIC"))
346                 if config.plugins.easyMedia.radio.value != "no":
347                         self.__keys.append("radio")
348                         if config.usage.e1like_radio_mode.value:
349                                 MPaskList.append((_("Tv/Radio"), "RADIO"))
350                         else:
351                                 MPaskList.append((_("Radio"), "RADIO"))
352                 if config.plugins.easyMedia.dvd.value != "no":
353                         self.__keys.append("dvd")
354                         MPaskList.append((_("DVD Player"), "DVD"))
355                 if config.plugins.easyMedia.weather.value != "no":
356                         self.__keys.append("weather")
357                         MPaskList.append((_("Weather"), "WEATHER"))
358                 if config.plugins.easyMedia.files.value != "no":
359                         self.__keys.append("files")
360                         MPaskList.append((_("Files"), "FILES"))
361                 if config.plugins.easyMedia.iradio.value != "no":
362                         self.__keys.append("shoutcast")
363                         MPaskList.append((_("SHOUTcast"), "SHOUTCAST"))
364                 if config.plugins.easyMedia.idream.value != "no":
365                         self.__keys.append("idream")
366                         MPaskList.append((_("iDream"), "IDREAM"))
367                 if config.plugins.easyMedia.mytube.value != "no":
368                         self.__keys.append("mytube")
369                         MPaskList.append((_("MyTube Player"), "MYTUBE"))
370                 if config.plugins.easyMedia.vlc.value != "no":
371                         self.__keys.append("vlc")
372                         MPaskList.append((_("VLC Player"), "VLC"))
373                 if config.plugins.easyMedia.zdfmedia.value != "no":
374                         self.__keys.append("zdf")
375                         MPaskList.append((_("ZDFmediathek"), "ZDF"))
376                 if config.plugins.easyMedia.myvideo.value != "no":
377                         self.__keys.append("myvideo")
378                         MPaskList.append((_("MyVideo"), "MYVIDEO"))
379                 plist = os_listdir("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia")
380                 plist = [x[:-5] for x in plist if x.endswith('.plug')]
381                 plist.sort()
382                 for onePlug in plist:
383                         try:
384                                 inpf = open(("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/" + onePlug + ".plug"), 'rb')
385                                 binPlug = pickle.load(inpf)
386                                 inpf.close()    
387                                 self.__keys.append(binPlug.name)
388                                 MPaskList.append((binPlug.name, ("++++" + binPlug.name)))
389                         except: pass
390                 pos = 0
391                 for x in MPaskList:
392                         strpos = str(self.__keys[pos])
393                         self.list.append(MPanelEntryComponent(key = strpos, text = x, cell = pos))
394                         if pos==0: self["key_pvr"].setText(MPaskList[0][0])
395                         elif pos==1: self["key_red"].setText(MPaskList[1][0])
396                         elif pos==2: self["key_green"].setText(MPaskList[2][0])
397                         elif pos==3: self["key_yellow"].setText(MPaskList[3][0])
398                         elif pos==4: self["key_blue"].setText(MPaskList[4][0])
399                         pos += 1
400                 self["list"] = MPanelList(list = self.list, selection = 0)
401                 self["list"].onSelectionChanged.append(self.updateOLED)
402                 self["actions"] = ActionMap(["WizardActions", "MenuActions", "InfobarActions", "ColorActions"],
403                 {
404                         "ok": self.go,
405                         "back": self.cancel,
406                         "menu": self.emContextMenu,
407                         "showMovies": lambda: self.go2(MPaskList,0),
408                         "green": lambda: self.go2(MPaskList,2),
409                         "red": lambda: self.go2(MPaskList,1),
410                         "blue": lambda: self.go2(MPaskList,4),
411                         "yellow": lambda: self.go2(MPaskList,3)
412                 }, -1)
413
414         def cancel(self):
415                 self.close(None)
416
417         def go(self):
418                 cursel = self["list"].l.getCurrentSelection()
419                 if cursel:
420                         self.goEntry(cursel[0])
421                 else:
422                         self.cancel()
423
424         def go2(self, was, wohin):
425                 if wohin == 0:
426                         self.close(was[wohin])
427                 elif wohin == 1:
428                         if len(was)>1: 
429                                 self.close(was[wohin])
430                 elif wohin == 2:
431                         if len(was)>2: 
432                                 self.close(was[wohin])
433                 elif wohin == 3:
434                         if len(was)>3: 
435                                 self.close(was[wohin])
436                 elif wohin == 4:
437                         if len(was)>4: 
438                                 self.close(was[wohin])
439
440         def goEntry(self, entry):
441                 if len(entry) > 2 and isinstance(entry[1], str) and entry[1] == "CALLFUNC":
442                         arg = self["list"].l.getCurrentSelection()[0]
443                         entry[2](arg)
444                 else:
445                         self.close(entry)
446
447         def emContextMenu(self):
448                 self.session.open(ConfigEasyMedia)
449
450         def createSummary(self):
451                 return EasyMediaSummary
452
453         def updateOLED(self):
454                 text = str(self["list"].l.getCurrentSelection()[0][0])
455                 self.summaries.setText(text, 1)
456
457
458
459 def MPcallbackFunc(answer):
460         if EMsession is None:
461                 return
462         answer = answer and answer[1]
463         if answer == "PLAYMOVIES":
464                 if InfoBar_instance:
465                         InfoBar_instance.showMovies()
466         elif answer == "RADIO":
467                 if config.usage.e1like_radio_mode.value:
468                         askBM = []
469                         askBM.append((_("TV-mode"), "TM"))
470                         askBM.append((_("Radio-mode"), "RM"))
471                         askBM.append((_("Nothing"), "NO"))
472                         EMsession.openWithCallback(TvRadioCallback, ChoiceBox, title="EasyMedia...", list = askBM)
473                 else:
474                         if InfoBar_instance:
475                                 InfoBar_instance.showRadio()
476         elif answer == "BOOKMARKS":
477                 tmpBookmarks = config.movielist.videodirs
478                 myBookmarks = tmpBookmarks and tmpBookmarks.value[:] or []
479                 if len(myBookmarks)>0:
480                         askBM = []
481                         for s in myBookmarks:
482                                 askBM.append((s, s))
483                         EMsession.openWithCallback(BookmarksCallback, ChoiceBox, title=_("Select bookmark..."), list = askBM)
484         elif answer == "PICTURES":
485                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/PicturePlayer/plugin.pyo"):
486                         from Plugins.Extensions.PicturePlayer.plugin import picshow
487                         EMsession.open(picshow)
488                 else:
489                         EMsession.open(MessageBox, text = _('Picture-player is not installed!'), type = MessageBox.TYPE_ERROR)
490         elif answer == "MUSIC":
491                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinMusicPlayer/plugin.pyo") and (config.plugins.easyMedia.music.value == "merlinmp"):
492                         from Plugins.Extensions.MerlinMusicPlayer.plugin import MerlinMusicPlayerFileList
493                         servicelist = None
494                         EMsession.open(MerlinMusicPlayerFileList, servicelist)
495                 elif fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MediaPlayer/plugin.pyo") and (config.plugins.easyMedia.music.value == "mediaplayer"):
496                         from Plugins.Extensions.MediaPlayer.plugin import MediaPlayer
497                         EMsession.open(MediaPlayer)
498                 else:
499                         EMsession.open(MessageBox, text = _('No Music-Player installed!'), type = MessageBox.TYPE_ERROR)
500         elif answer == "FILES":
501                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Tuxcom/plugin.pyo") and (config.plugins.easyMedia.files.value == "tuxcom"):
502                         from Plugins.Extensions.Tuxcom.plugin import TuxComStarter
503                         EMsession.open(TuxComStarter)
504                 elif fileExists("/usr/lib/enigma2/python/Plugins/Extensions/DreamExplorer/plugin.pyo") and (config.plugins.easyMedia.files.value == "dreamexplorer"):
505                         from Plugins.Extensions.DreamExplorer.plugin import DreamExplorerII
506                         EMsession.open(DreamExplorerII)
507                 elif fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Filebrowser/plugin.pyo") and (config.plugins.easyMedia.files.value == "filebrowser"):
508                         from Plugins.Extensions.Filebrowser.plugin import FilebrowserScreen
509                         EMsession.open(FilebrowserScreen)
510                 else:
511                         EMsession.open(MessageBox, text = _('No File-Manager installed!'), type = MessageBox.TYPE_ERROR)
512         elif answer == "WEATHER":
513                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/WeatherPlugin/plugin.pyo"):
514                         from Plugins.Extensions.WeatherPlugin.plugin import WeatherPlugin
515                         EMsession.open(WeatherPlugin)
516                 else:
517                         EMsession.open(MessageBox, text = _('Weather Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
518         elif answer == "DVD":
519                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/DVDPlayer/plugin.pyo"):
520                         from Plugins.Extensions.DVDPlayer.plugin import DVDPlayer
521                         EMsession.open(DVDPlayer)
522                 else:
523                         EMsession.open(MessageBox, text = _('DVDPlayer Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
524         elif answer == "MYTUBE":
525                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MyTube/plugin.pyo"):
526                         from Plugins.Extensions.MyTube.plugin import *
527                         MyTubeMain(EMsession)
528                 else:
529                         EMsession.open(MessageBox, text = _('MyTube Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
530         elif answer == "SHOUTCAST":
531                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/SHOUTcast/plugin.pyo"):
532                         from Plugins.Extensions.SHOUTcast.plugin import SHOUTcastWidget
533                         EMsession.open(SHOUTcastWidget)
534                 else:
535                         EMsession.open(MessageBox, text = _('SHOUTcast Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
536         elif answer == "ZDF":
537                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/ZDFMediathek/plugin.pyo"):
538                         from Plugins.Extensions.ZDFMediathek.plugin import ZDFMediathek
539                         EMsession.open(ZDFMediathek)
540                 else:
541                         EMsession.open(MessageBox, text = _('ZDFmediathek Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
542         elif answer == "VLC":
543                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/VlcPlayer/plugin.pyo"):
544                         from Plugins.Extensions.VlcPlayer.plugin import *
545                         main(EMsession)
546                 else:
547                         EMsession.open(MessageBox, text = _('VLC Player is not installed!'), type = MessageBox.TYPE_ERROR)
548         elif answer == "IDREAM":
549                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinMusicPlayer/plugin.pyo"):
550                         from Plugins.Extensions.MerlinMusicPlayer.plugin import iDreamMerlin
551                         servicelist = None
552                         EMsession.open(iDreamMerlin, servicelist)
553                 else:
554                         EMsession.open(MessageBox, text = _('Merlin iDream is not installed!'), type = MessageBox.TYPE_ERROR)
555         elif answer == "MYVIDEO":
556                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MyVideoPlayer/plugin.pyo"):
557                         from Plugins.Extensions.MyVideoPlayer.plugin import Vidtype
558                         EMsession.open(Vidtype)
559                 else:
560                         EMsession.open(MessageBox, text = _('MyVideo Player is not installed!'), type = MessageBox.TYPE_ERROR)
561         elif answer == "VIDEODB":
562                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/VideoDB/plugin.pyo"):
563                         from Plugins.Extensions.VideoDB.plugin import main as vdbmain
564                         vdbmain(EMsession)
565                 else:
566                         EMsession.open(MessageBox, text = _('VideoDB is not installed!'), type = MessageBox.TYPE_ERROR)
567         elif answer == "TIMERS":
568                 from Screens.TimerEdit import TimerEditList
569                 EMsession.open(TimerEditList)
570         elif answer is not None and "++++" in answer:
571                 plugToRun = answer[4:]
572                 try:
573                         inpf = open(("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/" + plugToRun + ".plug"), 'rb')
574                         runPlug = pickle.load(inpf)
575                         inpf.close()    
576                         runPlug(session = EMsession)
577                 except: EMsession.open(MessageBox, text = (plugToRun + " not found!"), type = MessageBox.TYPE_WARNING)
578
579
580