From 33ad64f0a49b5ed65e62b96cd1011f0ba46a3d79 Mon Sep 17 00:00:00 2001 From: derrod Date: Thu, 28 Oct 2021 10:34:28 +0200 Subject: [PATCH] [core] Only fail if absolutely no base-url can be found Overrides without a known base-url should work. --- legendary/core.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/legendary/core.py b/legendary/core.py index 4baf0b1..43d7cb0 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -1145,8 +1145,9 @@ class LegendaryCore: else: resume_file = None - # Match EGS' behaviour and just use the first available URL - base_url = base_urls[0] + # Use user-specified base URL or preferred CDN first, otherwise fall back to + # EGS's behaviour of just selecting the first CDN in the list. + base_url = None if override_base_url: self.log.info(f'Overriding base URL with "{override_base_url}"') base_url = override_base_url @@ -1157,6 +1158,11 @@ class LegendaryCore: break else: self.log.warning(f'Preferred CDN "{preferred_cdn}" unavailable, using default selection.') + # Use first, fail if none known + if not base_url: + if not base_urls: + raise ValueError('No base URLs found, please try again.') + base_url = base_urls[0] # The EGS client uses plaintext HTTP by default for the purposes of enabling simple DNS based # CDN redirection to a (local) cache. In Legendary this will be a config option.