From 1f3bbbde287da3f51d87eae0c16671a993e3b5e7 Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Wed, 26 May 2021 23:49:00 +0200 Subject: [PATCH] CurseForge: Prefer classic AddOns instead of ignoring retail ones. --- wau/providers/curseforge.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/wau/providers/curseforge.py b/wau/providers/curseforge.py index 415d185..c9a365a 100644 --- a/wau/providers/curseforge.py +++ b/wau/providers/curseforge.py @@ -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"] - raise FileNotFoundError("No file found") + 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")