Skip to content

Commit

Permalink
GitHub: TBC support
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed May 17, 2021
1 parent 708ab83 commit 19293e5
Showing 1 changed file with 55 additions and 17 deletions.
72 changes: 55 additions & 17 deletions CB/GitHub.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,67 @@ def __init__(self, url, clienttype):
self.changelogUrl = self.payload['html_url']
self.archive = None
self.dependencies = None
self.metadata = None
self.directories = []
self.author = [project.split('/')[0]]
self.parse_metadata()
self.get_latest_package()

def get_latest_package(self):
latest = None
latestclassic = None
def parse_metadata(self):
for release in self.payload['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'):
latest = release['browser_download_url']
elif not latestclassic and release['name'].endswith('-classic.zip') and \
not release['name'].endswith('-bc.zip'):
latestclassic = release['browser_download_url']
if (self.clientType == 'wow_retail' and latest) or (self.clientType == 'wow_classic' and latest
and not latestclassic):
self.downloadUrl = latest
elif self.clientType == 'wow_classic' and latestclassic:
self.downloadUrl = latestclassic
if release['name'] and release['name'] == 'release.json':
self.metadata = requests.get(release['browser_download_url'], headers=HEADERS, timeout=5).json()
break

def get_latest_package(self):
if self.metadata:
targetfile = None
if self.clientType == 'wow_classic':
targetflavor = 'classic'
elif self.clientType == 'wow_burning_crusade':
targetflavor = 'bcc'
else:
targetflavor = 'mainline'
for release in self.metadata['releases']:
if not release['nolib']:
for flavor in release['metadata']:
if flavor['flavor'] == targetflavor:
targetfile = release['filename']
break
if targetfile:
break
if not targetfile:
raise RuntimeError(f'{self.name}.\nFailed to find release for your client version.')
for release in self.payload['assets']:
if release['name'] and release['name'] == targetfile:
self.downloadUrl = release['browser_download_url']
break
if not self.downloadUrl:
raise RuntimeError(f'{self.name}.\nFailed to find release for your client version.')
else:
raise RuntimeError(f'{self.name}.\nFailed to find release for your client version.')
latest = None
latestclassic = None
latestbc = None
for release in self.payload['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'):
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'):
latestbc = release['browser_download_url']
if (self.clientType == 'wow_retail' and latest) \
or (self.clientType == 'wow_classic' and latest and not latestclassic) \
or (self.clientType == 'wow_burning_crusade' and latest and not latestbc):
self.downloadUrl = latest
elif self.clientType == 'wow_classic' and latestclassic:
self.downloadUrl = latestclassic
elif self.clientType == 'wow_burning_crusade' and latestbc:
self.downloadUrl = latestbc
else:
raise RuntimeError(f'{self.name}.\nFailed to find release for your client version.')

@retry()
def get_addon(self):
Expand Down

0 comments on commit 19293e5

Please sign in to comment.