pytubefix
pytubefix copied to clipboard
IncompleteRead
Hi, JuanBindez I've installed pytubefix version 5.4.2. Here's the test code:
from pytubefix import YouTube
url = 'https://www.youtube.com/watch?v=xtQy5NTsHeE' # download failed
def test_YouTube():
yt = YouTube(url, use_oauth=True, allow_oauth_cache=True, client='WEB')
video_stream = yt.streams.get_highest_resolution()
output_path = r"./"
video_title_file = "test.mp4"
video_stream.download(output_path=output_path, filename=video_title_file, max_retries=5)
print(f'Downloading video: {yt.title}')
if __name__ == '__main__':
test_YouTube()
Some YouTube links have this problem Below is the error message I get when running the code:
Traceback (most recent call last):
File "D:\code\python\project\some-reverse-works\examples\pytube\test_pytubefix_to_author.py", line 15, in <module>
test_YouTube()
File "D:\code\python\project\some-reverse-works\examples\pytube\test_pytubefix_to_author.py", line 11, in test_YouTube
video_stream.download(output_path=output_path, filename=video_title_file, max_retries=5)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pytubefix\streams.py", line 325, in download
for chunk in request.stream(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\pytubefix\request.py", line 185, in stream
chunk = response.read()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 482, in read
s = self._safe_read(self.length)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 633, in _safe_read
raise IncompleteRead(data, amt-len(data))
http.client.IncompleteRead: IncompleteRead(435172 bytes read, 9002012 more expected)