Beispiel #1
0
def refresh_paths(notify=False, force=False):
    if notify:
        dialog = xbmcgui.Dialog()
        dialog.notification('AutoWidget', utils.get_string(32033),
                            sound=utils.get_setting_bool('service.refresh_sound'))

    for group_def in manage.find_defined_groups():
        paths = []

        widgets = manage.find_defined_widgets(group_def['id'])
        for widget_def in widgets:
            paths = refresh(widget_def['id'], widget_def=widget_def, paths=paths, force=force)

    utils.update_container(True)

    return True, 'AutoWidget'
    def _refresh(self, startup=False):
        if self.refresh_enabled in [0, 1] and manage.find_defined_widgets():
            notification = False
            if self.refresh_enabled == 1:
                if self.player.isPlayingVideo():
                    utils.log(
                        '+++++ PLAYBACK DETECTED, SKIPPING AUTOWIDGET REFRESH +++++',
                        'info')
                    return
            else:
                if self.refresh_notification == 0:
                    notification = True
                elif self.refresh_notification == 1:
                    if not self.player.isPlayingVideo():
                        notification = True

            utils.log('+++++ REFRESHING AUTOWIDGETS +++++', 'info')
            refresh_paths(notify=notification and not startup)
        else:
            utils.log('+++++ AUTOWIDGET REFRESHING NOT ENABLED +++++', 'info')
Beispiel #3
0
def refresh_paths(notify=False, force=False):
    if notify:
        dialog = xbmcgui.Dialog()
        dialog.notification(
            "AutoWidget",
            utils.get_string(30020),
            sound=settings.get_setting_bool("service.refresh_sound"),
        )
        del dialog

    for group_def in manage.find_defined_groups():
        paths = []

        widgets = manage.find_defined_widgets(group_def["id"])
        for widget_def in widgets:
            paths = refresh(
                widget_def["id"], widget_def=widget_def, paths=paths, force=force
            )

    utils.update_container(True)

    return True, "AutoWidget"
def refresh_paths(notify=False, force=False):
    converted = []
    current_time = time.time()

    if force:
        converted = convert.convert_widgets(notify)

    if notify:
        dialog = xbmcgui.Dialog()
        dialog.notification('AutoWidget', utils.get_string(32033))

    for group_def in manage.find_defined_groups():
        paths = []

        widgets = manage.find_defined_widgets(group_def['id'])
        for widget_def in widgets:
            paths = refresh(widget_def['id'],
                            widget_def=widget_def,
                            paths=paths,
                            force=force)

    utils.update_container(reload=len(converted) > 0 and utils.shortcuts_path)
Beispiel #5
0
 def _clean_widgets(self):
     for widget_def in manage.find_defined_widgets():
         if not manage.clean(widget_def["id"]):
             utils.log("Resetting {}".format(widget_def["id"]))
             update_path(widget_def["id"], "reset")
Beispiel #6
0
def active_widgets_menu():
    manage.clean()
    widgets = sorted(manage.find_defined_widgets(),
                     key=lambda x: x.get('updated'),
                     reverse=True)

    if len(widgets) > 0:
        for widget_def in widgets:
            widget_id = widget_def.get('id', '')
            action = widget_def.get('action', '')
            group = widget_def.get('group', '')
            path_def = widget_def.get('path', {})

            group_def = manage.get_group_by_id(group)

            title = ''
            if path_def and group_def:
                try:
                    if action != 'merged':
                        if isinstance(path_def, dict):
                            label = path_def['label'].encode('utf-8')
                        else:
                            label = widget_def['stack'][0]['label'].encode(
                                'utf-8')
                        group_def['label'] = group_def['label'].encode('utf-8')
                    else:
                        label = utils.get_string(32128).format(len(path_def))
                except:
                    pass

                title = '{} - {}'.format(label, group_def['label'])
            elif group_def:
                title = group_def.get('label')

            art = {}
            params = {}
            cm = []
            if not action:
                art = folder_shortcut
                title = utils.get_string(32030).format(title)
            else:
                if action in ['random', 'next']:
                    art = shuffle
                    cm.append((utils.get_string(32069),
                               ('RunPlugin('
                                'plugin://plugin.program.autowidget/'
                                '?mode=refresh'
                                '&id={})').format(widget_id)))
                elif action == 'merged':
                    art = merge
                elif action == 'static':
                    art = utils.get_art('folder')

            cm.append((utils.get_string(32070),
                       ('RunPlugin('
                        'plugin://plugin.program.autowidget/'
                        '?mode=manage'
                        '&action=edit_widget'
                        '&id={})').format(widget_id)))

            if not group_def:
                title = '{} - [COLOR firebrick]{}[/COLOR]'.format(
                    widget_id, utils.get_string(32071))

            directory.add_menu_item(title=title,
                                    art=art,
                                    params={
                                        'mode': 'group',
                                        'group': group
                                    },
                                    cm=cm[1:] if not action else cm,
                                    isFolder=True)
    else:
        directory.add_menu_item(title=32072,
                                art=utils.get_art('alert'),
                                isFolder=False,
                                props={'specialsort': 'bottom'})

    return True, utils.get_string(32074)
 def _clean_widgets(self):
     for widget_def in manage.find_defined_widgets():
         if not manage.clean(widget_def['id']):
             utils.log('Resetting {}'.format(widget_def['id']))
             update_path(widget_def['id'], None, 'reset')
def active_widgets_menu():
    widgets = manage.find_defined_widgets()

    if len(widgets) > 0:
        for widget_def in widgets:
            _id = widget_def.get('id', '')
            action = widget_def.get('action', '')
            group = widget_def.get('group', '')
            path = widget_def.get('path', '')
            updated = widget_def.get('updated', '')

            path_def = manage.get_path_by_id(path, group)
            group_def = manage.get_group_by_id(group)

            title = ''
            if path_def and group_def:
                try:
                    path_def['label'] = path_def['label'].encode('utf-8')
                    group_def['label'] = group_def['label'].encode('utf-8')
                except:
                    pass

                title = '{} - {}'.format(path_def['label'], group_def['label'])
            elif group_def:
                title = group_def.get('label')

            art = {}
            params = {}
            if not action:
                art = folder_shortcut
                params = {
                    'mode': 'group',
                    'group': group,
                    'target': 'shortcut',
                    'id': six.text_type(_id)
                }
                title = utils.get_string(32030).format(title)
            elif action in ['random', 'next']:
                art = folder_sync if action == 'random' else folder_next
                params = {
                    'mode': 'group',
                    'group': group,
                    'target': 'widget',
                    'id': six.text_type(_id)
                }

            cm = [(utils.get_string(32069),
                   ('RunPlugin('
                    'plugin://plugin.program.autowidget/'
                    '?mode=refresh'
                    '&target={})').format(_id)),
                  (utils.get_string(32070),
                   ('RunPlugin('
                    'plugin://plugin.program.autowidget/'
                    '?mode=manage'
                    '&action=edit_widget'
                    '&target={})').format(_id))]

            if not group_def:
                title = '{} - [COLOR firebrick]{}[/COLOR]'.format(
                    _id, utils.get_string(32071))

            directory.add_menu_item(title=title,
                                    art=art,
                                    params=params,
                                    cm=cm[1:] if not action else cm,
                                    isFolder=True)
    else:
        directory.add_menu_item(title=32072, art=alert, isFolder=False)

    return True, utils.get_string(32074)