Example #1
0
    def onInit(self):
        '''triggered when the dialog is drawn'''
        if self.listitem:
            self.clearList()
            kodidb = KodiDb()
            if isinstance(self.listitem, dict):
                self.listitem = kodidb.prepare_listitem(self.listitem)
                self.listitem = kodidb.create_listitem(self.listitem, False)
            del kodidb
            self.addItem(self.listitem)

        # disable some controls if existing
        disable_controls = [9, 7, 101, 6]
        for item in disable_controls:
            try:
                self.getControl(item).setVisible(False)
            except Exception:
                pass

        # enable some controls if existing
        disable_controls = [351, 352]
        for item in disable_controls:
            try:
                self.getControl(item).setVisible(True)
                self.getControl(item).setEnabled(True)
            except Exception:
                pass
 def playlists_nodes(self):
     '''build smart shortcuts listing for playlists'''
     nodes = []
     if xbmc.getCondVisibility("Skin.HasSetting(SmartShortcuts.playlists)"):
         # build node listing
         count = 0
         import xml.etree.ElementTree as xmltree
         paths = [('special://videoplaylists/', 'Videos'),
                  ('special://musicplaylists/', 'Music')]
         for playlistpath in paths:
             if xbmcvfs.exists(playlistpath[0]):
                 media_array = KodiDb().files(playlistpath[0])
                 for item in media_array:
                     try:
                         label = ""
                         if item["file"].endswith(
                                 ".xsp") and "Emby" not in item["file"]:
                             playlist = item["file"]
                             contents = xbmcvfs.File(playlist, 'r')
                             contents_data = contents.read()
                             contents.close()
                             xmldata = xmltree.fromstring(contents_data)
                             media_type = "unknown"
                             label = item["label"]
                             for line in xmldata.getiterator():
                                 if line.tag == "smartplaylist":
                                     media_type = line.attrib['type']
                                 if line.tag == "name":
                                     label = line.text
                             key = "playlist.%s" % count
                             item_path = "ActivateWindow(%s,%s,return)" % (
                                 playlistpath[1], playlist)
                             self.bgupdater.set_winprop(
                                 "%s.label" % key, label)
                             self.bgupdater.set_winprop(
                                 "%s.title" % key, label)
                             self.bgupdater.set_winprop(
                                 "%s.action" % key, item_path)
                             self.bgupdater.set_winprop(
                                 "%s.path" % key, item_path)
                             self.bgupdater.set_winprop(
                                 "%s.content" % key, playlist)
                             self.bgupdater.set_winprop(
                                 "%s.type" % key, media_type)
                             nodes.append(
                                 ("%s.image" % key, playlist, label))
                             if key not in self.toplevel_nodes:
                                 self.toplevel_nodes.append(key)
                             count += 1
                     except Exception:
                         log_msg(
                             "Error while processing smart shortcuts for playlist %s  --> "
                             "This file seems to be corrupted, please remove it from your system "
                             "to prevent any further errors." %
                             item["file"], xbmc.LOGWARNING)
         self.all_nodes["playlists"] = nodes
 def __init__(self):
     self.cache = SimpleCache()
     self.kodidb = KodiDb()
     self.win = xbmcgui.Window(10000)
     self.addon = xbmcaddon.Addon(ADDON_ID)
     self.kodimonitor = xbmc.Monitor()
     self.all_backgrounds_labels = []
     self.smartshortcuts = SmartShortCuts(self)
     self.wallimages = WallImages(self)
     self.winprops = {}
Example #4
0
    def __init__(self):
        self.cache = SimpleCache()
        self.kodi_db = KodiDb()
        self.win = xbmcgui.Window(10000)
        try:
            self.params = dict(
                urlparse.parse_qsl(sys.argv[2].replace(
                    '?', '').lower().decode("utf-8")))
            log_msg("plugin called with parameters: %s" % self.params)
            self.main()
        except Exception as exc:
            log_exception(__name__, exc)
            xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))

        # cleanup when done processing
        self.close()
Example #5
0
 def open_item(self):
     '''open selected item'''
     control_id = self.getFocusId()
     listitem = self.getControl(control_id).getSelectedItem()
     if "videodb:" in listitem.getfilename():
         # tvshow: open path
         xbmc.executebuiltin('ReplaceWindow(Videos,"%s")' %
                             self.listitem.getfilename())
         self.close_dialog()
     elif "actor" in listitem.getProperty("DBTYPE"):
         # cast dialog
         xbmc.executebuiltin("ActivateWindow(busydialog)")
         from dialogselect import DialogSelect
         results = []
         kodidb = KodiDb()
         name = listitem.getLabel().decode("utf-8")
         items = kodidb.castmedia(name)
         items = process_method_on_list(kodidb.prepare_listitem, items)
         for item in items:
             if item["file"].startswith("videodb://"):
                 item["file"] = "ActivateWindow(Videos,%s,return)" % item[
                     "file"]
             else:
                 item["file"] = 'PlayMedia("%s")' % item["file"]
             results.append(kodidb.create_listitem(item, False))
         # finished lookup - display listing with results
         xbmc.executebuiltin("dialog.Close(busydialog)")
         dialog = DialogSelect("DialogSelect.xml",
                               "",
                               listing=results,
                               windowtitle=name,
                               richlayout=True)
         dialog.doModal()
         result = dialog.result
         del dialog
         if result:
             xbmc.executebuiltin(result.getfilename())
             self.close_dialog()
     else:
         # video file: start playback
         xbmc.executebuiltin('PlayMedia("%s")' % listitem.getfilename())
         self.close_dialog()
 def favourites_nodes(self):
     '''build smart shortcuts for favourites'''
     if xbmc.getCondVisibility("Skin.HasSetting(SmartShortcuts.favorites)"):
         # build node listing
         nodes = []
         favs = KodiDb().favourites()
         for count, fav in enumerate(favs):
             if fav["type"] == "window":
                 content = fav["windowparameter"]
                 # check if this is a valid path with content
                 if ("script://" not in content.lower()
                         and "mode=9" not in content.lower()
                         and "search" not in content.lower()
                         and "play" not in content.lower()):
                     item_path = "ActivateWindow(%s,%s,return)" % (
                         fav["window"], content)
                     if "&" in content and "?" in content and "=" in content and not content.endswith(
                             "/"):
                         content += "&widget=true"
                     media_type = detect_plugin_content(content)
                     if media_type:
                         key = "favorite.%s" % count
                         self.bgupdater.set_winprop("%s.label" % key,
                                                    fav["label"])
                         self.bgupdater.set_winprop("%s.title" % key,
                                                    fav["label"])
                         self.bgupdater.set_winprop("%s.action" % key,
                                                    item_path)
                         self.bgupdater.set_winprop("%s.path" % key,
                                                    item_path)
                         self.bgupdater.set_winprop("%s.content" % key,
                                                    content)
                         self.bgupdater.set_winprop("%s.type" % key,
                                                    media_type)
                         if key not in self.toplevel_nodes:
                             self.toplevel_nodes.append(key)
                         nodes.append(
                             ("%s.image" % key, content, fav["label"]))
         self.all_nodes["favourites"] = nodes
    def __init__(self):
        '''Initialization and main code run'''
        self.win = xbmcgui.Window(10000)
        self.addon = xbmcaddon.Addon(ADDON_ID)
        self.kodidb = KodiDb()
        self.cache = SimpleCache()

        self.params = self.get_params()
        log_msg("MainModule called with parameters: %s" % self.params)
        action = self.params.get("action", "")
        # launch module for action provided by this script
        try:
            getattr(self, action)()
        except AttributeError:
            log_exception(__name__, "No such action: %s" % action)
        except Exception as exc:
            log_exception(__name__, exc)
        finally:
            xbmc.executebuiltin("dialog.Close(busydialog)")

        # do cleanup
        self.close()
Example #8
0
 def __init__(self, *args):
     xbmc.log("SearchBackgroundThread Init")
     threading.Thread.__init__(self, *args)
     self.kodidb = KodiDb()
     self.actors = []
     thread.start_new_thread(self.set_actors, ())
 def get_youtube_listing(searchquery):
     '''get items from youtube plugin by query'''
     lib_path = u"plugin://plugin.video.youtube/kodion/search/query/?q=%s" % searchquery
     return KodiDb().files(lib_path)