Ejemplo n.º 1
0
def build_labels(source, path_def=None, target=""):
    if source == "context" and not path_def and not target:
        content = utils.get_infolabel("Container.Content")
        labels = {
            "label": utils.get_infolabel("ListItem.Label"),
            "content": content if content else "videos",
        }

        path_def = {
            "file":
            utils.get_infolabel("ListItem.FolderPath"),
            "filetype":
            "directory"
            if utils.get_condition("Container.ListItem.IsFolder") else "file",
            "art": {},
        }  # would be fun to set some "placeholder" art here

        for i in utils.get_info_keys():
            info = utils.get_infolabel("ListItem.{}".format(i.capitalize()))
            if info and not info.startswith("ListItem"):
                path_def[i] = info

        for i in utils.art_types:
            art = utils.get_infolabel("ListItem.Art({})".format(i))
            if art:
                path_def["art"][i] = utils.clean_artwork_url(art)
        for i in ["icon", "thumb"]:
            art = utils.clean_artwork_url(
                utils.get_infolabel("ListItem.{}".format(i)))
            if art:
                path_def["art"][i] = art
    elif source == "json" and path_def and target:
        labels = {
            "label": path_def["label"],
            "content": "videos",
            "target": target
        }

    labels["file"] = (path_def if path_def else {
        key: path_def[key]
        for key in path_def if path_def[key]
    })
    path = labels["file"]["file"]

    if path != "addons://user/":
        path = path.replace("addons://user/", "plugin://")
    if "plugin://plugin.video.themoviedb.helper" in path and not "&widget=True" in path:
        path += "&widget=True"
    labels["file"]["file"] = path

    labels["color"] = settings.get_setting_string("ui.color")

    for _key in utils.windows:
        if any(i in path for i in utils.windows[_key]):
            labels["window"] = _key

    return labels
Ejemplo n.º 2
0
def build_labels(source, path_def=None, target=''):
    if source == 'context' and not path_def and not target:
        labels = {'label': utils.get_infolabel('ListItem.Label'),
                  'content': utils.get_infolabel('Container.Content')}
        
        path_def = {'file': utils.get_infolabel('ListItem.FolderPath'),
                    'filetype': 'directory' if utils.get_condition('Container.ListItem.IsFolder') else 'file',
                    'art': {}}  # would be fun to set some "placeholder" art here

        for i in utils.info_types:
            info = utils.get_infolabel('ListItem.{}'.format(i.capitalize()))
            if info and not info.startswith('ListItem'):
                path_def[i] = info

        for i in utils.art_types:
            art = utils.get_infolabel('ListItem.Art({})'.format(i))
            if art:
                path_def['art'][i] = utils.clean_artwork_url(art)
        for i in ['icon', 'thumb']:
            art = utils.clean_artwork_url(utils.get_infolabel('ListItem.{}'.format(i)))
            if art:
                path_def['art'][i] = art
    elif source == 'json' and path_def and target:
        labels = {'label': path_def['label'],
                  'content': '',
                  'target': target}

    labels['file'] = path_def if path_def else {key: path_def[key] for key in path_def if path_def[key]}
    path = labels['file']['file']

    if path != 'addons://user/':
        path = path.replace('addons://user/', 'plugin://')
    if 'plugin://plugin.video.themoviedb.helper' in path and not '&widget=True' in path:
        path += '&widget=True'            
    labels['file']['file'] = path

    labels['color'] = utils.get_setting('ui.color')

    for _key in utils.windows:
        if any(i in path for i in utils.windows[_key]):
            labels['window'] = _key

    return labels