from pytubefix import YouTube
from pytubefix.cli import on_progress
path = "YouTube/videos"
video = YouTube('https://www.youtube.com/watch?v=P1tYp24-fpA',on_progress_callback = on_progress)
print(*[i for i in video.streams], sep = '\n')
video.streams.filter(res = f'480p').first().download(path)
When the program starts, a file is created, but the video is not recorded in it. I waited for about an hour, but nothing happened, after which i stopped the programm
I checked different videos and qualities, and sometimes i got erros like this
File "c:\Users\lolik\Desktop\tgbots\test.py", line 13, in
video.streams.filter(res = f'1080p',file_extension='mp4').first().download(path,filename='test2.mp4')
File "c:\Users\lolik\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytubefix\streams.py", line 330, in download
for chunk in request.stream(
File "c:\Users\lolik\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytubefix\request.py", line 185, in stream
chunk = response.read()
^^^^^^^^^^^^^^^
File "c:\Users\lolik\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 482, in read
s = self._safe_read(self.length)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\lolik\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 633, in _safe_read
raise IncompleteRead(data, amt-len(data))
http.client.IncompleteRead: IncompleteRead(7552896 bytes read, 633466 more expected)
But audio downloads correctrly
video.streams.filter(type = 'audio').first().download(path)
from pytubefix import YouTube from pytubefix.cli import on_progress path = "YouTube/videos" video = YouTube('https://www.youtube.com/watch?v=P1tYp24-fpA',on_progress_callback = on_progress) print(*[i for i in video.streams], sep = '\n') video.streams.filter(res = f'480p').first().download(path)
When the program starts, a file is created, but the video is not recorded in it. I waited for about an hour, but nothing happened, after which i stopped the programm
I checked different videos and qualities, and sometimes i got erros like this
File "c:\Users\lolik\Desktop\tgbots\test.py", line 13, in
video.streams.filter(res = f'1080p',file_extension='mp4').first().download(path,filename='test2.mp4')
File "c:\Users\lolik\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytubefix\streams.py", line 330, in download
for chunk in request.stream(
File "c:\Users\lolik\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytubefix\request.py", line 185, in stream
chunk = response.read()
^^^^^^^^^^^^^^^
File "c:\Users\lolik\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 482, in read
s = self._safe_read(self.length)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\lolik\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 633, in _safe_read
raise IncompleteRead(data, amt-len(data))
http.client.IncompleteRead: IncompleteRead(7552896 bytes read, 633466 more expected)
But audio downloads correctrly video.streams.filter(type = 'audio').first().download(path)