Skip to content

Commit

Permalink
Added support for CCIP files
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Aug 8, 2019
1 parent a11034f commit 72597f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ WTF-Backup/
/CurseBreaker.spec
/CurseBreaker.reg
/Setup.bat

/Pipfile
/Pipfile.lock
11 changes: 2 additions & 9 deletions CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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\\""')
2 changes: 1 addition & 1 deletion CB/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.5.4'
__version__ = '1.6.0'
__license__ = 'GPLv3'
__copyright__ = '2019, Paweł Jastrzębski <pawelj@iosphe.re>'
__docformat__ = 'restructuredtext en'
Expand Down
16 changes: 13 additions & 3 deletions CurseBreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 72597f5

Please sign in to comment.