Add TukUI AddOn provider
This commit is contained in:
parent
d2c7c020ab
commit
0086cb798c
2 changed files with 32 additions and 0 deletions
|
@ -2,6 +2,7 @@ from .base import Provider
|
|||
from .curseforge import CurseForge
|
||||
from .git import Git
|
||||
from .github import GitHub
|
||||
from .tukui import TukUI
|
||||
from .web import Web
|
||||
from .wowinterface import WowInterface
|
||||
|
||||
|
@ -9,6 +10,7 @@ from .wowinterface import WowInterface
|
|||
PROVIDERS = { # in order of preference
|
||||
"curse": CurseForge,
|
||||
"wowinterface": WowInterface,
|
||||
"tukui": TukUI,
|
||||
"github": GitHub,
|
||||
"git": Git,
|
||||
"web": Web
|
||||
|
|
30
wau/providers/tukui.py
Executable file
30
wau/providers/tukui.py
Executable file
|
@ -0,0 +1,30 @@
|
|||
import logging
|
||||
|
||||
from .web import Web
|
||||
from .. import http
|
||||
from ..addons import Addon
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TukUI(Web):
|
||||
api_url = "https://www.tukui.org/api.php?classic-wotlk-addons"
|
||||
|
||||
@classmethod
|
||||
def is_supported(cls, url: str) -> bool:
|
||||
return "tukui.org" in url
|
||||
|
||||
@classmethod
|
||||
def download(cls, addon: Addon, url: str = None) -> bool:
|
||||
file_url = cls._get_file_url(addon)
|
||||
return super().download(addon, url=file_url)
|
||||
|
||||
@classmethod
|
||||
def _get_file_url(self, addon: Addon) -> str:
|
||||
logger.debug("Getting all AddOns info from TukUI")
|
||||
# Find the given AddOn URL in the list of all TukUI AddOns
|
||||
tukui_addons = http.open(self.api_url).json()
|
||||
for tukui_addon in tukui_addons:
|
||||
if tukui_addon["web_url"] == addon.url:
|
||||
return tukui_addon["url"]
|
||||
raise ValueError("AddOn not found in TukUI AddOns.")
|
Loading…
Reference in a new issue