aboutsummaryrefslogtreecommitdiff
path: root/update.py
diff options
context:
space:
mode:
Diffstat (limited to 'update.py')
-rwxr-xr-xupdate.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/update.py b/update.py
index 953f994..5cf99f9 100755
--- a/update.py
+++ b/update.py
@@ -103,7 +103,7 @@ def apply_updates(args):
else:
url = requests.get(mod[1]).url
if url is None:
- print('Failed to fetch {mod[0]}!'.format(mod=mod))
+ print('[!]Failed to fetch {mod[0]}!'.format(mod=mod))
continue
resp = requests.get(url)
hsh = hashlib.sha1(resp.content).hexdigest()
@@ -147,19 +147,19 @@ def check_updates(args):
# Use selenium to find curseforge CDN links around cloudflare
def find_cdn(ffx, url):
try:
- ffx.get(url + '/download')
- page_src = ffx.page_source
- dl = re.search('Elerium.PublicProjectDownload.countdown\(".*?"\);', page_src)
- if not dl:
- return None
- dl = re.search('\d+', dl.group(0).split('"')[1])
+ #ffx.get(url + '/download')
+ ffx.get(url + '/files')
+ #page_src = ffx.page_source
+ #dl = re.search('Elerium.PublicProjectDownload.countdown\(".*?"\);', page_src)
+ #if not dl:
+ # return None
+ dl = ffx.find_element_by_xpath("html/body/div/main/div/div/section/div/div/div/section/article/div/div/a").get_attribute("href")
+ dl = re.search('\d{7}', dl)
dl = dl.group(0)
four = str(int(dl[:4]))
three = str(int(dl[4:]))
- ffx.get(url + '/files')
- elements = ffx.find_elements_by_tag_name('tr')
- file_name = elements[1].find_element_by_tag_name('a').text
+ file_name = ffx.find_elements_by_xpath("html/body/div/main/div/div/section/div/div/div/section/article/div/div/span[contains(@class, 'text-sm')]")[1].text
return 'https://media.forgecdn.net/files/{four}/{three}/{jar}'.format(four=four,three=three,jar=file_name)
except: