docstring
Browse files- pytube/utils.py +10 -6
pytube/utils.py
CHANGED
@@ -45,7 +45,8 @@ def sizeof(bytes):
|
|
45 |
"""Takes the size of file or folder in bytes and returns size formatted in
|
46 |
KB, MB, GB, TB or PB.
|
47 |
|
48 |
-
:params bytes:
|
|
|
49 |
"""
|
50 |
alternative = [
|
51 |
(1024 ** 5, ' PB'),
|
@@ -74,16 +75,19 @@ def print_status(progress, file_size, start):
|
|
74 |
This function - when passed as `on_progress` to `Video.download` - prints
|
75 |
out the current download progress.
|
76 |
|
77 |
-
:params progress:
|
78 |
-
|
79 |
-
:params
|
|
|
|
|
|
|
80 |
"""
|
81 |
|
82 |
-
|
83 |
done = int(50 * progress / int(file_size))
|
84 |
dt = (clock() - start)
|
85 |
if dt > 0:
|
86 |
stdout.write("\r [%s%s][%3.2f%%] %s at %s/s\r " %
|
87 |
-
('=' * done, ' ' * (50 - done),
|
88 |
sizeof(file_size), sizeof(progress // dt)))
|
89 |
stdout.flush()
|
|
|
45 |
"""Takes the size of file or folder in bytes and returns size formatted in
|
46 |
KB, MB, GB, TB or PB.
|
47 |
|
48 |
+
:params bytes:
|
49 |
+
Size of the file in bytes
|
50 |
"""
|
51 |
alternative = [
|
52 |
(1024 ** 5, ' PB'),
|
|
|
75 |
This function - when passed as `on_progress` to `Video.download` - prints
|
76 |
out the current download progress.
|
77 |
|
78 |
+
:params progress:
|
79 |
+
The lenght of the currently downloaded bytes.
|
80 |
+
:params file_size:
|
81 |
+
The total size of the video.
|
82 |
+
:params start:
|
83 |
+
The time when started
|
84 |
"""
|
85 |
|
86 |
+
percent_done = int(progress) * 100. / file_size
|
87 |
done = int(50 * progress / int(file_size))
|
88 |
dt = (clock() - start)
|
89 |
if dt > 0:
|
90 |
stdout.write("\r [%s%s][%3.2f%%] %s at %s/s\r " %
|
91 |
+
('=' * done, ' ' * (50 - done), percent_done,
|
92 |
sizeof(file_size), sizeof(progress // dt)))
|
93 |
stdout.flush()
|