Skip to content

Instantly share code, notes, and snippets.

@Scrxtchy
Last active April 23, 2017 06:45
Show Gist options
  • Save Scrxtchy/766a5f10bd243bc396110c8c03a69294 to your computer and use it in GitHub Desktop.
Save Scrxtchy/766a5f10bd243bc396110c8c03a69294 to your computer and use it in GitHub Desktop.
Sharex Portable Downloader
#https://ci.appveyor.com/api/projects/sharex/sharex/
#https://ci.appveyor.com/api/buildjobs/gvpcphtdc5pnsy3d/artifacts/ShareX.Setup%2FInnoSetup%2FOutput%2FShareX-portable.zip
#https://ci.appveyor.com/api/buildjobs/ppbvy1947qageqii/artifacts/Output%2FShareX-portable.zip
import requests, json, urllib.request, zipfile, os
r = requests.get('https://ci.appveyor.com/api/projects/sharex/sharex/')
data = json.loads(r.text)
buildId = data['build']['jobs'][0]['jobId']
#print(data['build']['jobs'][0]['jobId'])
for i in data['build']['jobs']:
if i['name'] == 'Configuration: Release':
buildId = i['jobId']
print('downloading release')
def reporthook(blocknum, blocksize, totalsize): #https://stackoverflow.com/questions/13881092/download-progressbar-for-python-3
readsofar = blocknum * blocksize
if totalsize > 0:
percent = readsofar * 1e2 / totalsize
s = "\r%5.1f%% %*d / %d" % (
percent, len(str(totalsize)), readsofar, totalsize)
print(s)
if readsofar >= totalsize: # near the end
print("\n")
else: # total size is unknown
print("read %d\n" % (readsofar,))
sharexzip = urllib.request.urlretrieve("https://ci.appveyor.com/api/buildjobs/%s/artifacts/Output/ShareX-portable.zip" % buildId, 'sharex-portable.zip', reporthook)
print('download complete')
sharexzip = zipfile.ZipFile('sharex-portable.zip')
sharexzip.extractall(os.path.expanduser('~\sharex'))
print('Portable Version dumped to %s\nDeleting Zip' %os.path.expanduser('~\sharex'))
sharexzip.close()
os.remove('sharex-portable.zip')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment