Skip to content

Instantly share code, notes, and snippets.

@subuk
Last active January 20, 2017 17:28
Show Gist options
  • Save subuk/202f3100ec661a100232686a5cc50f77 to your computer and use it in GitHub Desktop.
Save subuk/202f3100ec661a100232686a5cc50f77 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import requests
from requests.auth import HTTPBasicAuth
URL_TEMPLATE = (
"https://api.bintray.com"
"/packages/{subject}/{repo}/{package}/files"
)
packages = ["main", "atlassian", "backend"]
URL_DATA = {
"subject": "COMPANY",
"repo": "REPO",
"package": "PACKAGE",
"version": "VERSOIN",
}
auth = HTTPBasicAuth("username", "api-key")
for package in packages:
URL_DATA['package'] = package
url = URL_TEMPLATE.format(**URL_DATA)
response = requests.get(url, auth=auth)
response.raise_for_status()
for fileinfo in response.json():
print "https://username:[email protected]/repo/{path}".format(**fileinfo)
#!/bin/bash
urls=$(cat urls.list)
pushd ~/workspace/repo
for url in $urls;do
path=$(echo $url|awk -F'https://username:[email protected]/' '{print $2}')
mkdir -p $(dirname $path)
pushd $(dirname $path)
wget $url
popd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment