I found addons.download_addons but i’m not sure I can use it to download an addon from an other. ^^
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import annotations
import io
import json
import os
import re
import zipfile
from collections import defaultdict
from concurrent.futures import Future
from dataclasses import dataclass
from datetime import datetime
from typing import IO, Any, Callable, Iterable, Union
from urllib.parse import parse_qs, urlparse
from zipfile import ZipFile
import jsonschema
import markdown
from jsonschema.exceptions import ValidationError
This file has been truncated. show original
def download_addons(
parent: QWidget,
mgr: AddonManager,
ids: list[int],
on_done: Callable[[list[DownloadLogEntry]], None],
client: HttpClient | None = None,
)
How to use this in an addon ?
abdo
November 25, 2021, 9:04am
2
Try something like this:
from aqt.addons import download_addons
def on_done(info):
print(info)
download_addons(mw, mw.addonManager, [2084557901], on_done)
See anki/addons.py at ebad6ad3793ece9f27aed13a870ae65a966a27f3 · ankitects/anki · GitHub for details about the info passed to on_done
.
1 Like
Thanks for your answer , it helped a lot !
So it’s better but seem, I’m having an issue lol
from aqt import mw
from aqt.addons import download_addons
def on_done(info):
print(info)
download_addons(mw, mw.addonManager, [2055492159], on_done)
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import annotations
import time
import aqt.forms
from aqt.qt import *
from aqt.utils import disable_help_button, tr
# Progress info
##########################################################################
class ProgressManager:
def __init__(self, mw: aqt.AnkiQt) -> None:
self.mw = mw
self.app = mw.app
self.inDB = False
self.blockUpdates = False
This file has been truncated. show original
Can’t do that at the start of anki, that was the problem.
abdo
November 25, 2021, 8:22pm
5
Maybe you can work around this by using a hook like main_window_did_init
3 Likes