Skip to content

Commit

Permalink
Tweaked WoWI parser
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Jul 1, 2020
1 parent 4f98452 commit 3d5cc8f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def parse_url(self, url):
'wow' if url in self.config['IgnoreClientVersion'].keys() else self.clientType,
self.check_if_dev(url))
elif url.startswith('https://www.wowinterface.com/downloads/'):
return WoWInterfaceAddon(url, self.wowiCache, self.scraper)
return WoWInterfaceAddon(url, self.wowiCache)
elif url.startswith('https://www.tukui.org/addons.php?id='):
if self.clientType == 'wow_classic':
raise RuntimeError('Incorrect client version.')
Expand Down
11 changes: 6 additions & 5 deletions CB/WoWInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
import io
import re
import zipfile
from . import retry
import requests
from . import retry, HEADERS


class WoWInterfaceAddon:
@retry()
def __init__(self, url, checkcache, scraper):
def __init__(self, url, checkcache):
project = re.findall(r'\d+', url)[0]
self.scraper = scraper
if project in checkcache:
self.payload = checkcache[project]
else:
self.payload = self.scraper.get(f'https://api.mmoui.com/v4/game/WOW/filedetails/{project}.json').json()
self.payload = requests.get(f'https://api.mmoui.com/v4/game/WOW/filedetails/{project}.json',
headers=HEADERS).json()
if 'ERROR' in self.payload:
raise RuntimeError(url)
else:
Expand All @@ -26,7 +27,7 @@ def __init__(self, url, checkcache, scraper):

@retry()
def get_addon(self):
self.archive = zipfile.ZipFile(io.BytesIO(self.scraper.get(self.downloadUrl).content))
self.archive = zipfile.ZipFile(io.BytesIO(requests.get(self.downloadUrl, headers=HEADERS).content))
for file in self.archive.namelist():
if '/' not in os.path.dirname(file):
self.directories.append(os.path.dirname(file))
Expand Down
2 changes: 1 addition & 1 deletion CB/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import random
from rich.terminal_theme import TerminalTheme

__version__ = '3.4.1'
__version__ = '3.4.2'
__license__ = 'GPLv3'
__copyright__ = '2019-2020, Paweł Jastrzębski <[email protected]>'
__docformat__ = 'restructuredtext en'
Expand Down

0 comments on commit 3d5cc8f

Please sign in to comment.