Skip to content

Commit

Permalink
Added option to ignore client version check (close #24)
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Oct 11, 2019
1 parent ac6a666 commit 145a196
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
13 changes: 11 additions & 2 deletions CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def init_config(self):
else:
self.config = {'Addons': [],
'CurseCache': {},
'IgnoreClientVersion': {},
'Backup': {'Enabled': True, 'Number': 7},
'Version': __version__,
'WAUsername': '',
Expand Down Expand Up @@ -95,6 +96,9 @@ def update_config(self):
self.config['WAAPIKey'] = ''
if 'WACompanionVersion' not in self.config.keys():
self.config['WACompanionVersion'] = 0
# 2.8.0
if 'IgnoreClientVersion' not in self.config.keys():
self.config['IgnoreClientVersion'] = {}
self.config['Version'] = __version__
self.save_config()

Expand All @@ -120,7 +124,9 @@ def cleanup(self, directories):

def parse_url(self, url):
if url.startswith('https://www.curseforge.com/wow/addons/'):
return CurseForgeAddon(self.parse_cf_id(url), self.cfCache, self.clientType, self.check_if_dev(url))
return CurseForgeAddon(self.parse_cf_id(url), self.cfCache,
'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)
elif url.startswith('https://www.tukui.org/addons.php?id='):
Expand Down Expand Up @@ -151,7 +157,7 @@ def parse_url(self, url):
else:
raise NotImplementedError('Provided URL is not supported.')

def add_addon(self, url):
def add_addon(self, url, ignore):
if 'twitch://' in url:
url = url.split('/download-client')[0].replace('twitch://', 'https://').strip()
elif url.startswith('cf:'):
Expand All @@ -164,6 +170,8 @@ def add_addon(self, url):
url = f'https://www.tukui.org/classic-addons.php?id={url[4:]}'
addon = self.check_if_installed(url)
if not addon:
if ignore:
self.config['IgnoreClientVersion'][url] = True
new = self.parse_url(url)
new.install(self.path)
checksums = {}
Expand All @@ -183,6 +191,7 @@ def del_addon(self, url):
old = self.check_if_installed(url)
if old:
self.cleanup(old['Directories'])
self.config['IgnoreClientVersion'].pop(old['URL'], None)
self.config['Addons'][:] = [d for d in self.config['Addons'] if d.get('URL') != url
and d.get('Name') != url]
self.save_config()
Expand Down
4 changes: 2 additions & 2 deletions CB/CurseForge.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def get_current_version(self):
files = sorted(self.payload['latestFiles'], key=itemgetter('id'), reverse=True)
for status in [[3, 2, 1]] if self.allowDev else [[1], [2], [3]]:
for f in files:
if f['gameVersionFlavor'] == self.clientType and f['releaseType'] in status \
and '-nolib' not in f['displayName'] and not f['isAlternate']:
if (self.clientType == 'wow' or f['gameVersionFlavor'] == self.clientType) and \
f['releaseType'] in status and '-nolib' not in f['displayName'] and not f['isAlternate']:
self.downloadUrl = f['downloadUrl']
self.currentVersion = f['displayName']
break
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 string
import random

__version__ = '2.7.3'
__version__ = '2.8.0'
__license__ = 'GPLv3'
__copyright__ = '2019, Paweł Jastrzębski <[email protected]>'
__docformat__ = 'restructuredtext en'
Expand Down
18 changes: 12 additions & 6 deletions CurseBreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,15 @@ def sanitize_table(self):

def c_install(self, args):
if args:
if args.startswith('-i '):
args = args[3:]
optignore = True
else:
optignore = False
addons = [addon.strip() for addon in args.split(',')]
with tqdm(total=len(addons), bar_format='{n_fmt}/{total_fmt} |{bar}|') as pbar:
for addon in addons:
installed, name, version = self.core.add_addon(addon)
installed, name, version = self.core.add_addon(addon, optignore)
if installed:
self.tableData.append([f'{AC.GREEN}Installed{AC.RESET}', name, version])
else:
Expand All @@ -262,11 +267,12 @@ def c_install(self, args):
printft(ANSI(self.table.table))
else:
printft(HTML('<ansigreen>Usage:</ansigreen>\n\tThis command accepts a comma-separated list of links as an a'
'rgument.\n<ansigreen>Supported URLs:</ansigreen>\n\thttps://www.curseforge.com/wow/addons/[ad'
'don_name] <ansiwhite>|</ansiwhite> cf:[addon_name]\n\thttps://www.wowinterface.com/downloads/'
'[addon_name] <ansiwhite>|</ansiwhite> wowi:[addon_id]\n\thttps://www.tukui.org/addons.php?id='
'[addon_id] <ansiwhite>|</ansiwhite> tu:[addon_id]\n\thttps://www.tukui.org/classic-addons.php'
'?id=[addon_id] <ansiwhite>|</ansiwhite> tuc:[addon_id]\n\tElvUI <ansiwhite>|</ansiwhite> ElvU'
'rgument.\n\tOption <ansiwhite>-i</ansiwhite> will disable the client version check.\n<ansigre'
'en>Supported URLs:</ansigreen>\n\thttps://www.curseforge.com/wow/addons/[addon_name] <ansiwhi'
'te>|</ansiwhite> cf:[addon_name]\n\thttps://www.wowinterface.com/downloads/[addon_name] <ansi'
'white>|</ansiwhite> wowi:[addon_id]\n\thttps://www.tukui.org/addons.php?id=[addon_id] <ansiwh'
'ite>|</ansiwhite> tu:[addon_id]\n\thttps://www.tukui.org/classic-addons.php?id=[addon_id] <an'
'siwhite>|</ansiwhite> tuc:[addon_id]\n\tElvUI <ansiwhite>|</ansiwhite> ElvU'
'I:Dev\n\tTukui'))

def c_uninstall(self, args):
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ By default **CurseBreaker** will create backups of entire `WTF` directory.
## TIPS & TRICKS
- Command `uri_integration` can be used to enable integration with the CurseForge page.
- Most of the commands support the comma-separated list of addons.
- `install` command have optional `-i` flag that can be used to disable version client check.

## SUPPORTED URL
- CurseForge: `https://www.curseforge.com/wow/addons/[addon_name]`, `cf:[addon_name]`
Expand Down

0 comments on commit 145a196

Please sign in to comment.