def add_group(target, group_name=""): dialog = xbmcgui.Dialog() group_name = dialog.input(heading=utils.get_string(30023), defaultt=group_name) group_id = "" if group_name: group_id = utils.get_unique_id(group_name) filename = os.path.join(_addon_data, "{}.group".format(group_id)) group_def = { "label": group_name, "type": target, "paths": [], "id": group_id, "art": folder_sync if target == "widget" else folder_shortcut, "version": settings.get_addon_info("version"), "content": None, } utils.write_json(filename, group_def) else: dialog.notification("AutoWidget", utils.get_string(30024)) del dialog return group_id
def _add_path(group_def, labels, over=False): if not over: if group_def["type"] == "shortcut": heading = utils.get_string(30028) elif group_def["type"] == "widget": heading = utils.get_string(30029) dialog = xbmcgui.Dialog() labels["label"] = dialog.input(heading=heading, defaultt=labels["label"]) del dialog labels["id"] = utils.get_unique_id(labels["label"]) labels["version"] = settings.get_addon_info("version") if labels["target"] == "settings": labels["file"]["filetype"] = "file" labels["file"]["file"] = labels["file"]["file"].split("&")[0] elif labels["target"] == "shortcut" and labels["file"]["filetype"] == "file": labels["content"] = None manage.write_path(group_def, path_def=labels)
def initialize(group_def, action, widget_id, save=True, keep=None): duration = settings.get_setting_float("service.refresh_duration") paths = group_def.get("paths", []) path_def = [] cycle_paths = [] path_idx = 0 if action != "merged": if action == "static" and keep is not None: path_def = paths[keep]["id"] elif action in ["random", "next"]: if keep is None: path_idx = random.randrange( len(paths)) if action == "random" else 0 else: path_idx = (keep[random.randrange(len(keep))] if action == "random" else keep[0]) for idx in keep: cycle_paths.append(paths[idx]["id"]) path_def = paths[path_idx]["id"] elif action == "merged" and keep: for idx in keep: path_def.append(paths[idx]["id"]) params = { "action": action, "id": widget_id, "group": group_def["id"], "refresh": duration, "path": path_def, "version": settings.get_addon_info("version"), "current": path_idx, } if cycle_paths: params["cycle_paths"] = cycle_paths if save: save_path_details(params) return params
import xbmc import xbmcgui import os import random import time import threading from resources.lib import manage from resources.lib.common import cache from resources.lib.common import settings from resources.lib.common import utils _addon_data = utils.translate_path(settings.get_addon_info("profile")) skin_string_pattern = "autowidget-{}-{}" _properties = ["context.autowidget"] _thread = None class RefreshService(xbmc.Monitor): def __init__(self): """Starts all of the actions of AutoWidget's service.""" super(RefreshService, self).__init__() utils.log("+++++ STARTING AUTOWIDGET SERVICE +++++", "info") self.player = Player() utils.ensure_addon_data() self._update_properties() self._clean_widgets()
import six from PIL import Image from resources.lib.common import settings try: from urllib.parse import unquote except ImportError: from urlparse import unquote try: translate_path = xbmcvfs.translatePath except AttributeError: translate_path = xbmc.translatePath _addon_id = settings.get_addon_info("id") _addon_data = translate_path(settings.get_addon_info("profile")) _addon_root = translate_path(settings.get_addon_info("path")) _art_path = os.path.join(_addon_root, "resources", "media") _home = translate_path("special://home/") windows = { "programs": ["program", "script"], "addonbrowser": ["addon", "addons"], "music": ["audio", "music"], "pictures": ["image", "picture"], "videos": ["video", "videos"], } art_types = [
import xbmcgui import os import random from resources.lib.common import settings from resources.lib.common import utils _addon_data = utils.translate_path(settings.get_addon_info("profile")) _userdata = utils.translate_path("special://userdata/") _skin_shortcuts = utils.translate_path( settings.get_addon_info("profile", addon="script.skinshortcuts")) def clean(widget_id=None, notify=False, all=False): if all: for widget in find_defined_widgets(): clean(widget_id=widget["id"]) return find_defined_widgets() files = [] dialog = xbmcgui.Dialog() params = { "jsonrpc": "2.0", "id": 1, "method": "Addons.GetAddons", "params": { "type": "xbmc.gui.skin" }, }