def download_torrent(url):
    client = container.torrent_client()
    client.add(container.torrent(url), save_path(local=True))
    if isinstance(client, TransmissionClient):
        name = 'Transmission'
        addon_id = 'script.transmission'
    elif isinstance(client, UTorrentClient):
        name = 'UTorrent'
        addon_id = 'plugin.program.utorrent'
    else:
        return

    if xbmcgui.Dialog().yesno(lang(40316), *(lang(40317) % name).split("|")):
        xbmc.executebuiltin('XBMC.RunAddon(%s)' % addon_id)
def download_torrent_context_menu(url):
    if container.torrent_client() and url:
        return [(lang(40314), actions.background(plugin.url_for('download_torrent', url=url)))]
    else:
        return []