Skip to content

Commit

Permalink
Fixed issues with dev version detection (close #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Jul 2, 2019
1 parent 0859bc1 commit 374aa7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
27 changes: 10 additions & 17 deletions CB/CurseForge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import zipfile
import requests
from bs4 import BeautifulSoup
from operator import itemgetter
from . import retry


Expand All @@ -25,25 +26,17 @@ def __init__(self, url, cache, allowdev):
self.directories = []
self.get_current_version()

def _parse_files(self, releasetype):
for f in self.payload['latestFiles']:
if f['releaseType'] == releasetype and '-nolib' not in f['displayName']:
self.downloadUrl = f['downloadUrl']
self.currentVersion = f['displayName']
break

def get_current_version(self):
if self.allowDev:
self._parse_files(3)
if not self.downloadUrl and not self.currentVersion:
self._parse_files(2)
if not self.downloadUrl and not self.currentVersion:
self._parse_files(1)
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['releaseType'] in status and '-nolib' not in f['displayName'] and not f['isAlternate']:
self.downloadUrl = f['downloadUrl']
self.currentVersion = f['displayName']
break
if self.downloadUrl and self.currentVersion:
break
else:
self._parse_files(1)
if not self.downloadUrl and not self.currentVersion:
self._parse_files(2)
if not self.downloadUrl or not self.currentVersion:
raise RuntimeError

@retry()
Expand Down
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.2'
__version__ = '1.5.3'
__license__ = 'GPLv3'
__copyright__ = '2019, Paweł Jastrzębski <pawelj@iosphe.re>'
__docformat__ = 'restructuredtext en'
Expand Down

0 comments on commit 374aa7c

Please sign in to comment.