From 3cd5513c0c54e5e000d53c39853173d3d9d9046b Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 30 Apr 2013 18:11:44 +0200 Subject: [PATCH] Point source updater to new url --- couchpotato/core/_base/updater/main.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/couchpotato/core/_base/updater/main.py b/couchpotato/core/_base/updater/main.py index 07031556..2bcfef31 100644 --- a/couchpotato/core/_base/updater/main.py +++ b/couchpotato/core/_base/updater/main.py @@ -15,6 +15,7 @@ import tarfile import time import traceback import version +import zipfile log = CPLog(__name__) @@ -253,6 +254,8 @@ class GitUpdater(BaseUpdater): class SourceUpdater(BaseUpdater): + update_url = 'https://couchpota.to/updates/source.php?repo=%s&name=%s&branch=%s' + def __init__(self): # Create version file in cache @@ -260,14 +263,17 @@ class SourceUpdater(BaseUpdater): if not os.path.isfile(self.version_file): self.createFile(self.version_file, json.dumps(self.latestCommit())) + addEvent('app.load', self.doUpdate) + def doUpdate(self): try: - url = 'https://github.com/%s/%s/tarball/%s' % (self.repo_user, self.repo_name, self.branch) - destination = os.path.join(Env.get('cache_dir'), self.update_version.get('hash') + '.tar.gz') - extracted_path = os.path.join(Env.get('cache_dir'), 'temp_updater') + url = self.update_url % (self.repo_user, self.repo_name, self.branch) + download_data = json.loads(self.urlopen(url)) + destination = os.path.join(Env.get('cache_dir'), self.update_version.get('hash')) + '.' + download_data.get('type') - destination = fireEvent('file.download', url = url, dest = destination, single = True) + extracted_path = os.path.join(Env.get('cache_dir'), 'temp_updater') + destination = fireEvent('file.download', url = download_data.get('url'), dest = destination, single = True) # Cleanup leftover from last time if os.path.isdir(extracted_path): @@ -275,9 +281,14 @@ class SourceUpdater(BaseUpdater): self.makeDir(extracted_path) # Extract - tar = tarfile.open(destination) - tar.extractall(path = extracted_path) - tar.close() + if download_data.get('type') == 'zip': + zip = zipfile.ZipFile(destination) + zip.extractall(extracted_path) + else: + tar = tarfile.open(destination) + tar.extractall(path = extracted_path) + tar.close() + os.remove(destination) if self.replaceWith(os.path.join(extracted_path, os.listdir(extracted_path)[0])):