diff options
author | Sergey M․ <dstftw@gmail.com> | 2016-07-03 22:20:14 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2016-07-03 22:20:14 +0700 |
commit | bf3ae6a543ee8825308e8427f60fceb125a77ab5 (patch) | |
tree | e59f640af83a1d44c9703612df0a11cf9d971445 /devscripts/show-downloads-statistics.py | |
parent | bff98341d5c5944fd8fb74797b70b0d3db6a3c89 (diff) |
[devscripts/show-downloads-statictics] Add script for displaying downloads statistics
Diffstat (limited to 'devscripts/show-downloads-statistics.py')
-rw-r--r-- | devscripts/show-downloads-statistics.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/devscripts/show-downloads-statistics.py b/devscripts/show-downloads-statistics.py new file mode 100644 index 000000000..b591d3fc9 --- /dev/null +++ b/devscripts/show-downloads-statistics.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +from __future__ import unicode_literals + +import json +import os +import re +import sys + +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from youtube_dl.compat import ( + compat_print, + compat_urllib_request, +) +from youtube_dl.utils import format_bytes + + +def format_size(bytes): + return '%s (%d bytes)' % (format_bytes(bytes), bytes) + + +total_bytes = 0 + +releases = json.loads(compat_urllib_request.urlopen( + 'https://api.github.com/repos/rg3/youtube-dl/releases').read().decode('utf-8')) + +for release in releases: + compat_print(release['name']) + for asset in release['assets']: + asset_name = asset['name'] + total_bytes += asset['download_count'] * asset['size'] + if all(not re.match(p, asset_name) for p in ( + r'^youtube-dl$', + r'^youtube-dl-\d{4}\.\d{2}\.\d{2}(?:\.\d+)?\.tar\.gz$', + r'^youtube-dl\.exe$')): + continue + compat_print( + ' %s size: %s downloads: %d' + % (asset_name, format_size(asset['size']), asset['download_count'])) + +compat_print('total downloads traffic: %s' % format_size(total_bytes)) |