project-stats

keep track of your projects
git clone https://git.ce9e.org/project-stats.git

commit
b61b96e681e48cacf7a8393b85c552dff7a89c0d
parent
c280e48971550c6518fd2b33f9730b6f68cca8e7
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2018-03-25 12:30
add support for firefox add-ons

Diffstat

M project_stats.py 22 +++++++++++++++++++++-

1 files changed, 21 insertions, 1 deletions


diff --git a/project_stats.py b/project_stats.py

@@ -18,7 +18,7 @@ except ImportError:
   18    18 
   19    19 __version__ = '1.1.1'
   20    20 
   21    -1 SOURCES = ['github', 'gitlab', 'local', 'pypi', 'npm', 'travis']
   -1    21 SOURCES = ['github', 'gitlab', 'local', 'pypi', 'npm', 'travis', 'firefox']
   22    22 
   23    23 KEYS = [
   24    24     'name',
@@ -332,6 +332,26 @@ async def get_travis(url):
  332   332     }
  333   333 
  334   334 
   -1   335 async def get_firefox(url):
   -1   336     def get_us(d, key):
   -1   337         return d.get(key, {}).get('en-US')
   -1   338 
   -1   339     api_url = re.sub(
   -1   340         'mozilla.org/[^/]*/firefox', 'mozilla.org/api/v3/addons', url)
   -1   341     data = await get_json(api_url)
   -1   342 
   -1   343     return {
   -1   344         'name': get_us(data, 'name'),
   -1   345         'description': get_us(data, 'summary'),
   -1   346         'version': data.get('current_version', {}).get('version'),
   -1   347         'homepage': get_us(data, 'homepage'),
   -1   348         'updated': data.get('last_updated'),
   -1   349         'license': get_us(data.get('current_version', {}), 'license'),
   -1   350         'downloads': data.get('weekly_downloads'),
   -1   351         'subscribers_count': data.get('average_daily_users'),
   -1   352     }
   -1   353 
   -1   354 
  335   355 async def get_source(key, source, config, claims):
  336   356     fn = globals()['get_' + key]
  337   357     if key == 'github':