fallback to real filesize if approximate not available
Browse files- pytube/extract.py +2 -2
- pytube/streams.py +5 -3
pytube/extract.py
CHANGED
@@ -275,7 +275,7 @@ def apply_descrambler(stream_data: Dict, key: str) -> None:
|
|
275 |
"type": format_item["mimeType"],
|
276 |
"quality": format_item["quality"],
|
277 |
"itag": format_item["itag"],
|
278 |
-
"bitrate": format_item
|
279 |
"is_otf": (format_item.get("type") == otf_type),
|
280 |
}
|
281 |
for format_item in formats
|
@@ -291,7 +291,7 @@ def apply_descrambler(stream_data: Dict, key: str) -> None:
|
|
291 |
"type": format_item["mimeType"],
|
292 |
"quality": format_item["quality"],
|
293 |
"itag": format_item["itag"],
|
294 |
-
"bitrate": format_item
|
295 |
"is_otf": (format_item.get("type") == otf_type),
|
296 |
}
|
297 |
for i, format_item in enumerate(formats)
|
|
|
275 |
"type": format_item["mimeType"],
|
276 |
"quality": format_item["quality"],
|
277 |
"itag": format_item["itag"],
|
278 |
+
"bitrate": format_item.get("bitrate"),
|
279 |
"is_otf": (format_item.get("type") == otf_type),
|
280 |
}
|
281 |
for format_item in formats
|
|
|
291 |
"type": format_item["mimeType"],
|
292 |
"quality": format_item["quality"],
|
293 |
"itag": format_item["itag"],
|
294 |
+
"bitrate": format_item.get("bitrate"),
|
295 |
"is_otf": (format_item.get("type") == otf_type),
|
296 |
}
|
297 |
for i, format_item in enumerate(formats)
|
pytube/streams.py
CHANGED
@@ -164,9 +164,11 @@ class Stream:
|
|
164 |
:rtype: int
|
165 |
:returns: size of video in bytes
|
166 |
"""
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
170 |
|
171 |
@property
|
172 |
def default_filename(self) -> str:
|
|
|
164 |
:rtype: int
|
165 |
:returns: size of video in bytes
|
166 |
"""
|
167 |
+
if self._monostate.duration:
|
168 |
+
bits_in_byte = 8
|
169 |
+
return int((self._monostate.duration * self.bitrate) / bits_in_byte)
|
170 |
+
else:
|
171 |
+
return self.filesize
|
172 |
|
173 |
@property
|
174 |
def default_filename(self) -> str:
|