Fix download method
This commit is contained in:
@ -5,7 +5,6 @@ import json
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import requests
|
||||
import base64
|
||||
import sys
|
||||
from os import geteuid, chdir
|
||||
import subprocess
|
||||
@ -29,8 +28,8 @@ def get_master_info(repo, filepath, credz):
|
||||
url = f"https://api.github.com/repos/{repo}/contents/{filepath}"
|
||||
r = requests.get(url, auth=credz)
|
||||
sha = r.json()['sha']
|
||||
content = r.json()['content']
|
||||
return sha, content
|
||||
dlurl = r.json()['download_url']
|
||||
return sha, dlurl
|
||||
|
||||
|
||||
def get_last_release_info(repo, credz):
|
||||
@ -69,12 +68,12 @@ def githubmastersync(reponame, filepaths, credz):
|
||||
for filepath in filepaths:
|
||||
localfile = Path('files').joinpath(Path(filepath).name)
|
||||
print(f" * {localfile} ", end='')
|
||||
lastsha, content = get_master_info(reponame, filepath, credz)
|
||||
lastsha, dlurl = get_master_info(reponame, filepath, credz)
|
||||
|
||||
if not localfile.exists():
|
||||
content = base64.b64decode(content)
|
||||
r = requests.get(dlurl)
|
||||
with open(localfile, 'wb') as f:
|
||||
f.write(content)
|
||||
f.write(r.content)
|
||||
print('-> Installed! ;)')
|
||||
|
||||
else:
|
||||
@ -83,9 +82,9 @@ def githubmastersync(reponame, filepaths, credz):
|
||||
if sha == lastsha:
|
||||
print('-> Up-to-date.')
|
||||
else:
|
||||
content = base64.b64decode(content)
|
||||
r = requests.get(dlurl)
|
||||
with open(localfile, 'wb') as f:
|
||||
f.write(content)
|
||||
f.write(r.content)
|
||||
print('-> Updated!')
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user