def detect(cls, name, url, **kwargs):
urlp = urllib.parse.urlparse(url)
if urlp.netloc != 'bitbucket.org':
return
pathseg = urlp.path.lstrip('/').split('/')
repo = '/'.join(pathseg[:2])
if repo.endswith('.git'):
repo = repo[:-4]
if len(pathseg) > 2:
if pathseg[2] == 'downloads':
return cls(name, repo, 'release')
elif pathseg[2] == 'get':
return cls(name, repo, 'tag')
for category, url in (
('release', 'https://api.bitbucket.org/2.0/repositories/%s/downloads' % repo),
('tag', 'https://api.bitbucket.org/2.0/repositories/%s/refs/tags' % repo)):
req = HSESSION.get(url, timeout=30)
if req.status_code == 200:
d = req.json()
if d.get('values'):
return cls(name, repo, category)
评论列表
文章目录