Twixes
commited on
Bypass YouTube whole download throttling
Browse filesYouTube is throttling downloads without the Range header, which is used by browsers when streaming (for example with an implementation of the <video> HTML tag ) but not on whole downloads. We can easily bypass this, however, by just adding Range: bytes=0- to the request. The result is all the same bytes as before but in a much shorter time.
- pytube/request.py +1 -1
pytube/request.py
CHANGED
@@ -9,7 +9,7 @@ from urllib.request import urlopen
|
|
9 |
def _execute_request(url: str) -> Any:
|
10 |
if not url.lower().startswith("http"):
|
11 |
raise ValueError
|
12 |
-
return urlopen(Request(url, headers={"User-Agent": "Mozilla/5.0"})) # nosec
|
13 |
|
14 |
|
15 |
def get(url) -> str:
|
|
|
9 |
def _execute_request(url: str) -> Any:
|
10 |
if not url.lower().startswith("http"):
|
11 |
raise ValueError
|
12 |
+
return urlopen(Request(url, headers={"User-Agent": "Mozilla/5.0", "Range": "bytes=0-"})) # nosec
|
13 |
|
14 |
|
15 |
def get(url) -> str:
|