From 72597f53508bf4de1916cf753a89a13d723aaa94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 8 Aug 2019 10:18:26 +0200 Subject: [PATCH] Added support for CCIP files --- .gitignore | 3 ++- CB/Core.py | 11 ++--------- CB/__init__.py | 2 +- CurseBreaker.py | 16 +++++++++++++--- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 617360f..023c739 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ WTF-Backup/ /CurseBreaker.spec /CurseBreaker.reg /Setup.bat - +/Pipfile +/Pipfile.lock diff --git a/CB/Core.py b/CB/Core.py index 11f8ddf..0e6fd9c 100644 --- a/CB/Core.py +++ b/CB/Core.py @@ -98,8 +98,6 @@ def parse_url(self, url): raise NotImplementedError('Provided URL is not supported.') def add_addon(self, url): - if 'twitch://' in url: - url = url.split('/download-client')[0].replace('twitch://', 'https://').strip() addon = self.check_if_installed(url) if not addon: new = self.parse_url(url) @@ -239,10 +237,5 @@ def search(self, query): def create_reg(self): with open('CurseBreaker.reg', 'w') as outfile: - outfile.write('Windows Registry Editor Version 5.00\n[HKEY_CURRENT_USER\Software\Classes\\twitch]\n"URL Pro' - 'tocol"="\\"\\""\n@="\\"URL:CurseBreaker Protocol\\""\n[HKEY_CURRENT_USER\Software\Classes\\t' - 'witch\DefaultIcon]\n@="\\"CurseBreaker.exe,1\\""\n[HKEY_CURRENT_USER\Software\Classes\\twitc' - 'h\shell]\n[HKEY_CURRENT_USER\Software\Classes\\twitch\shell\open]\n[HKEY_CURRENT_USER\Softwa' - 're\Classes\\twitch\shell\open\command]\n@="\\"' - + os.path.abspath(sys.executable).replace('\\', '\\\\') + '\\" \\"%1\\""') - + outfile.write('Windows Registry Editor Version 5.00\n\n[HKEY_CLASSES_ROOT\.ccip\Shell\Open\Command]\n@="\\"' + + os.path.abspath(sys.executable).replace('\\', '\\\\') + '\\\" \\"%1\\""') diff --git a/CB/__init__.py b/CB/__init__.py index 2ce9df4..aef18a8 100644 --- a/CB/__init__.py +++ b/CB/__init__.py @@ -1,4 +1,4 @@ -__version__ = '1.5.4' +__version__ = '1.6.0' __license__ = 'GPLv3' __copyright__ = '2019, Paweł Jastrzębski ' __docformat__ = 'restructuredtext en' diff --git a/CurseBreaker.py b/CurseBreaker.py index d219e84..75fd6ef 100644 --- a/CurseBreaker.py +++ b/CurseBreaker.py @@ -5,6 +5,7 @@ import shutil import requests import traceback +from xml.dom.minidom import parse from tqdm import tqdm from colorama import init, Fore from terminaltables import SingleTable @@ -51,9 +52,18 @@ def start(self): self.setup_completer() self.setup_table() # Curse URI Support - if len(sys.argv) == 2 and 'twitch://' in sys.argv[1]: + if len(sys.argv) == 2 and '.ccip' in sys.argv[1]: try: - self.c_install(sys.argv[1].strip()) + path = sys.argv[1].strip() + xml = parse(path) + project = xml.childNodes[0].getElementsByTagName('project')[0].getAttribute('id') + payload = requests.post('https://addons-ecs.forgesvc.net/api/v2/addon', json=[int(project)]).json()[0] + url = payload['websiteUrl'].strip() + self.core.config['CurseCache'][url] = project + self.core.save_config() + self.c_install(url) + if os.path.exists(path): + os.remove(path) except Exception as e: self.handle_exception(e) os.system('timeout /t 5') @@ -269,7 +279,7 @@ def c_orphans(self, _): def c_uri_integration(self, _): self.core.create_reg() printft('CurseBreaker.reg file was created. Attempting to import...') - out = os.system('Reg import CurseBreaker.reg') + out = os.system('"' + os.path.join(os.path.dirname(sys.executable), 'CurseBreaker.reg') + '"') if out != 0: printft('Import failed. Please try to import REG file manually.') else: