mirror of https://github.com/yt-dlp/yt-dlp.git
[devscripts/show-downloads-statistics] Add support for paging
This commit is contained in:
parent
dcbb07c35a
commit
7935926baa
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import itertools
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -21,21 +22,26 @@ def format_size(bytes):
|
||||||
|
|
||||||
total_bytes = 0
|
total_bytes = 0
|
||||||
|
|
||||||
releases = json.loads(compat_urllib_request.urlopen(
|
for page in itertools.count(1):
|
||||||
'https://api.github.com/repos/rg3/youtube-dl/releases').read().decode('utf-8'))
|
releases = json.loads(compat_urllib_request.urlopen(
|
||||||
|
'https://api.github.com/repos/rg3/youtube-dl/releases?page=%s' % page
|
||||||
|
).read().decode('utf-8'))
|
||||||
|
|
||||||
for release in releases:
|
if not releases:
|
||||||
compat_print(release['name'])
|
break
|
||||||
for asset in release['assets']:
|
|
||||||
asset_name = asset['name']
|
for release in releases:
|
||||||
total_bytes += asset['download_count'] * asset['size']
|
compat_print(release['name'])
|
||||||
if all(not re.match(p, asset_name) for p in (
|
for asset in release['assets']:
|
||||||
r'^youtube-dl$',
|
asset_name = asset['name']
|
||||||
r'^youtube-dl-\d{4}\.\d{2}\.\d{2}(?:\.\d+)?\.tar\.gz$',
|
total_bytes += asset['download_count'] * asset['size']
|
||||||
r'^youtube-dl\.exe$')):
|
if all(not re.match(p, asset_name) for p in (
|
||||||
continue
|
r'^youtube-dl$',
|
||||||
compat_print(
|
r'^youtube-dl-\d{4}\.\d{2}\.\d{2}(?:\.\d+)?\.tar\.gz$',
|
||||||
' %s size: %s downloads: %d'
|
r'^youtube-dl\.exe$')):
|
||||||
% (asset_name, format_size(asset['size']), asset['download_count']))
|
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))
|
compat_print('total downloads traffic: %s' % format_size(total_bytes))
|
||||||
|
|
Loading…
Reference in New Issue