CurseForge: Prefer classic AddOns instead of ignoring retail ones.

This commit is contained in:
Casper V. Kristensen 2021-05-26 23:49:00 +02:00
parent 2fd7640a9e
commit 1f3bbbde28
Signed by: caspervk
GPG key ID: 289CA03790535054

View file

@ -66,8 +66,19 @@ class CurseForge(Web):
@classmethod
def _get_latest_file_url(cls, addon: Addon) -> str:
info = cls._get_curse_addon_info(addon)
for file in info["latestFiles"]:
# releaseTypes: 1: release, 2: beta, 3: alpha
if file["gameVersionFlavor"] == "wow_burning_crusade" and file["releaseType"] == 1:
return file["downloadUrl"]
flavor_priorities = [
"wow_burning_crusade",
"wow_classic",
"wow_retail",
]
files = sorted(
info["latestFiles"],
key=lambda f: (
flavor_priorities.index(f["gameVersionFlavor"]),
f["releaseType"] # releaseType: 1: release, 2: beta, 3: alpha
),
)
try:
return files[0]["downloadUrl"]
except IndexError:
raise FileNotFoundError("No file found")