CurseForge, GitHub: Update for TBCC.

This commit is contained in:
Casper V. Kristensen 2021-05-26 18:28:11 +02:00
parent e4618876dc
commit ce6e5f6eb7
Signed by: caspervk
GPG key ID: 289CA03790535054
2 changed files with 18 additions and 2 deletions

View file

@ -67,6 +67,7 @@ class CurseForge(Web):
def _get_latest_file_url(cls, addon: Addon) -> str: def _get_latest_file_url(cls, addon: Addon) -> str:
info = cls._get_curse_addon_info(addon) info = cls._get_curse_addon_info(addon)
for file in info["latestFiles"]: for file in info["latestFiles"]:
if file["gameVersionFlavor"] == "wow_classic" and file["releaseType"] == 1: # 1: release, 2: beta, 3: alpha # releaseTypes: 1: release, 2: beta, 3: alpha
if file["gameVersionFlavor"] == "wow_burning_crusade" and file["releaseType"] == 1:
return file["downloadUrl"] return file["downloadUrl"]
raise FileNotFoundError("No file found") raise FileNotFoundError("No file found")

View file

@ -28,7 +28,22 @@ class GitHub(Web):
latest_release = http.open( latest_release = http.open(
url=f"{cls.api_url}/repos/{repo_owner}/{repo_name}/releases/latest" url=f"{cls.api_url}/repos/{repo_owner}/{repo_name}/releases/latest"
).json() ).json()
for asset in sorted(latest_release["assets"], key=lambda a: "classic" in a["name"].lower(), reverse=True):
asset_priorities = [
r"[._-]bcc[._-]",
r"[._-]bc[._-]",
r"[._-]tbc[._-]",
r"[._-]classic[._-]",
r".*",
]
for asset in sorted(
latest_release["assets"],
key=lambda a: next(
i
for i, ap in enumerate(asset_priorities)
if re.search(ap, a["name"], flags=re.IGNORECASE)
)
):
if Path(asset["name"]).suffix == ".zip": if Path(asset["name"]).suffix == ".zip":
return super().download(addon, asset["browser_download_url"]) return super().download(addon, asset["browser_download_url"])
raise FileNotFoundError("No zip file found for latest release") raise FileNotFoundError("No zip file found for latest release")