]>
Commit | Line | Data |
---|---|---|
1 | # Unused | |
2 | ||
3 | #!/usr/bin/env python3 | |
4 | from __future__ import unicode_literals | |
5 | ||
6 | import itertools | |
7 | import json | |
8 | import os | |
9 | import re | |
10 | import sys | |
11 | ||
12 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
13 | ||
14 | from yt_dlp.compat import ( | |
15 | compat_print, | |
16 | compat_urllib_request, | |
17 | ) | |
18 | from yt_dlp.utils import format_bytes | |
19 | ||
20 | ||
21 | def format_size(bytes): | |
22 | return '%s (%d bytes)' % (format_bytes(bytes), bytes) | |
23 | ||
24 | ||
25 | total_bytes = 0 | |
26 | ||
27 | for page in itertools.count(1): | |
28 | releases = json.loads(compat_urllib_request.urlopen( | |
29 | 'https://api.github.com/repos/ytdl-org/youtube-dl/releases?page=%s' % page | |
30 | ).read().decode('utf-8')) | |
31 | ||
32 | if not releases: | |
33 | break | |
34 | ||
35 | for release in releases: | |
36 | compat_print(release['name']) | |
37 | for asset in release['assets']: | |
38 | asset_name = asset['name'] | |
39 | total_bytes += asset['download_count'] * asset['size'] | |
40 | if all(not re.match(p, asset_name) for p in ( | |
41 | r'^yt-dlp$', | |
42 | r'^yt-dlp-\d{4}\.\d{2}\.\d{2}(?:\.\d+)?\.tar\.gz$', | |
43 | r'^yt-dlp\.exe$')): | |
44 | continue | |
45 | compat_print( | |
46 | ' %s size: %s downloads: %d' | |
47 | % (asset_name, format_size(asset['size']), asset['download_count'])) | |
48 | ||
49 | compat_print('total downloads traffic: %s' % format_size(total_bytes)) |