mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
so that different entries can refer to a same software without much overhead. This is needed because entries may be generated, and only nvchecker can tell if two entries are expecting the same result because the name may or may not be relevant. Closes #81.
15 lines
484 B
Python
15 lines
484 B
Python
# MIT licensed
|
|
# Copyright (c) 2013-2018 lilydjwg <lilydjwg@gmail.com>, et al.
|
|
|
|
from . import session, conf_cacheable_with_name
|
|
|
|
API_URL = 'https://crates.io/api/v1/crates/%s'
|
|
|
|
get_cacheable_conf = conf_cacheable_with_name('cratesio')
|
|
|
|
async def get_version(name, conf, **kwargs):
|
|
name = conf.get('cratesio') or name
|
|
async with session.get(API_URL % name) as res:
|
|
data = await res.json()
|
|
version = [v['num'] for v in data['versions'] if not v['yanked']][0]
|
|
return version
|