]>
Raphaƫl G. Git Repositories - youtubedl/blob - devscripts/show-downloads-statistics.py
2 from __future__
import unicode_literals
10 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
12 from youtube_dl
.compat
import (
14 compat_urllib_request
,
16 from youtube_dl
.utils
import format_bytes
19 def format_size(bytes):
20 return '%s (%d bytes)' % (format_bytes(bytes), bytes)
25 for page
in itertools
.count(1):
26 releases
= json
.loads(compat_urllib_request
.urlopen(
27 'https://api.github.com/repos/rg3/youtube-dl/releases?page=%s' % page
28 ).read().decode('utf-8'))
33 for release
in releases
:
34 compat_print(release
['name'])
35 for asset
in release
['assets']:
36 asset_name
= asset
['name']
37 total_bytes
+= asset
['download_count'] * asset
['size']
38 if all(not re
.match(p
, asset_name
) for p
in (
40 r
'^youtube-dl-\d{4}\.\d{2}\.\d{2}(?:\.\d+)?\.tar\.gz$',
41 r
'^youtube-dl\.exe$')):
44 ' %s size: %s downloads: %d'
45 % (asset_name
, format_size(asset
['size']), asset
['download_count']))
47 compat_print('total downloads traffic: %s' % format_size(total_bytes
))