Permalink
Browse files

Import the latest kaoriya downloading script

https://gist.github.com/k-takata/5c931123b3d2bfdc40fd

Now this supports token authorization which allows 5,000 API requests
per hour.
1 parent b05d302 commit 497ff73d2fc15f792a2a12cf5a9db1ba055928b5 @k-takata k-takata committed Apr 16, 2016
Showing with 14 additions and 3 deletions.
  1. +14 −3 tools/dl-kaoriya-vim.py
@@ -25,17 +25,28 @@
parser.add_argument('-a', '--arch', type=str, action='store',
choices=['all', 'win32', 'win64'], default='all',
help='architecture to download')
+parser.add_argument('--auth', type=str, action='store',
+ default=os.getenv('AUTH_TOKEN'),
+ metavar="TOKEN", help='GitHub API token (Environment variable AUTH_TOKEN can be also used.)')
args = parser.parse_args()
if args.filename and args.arch == 'all':
parser.error('-a must be specified when you specify -n.')
# Get information of GitHub release
# see: https://developer.github.com/v3/repos/releases/
+if args.auth:
+ # Unauthenticated requests are limited up to 60 requests per hour.
+ # Authenticated requests are allowed up to 5,000 requests per hour.
+ # See: https://developer.github.com/v3/#rate-limiting
+ request = urllib.request.Request(gh_release_url)
+ request.add_header("Authorization", "token " + args.auth)
+else:
+ request = gh_release_url
try:
- response = urllib.request.urlopen(gh_release_url)
-except urllib.error.HTTPError:
- print('GitHub release not found.', out=sys.stderr)
+ response = urllib.request.urlopen(request)
+except urllib.error.HTTPError as err:
+ print('GitHub release not found. (%s)' % err.reason, file=sys.stderr)
exit(1)
rel_info = json.load(io.StringIO(str(response.read(), 'utf-8')))

0 comments on commit 497ff73

Please sign in to comment.