Esempio n. 1
0
def add_context_menus_to_item(item,
                              item_id,
                              item_index,
                              menu_id,
                              menu_len,
                              is_playable=False,
                              item_infos={}):
    """Add basic context menus to the item

    Args:
        plugin (codequick.script.Script)
        item (codequick.listing.Listitem): Item for which we want to add context menus
        item_id (str): Id of the item
        item_index (int): Index of the item
        menu_id (str): Menu to get (e.g. root)
        menu_len (int): Length of the item menu
    """

    # Move up
    if item_index > 0:
        item.context.script(move_item,
                            Script.localize(30501),
                            direction='up',
                            item_id=item_id,
                            menu_id=menu_id)

    # Move down
    if item_index < menu_len - 1:
        item.context.script(move_item,
                            Script.localize(30500),
                            direction='down',
                            item_id=item_id,
                            menu_id=menu_id)

    # Hide
    item.context.script(hide_item,
                        Script.localize(30502),
                        item_id=item_id,
                        menu_id=menu_id)

    # delete_for_submission_start
    # Connect/Disconnect VPN
    add_vpn_context(item)
    # delete_for_submission_end

    # Add to add-on favourites
    item.context.script(fav.add_item_to_favourites,
                        Script.localize(30800),
                        is_playable=is_playable,
                        item_infos=item_infos)

    return
Esempio n. 2
0
def add_context_menus_to_item(plugin, item, index, menu_id, menu_len,
                              **kwargs):

    # Move up
    if index > 0:
        item.context.script(move_item,
                            plugin.localize(LABELS['Move up']),
                            direction='up',
                            item_id=item.params['item_id'],
                            menu_id=menu_id)

    # Move down
    if index < menu_len - 1:
        item.context.script(move_item,
                            plugin.localize(LABELS['Move down']),
                            direction='down',
                            item_id=item.params['item_id'],
                            menu_id=menu_id)

    # Hide
    item.context.script(hide_item,
                        plugin.localize(LABELS['Hide']),
                        item_id=item.params['item_id'])

    # Connect/Disconnect VPN
    add_vpn_context(item)

    # Add to add-on favourites
    is_playable = False
    if 'is_playable' in kwargs:
        is_playable = kwargs['is_playable']
    elif 'item_infos' in kwargs and \
            kwargs['item_infos']['callback'] == 'live_bridge':
        is_playable = True

    fav.add_fav_context(item,
                        item2dict(item),
                        is_playable=is_playable,
                        channel_infos=kwargs.get('channel_infos', None))

    return