Skip to content

Commit

Permalink
Added preliminary Wrath of the Lich King Classic support (close #340)
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Jul 14, 2022
1 parent c8a0e8b commit 31f7f41
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 23 deletions.
26 changes: 18 additions & 8 deletions CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def cleanup(self, directories):
for directory in directories:
shutil.rmtree(self.path / directory, ignore_errors=True)

# TODO Cleanup after WOTLK Beta
def parse_url(self, url):
if url.startswith('https://addons.wago.io/addons/'):
return WagoAddonsAddon(url, self.wagoCache, 'retail' if url in self.config['IgnoreClientVersion'].keys()
Expand All @@ -190,19 +191,19 @@ def parse_url(self, url):
return WoWInterfaceAddon(url, self.wowiCache)
elif url.startswith('https://www.tukui.org/addons.php?id='):
if self.clientType != 'retail':
raise RuntimeError('Incorrect client version.')
raise RuntimeError('Unsupported client version.')
self.bulk_tukui_check()
return TukuiAddon(url, self.tukuiCache)
elif url.startswith('https://www.tukui.org/classic-addons.php?id='):
if self.clientType != 'classic':
raise RuntimeError('Incorrect client version.')
raise RuntimeError('Unsupported client version.')
elif url.endswith('=1') or url.endswith('=2'):
raise RuntimeError('ElvUI and Tukui cannot be installed this way.')
self.bulk_tukui_check()
return TukuiAddon(url, self.tukuiCache)
elif url.startswith('https://www.tukui.org/classic-tbc-addons.php?id='):
if self.clientType != 'bc':
raise RuntimeError('Incorrect client version.')
raise RuntimeError('Unsupported client version.')
elif url.endswith('=1') or url.endswith('=2'):
raise RuntimeError('ElvUI and Tukui cannot be installed this way.')
self.bulk_tukui_check()
Expand All @@ -212,29 +213,37 @@ def parse_url(self, url):
elif url.lower() == 'elvui':
if self.clientType == 'retail':
return TukuiAddon('ElvUI', self.tukuiCache, 'elvui')
elif self.clientType == 'wotlk':
raise RuntimeError('Unsupported client version.')
else:
self.bulk_tukui_check()
return TukuiAddon('2', self.tukuiCache)
elif url.lower() == 'elvui:dev':
return GitHubAddonRaw('tukui-org/ElvUI', 'development', ['ElvUI', 'ElvUI_OptionsUI'],
self.config['GHAPIKey'])
if self.clientType == 'wotlk':
return GitHubAddonRaw('tukui-org/ElvUI', 'wrath_beta', ['ElvUI', 'ElvUI_OptionsUI'],
self.config['GHAPIKey'])
else:
return GitHubAddonRaw('tukui-org/ElvUI', 'development', ['ElvUI', 'ElvUI_OptionsUI'],
self.config['GHAPIKey'])
elif url.lower() == 'tukui':
if self.clientType == 'retail':
return TukuiAddon('Tukui', self.tukuiCache, 'tukui')
elif self.clientType == 'wotlk':
raise RuntimeError('Unsupported client version.')
else:
self.bulk_tukui_check()
return TukuiAddon('1', self.tukuiCache)
elif url.lower() == 'tukui:dev':
if self.clientType == 'retail' or self.clientType == 'bc':
if self.clientType != 'wotlk':
return GitHubAddonRaw('tukui-org/Tukui', 'Live', ['Tukui'], self.config['GHAPIKey'])
else:
return GitHubAddonRaw('tukui-org/Tukui', 'Live-Classic-Era', ['Tukui'], self.config['GHAPIKey'])
raise RuntimeError('Unsupported client version.')
elif url.lower() == 'shadow&light:dev':
if self.clientType == 'retail':
return GitHubAddonRaw('Shadow-and-Light/shadow-and-light', 'dev', ['ElvUI_SLE'],
self.config['GHAPIKey'])
else:
raise RuntimeError('Incorrect client version.')
raise RuntimeError('Unsupported client version.')
elif url.startswith('https://www.townlong-yak.com/addons/'):
raise RuntimeError(f'{url}\nTownlong Yak is no longer supported by this application.')
elif url.startswith('https://www.curseforge.com/wow/addons/'):
Expand Down Expand Up @@ -570,6 +579,7 @@ def bulk_check(self, addons):
# for addon in payload['addons']:
# self.wagoCache[addon] = payload['addons'][addon]

# TODO Cleanup after WOTLK Beta
@retry(custom_error='Failed to parse Tukui API data')
def bulk_tukui_check(self):
if not self.tukuiCache:
Expand Down
17 changes: 14 additions & 3 deletions CB/GitHub.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def get_latest_package(self):
targetflavor = 'classic'
elif self.clientType == 'bc':
targetflavor = 'bcc'
elif self.clientType == 'wotlk':
targetflavor = 'wrath'
else:
targetflavor = 'mainline'
for release in self.metadata['releases']:
Expand Down Expand Up @@ -99,24 +101,31 @@ def get_latest_package(self):
latest = None
latestclassic = None
latestbc = None
latestwrath = None
for release in self.payloads[self.releaseDepth]['assets']:
if release['name'] and '-nolib' not in release['name'] \
and release['content_type'] in {'application/x-zip-compressed', 'application/zip'}:
if not latest and not release['name'].endswith('-classic.zip') and \
not release['name'].endswith('-bc.zip') and not release['name'].endswith('-bcc.zip'):
not release['name'].endswith('-bc.zip') and not release['name'].endswith('-bcc.zip') and \
not release['name'].endswith('-wrath.zip'):
latest = release['browser_download_url']
elif not latestclassic and release['name'].endswith('-classic.zip'):
latestclassic = release['browser_download_url']
elif not latestbc and (release['name'].endswith('-bc.zip') or release['name'].endswith('-bcc.zip')):
latestbc = release['browser_download_url']
elif not latestwrath and release['name'].endswith('-wrath.zip'):
latestwrath = release['browser_download_url']
if (self.clientType == 'retail' and latest) \
or (self.clientType == 'classic' and latest and not latestclassic) \
or (self.clientType == 'bc' and latest and not latestbc):
or (self.clientType == 'bc' and latest and not latestbc) \
or (self.clientType == 'wotlk' and latest and not latestwrath):
self.downloadUrl = latest
elif self.clientType == 'classic' and latestclassic:
self.downloadUrl = latestclassic
elif self.clientType == 'bc' and latestbc:
self.downloadUrl = latestbc
elif self.clientType == 'wotlk' and latestwrath:
self.downloadUrl = latestwrath
else:
self.releaseDepth += 1
self.parse()
Expand Down Expand Up @@ -146,7 +155,9 @@ def __init__(self, project, branch, targetdirs, apikey):
headers=HEADERS, auth=APIAuth('token', self.apiKey), timeout=5)
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
raise RuntimeError(f'{project}\nGitHub API failed to respond.')
if self.payload.status_code == 403:
if self.payload.status_code == 401:
raise RuntimeError(f'{project}\nIncorrect or expired GitHub API personal access token.')
elif self.payload.status_code == 403:
raise RuntimeError(f'{project}\nGitHub API rate limit exceeded. Try later or provide personal access '
f'token.')
elif self.payload.status_code == 404:
Expand Down
2 changes: 1 addition & 1 deletion CB/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import requests
from rich.terminal_theme import TerminalTheme

__version__ = '4.0.1'
__version__ = '4.1.0'
__license__ = 'GPLv3'
__copyright__ = '2019-2022, Paweł Jastrzębski <[email protected]>'
__docformat__ = 'restructuredtext en'
Expand Down
3 changes: 3 additions & 0 deletions CurseBreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def start(self):
flavor = os.path.basename(os.getcwd())
if flavor in {'_retail_', '_ptr_'}:
self.core.clientType = 'retail'
elif flavor in {'_classic_beta_'}:
self.core.clientType = 'wotlk'
set_terminal_title(f'CurseBreaker v{__version__} - Wrath of the Lich King')
elif flavor in {'_classic_', '_classic_ptr_'}:
self.core.clientType = 'bc'
set_terminal_title(f'CurseBreaker v{__version__} - Burning Crusade')
Expand Down
22 changes: 11 additions & 11 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 31f7f41

Please sign in to comment.