def favourites_widgets(): """widgets from favourites""" favourites = kodi_json( 'Favourites.GetFavourites', { "type": None, "properties": ["path", "thumbnail", "window", "windowparameter"] }) widgets = [] if favourites: for fav in favourites: if "windowparameter" in fav: 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()): label = fav["title"] log_msg("skinshortcuts widgets processing favourite: %s" % label) mutils = MetadataUtils() mediatype = mutils.detect_plugin_content(content) del mutils if mediatype and mediatype != "empty": widgets.append([label, content, mediatype]) return widgets
def playlists_widgets(): '''skin provided playlists''' widgets = [] import xml.etree.ElementTree as xmltree for playlist_path in ["special://skin/playlists/", "special://skin/extras/widgetplaylists/", "special://skin/extras/playlists/"]: if xbmcvfs.exists(playlist_path): log_msg("skinshortcuts widgets processing: %s" % playlist_path) media_array = kodi_json('Files.GetDirectory', {"directory": playlist_path, "media": "files"}) for item in media_array: if item["file"].endswith(".xsp"): playlist = item["file"] contents = xbmcvfs.File(item["file"], 'r') contents_data = contents.read().decode('utf-8') contents.close() xmldata = xmltree.fromstring(contents_data.encode('utf-8')) media_type = "" label = item["label"] for line in xmldata.getiterator(): if line.tag == "smartplaylist": media_type = line.attrib['type'] if line.tag == "name": label = line.text try: languageid = int(label) label = xbmc.getLocalizedString(languageid) except Exception: pass if not media_type: mutils = MetadataUtils() media_type = mutils.detect_plugin_content(playlist) del mutils widgets.append([label, playlist, media_type]) return widgets
def plugin_widgetlisting(pluginpath, sublevel=""): """get all nodes in a plugin listing""" widgets = [] if sublevel: media_array = kodi_json('Files.GetDirectory', { "directory": pluginpath, "media": "files" }) else: if not getCondVisibility("System.HasAddon(%s)" % pluginpath): return [] media_array = kodi_json('Files.GetDirectory', { "directory": "plugin://%s" % pluginpath, "media": "files" }) for item in media_array: log_msg("skinshortcuts widgets processing: %s" % (item["file"])) content = item["file"] label = item["label"] # extendedinfo has some login-required widgets, skip those if ("script.extendedinfo" in pluginpath and not EXTINFO_CREDS and ("info=starred" in content or "info=rated" in content or "info=account" in content)): continue if item.get("filetype", "") == "file": continue mutils = MetadataUtils() media_type = mutils.detect_plugin_content(item["file"]) del mutils if media_type == "empty": continue if media_type == "folder": content = "plugin://script.skin.helper.service?action=widgets&path=%s&sublevel=%s" % ( urlencode(item["file"]), label) # add reload param for widgets if "reload=" not in content: if "movies" in content: reloadstr = "&reload=$INFO[Window(Home).Property(widgetreload-movies)]" elif "episodes" in content: reloadstr = "&reload=$INFO[Window(Home).Property(widgetreload-episodes)]" elif "tvshows" in content: reloadstr = "&reload=$INFO[Window(Home).Property(widgetreload-tvshows)]" elif "musicvideos" in content: reloadstr = "&reload=$INFO[Window(Home).Property(widgetreload-musicvideos)]" elif "albums" in content or "songs" in content or "artists" in content: reloadstr = "&reload=$INFO[Window(Home).Property(widgetreload-music)]" else: reloadstr = "&reload=$INFO[Window(Home).Property(widgetreload)]"\ "$INFO[Window(Home).Property(widgetreload2)]" content = content + reloadstr content = content.replace("&limit=100", "&limit=25") widgets.append([label, content, media_type]) if pluginpath == "script.extendedinfo" and not sublevel: # some additional entrypoints for extendedinfo... widgets += extendedinfo_youtube_widgets() return widgets