[BUG] A very short video has an error.
See original GitHub issueDescribe the bug A very short video has an error.
The request used for the download does not seem to be able to handle requests for a small capacity. The urllib in use in the pytube package cannot handle this. The error contents are as follows.
To Reproduce Please provide the following information:
-
The video or playlist url that is causing the error. https://www.youtube.com/watch?v=jb6-LDqLNqk
-
The code where the problem is occurring.
Traceback (most recent call last):
File "/home/jayflow/Proejcts/Puzz/video_cron/venv/lib/python3.10/site-packages/rq/worker.py", line 1061, in perform_job
rv = job.perform()
File "/home/jayflow/Proejcts/Puzz/video_cron/venv/lib/python3.10/site-packages/rq/job.py", line 821, in perform
self._result = self._execute()
File "/home/jayflow/Proejcts/Puzz/video_cron/venv/lib/python3.10/site-packages/rq/job.py", line 844, in _execute
result = self.func(*self.args, **self.kwargs)
File "/home/jayflow/Proejcts/Puzz/video_cron/src/providers/youtube.py", line 32, in download_video
YouTube(
File "/home/jayflow/Proejcts/Puzz/video_cron/venv/lib/python3.10/site-packages/pytube/streams.py", line 252, in download
for chunk in request.stream(
File "/home/jayflow/Proejcts/Puzz/video_cron/venv/lib/python3.10/site-packages/pytube/request.py", line 185, in stream
chunk = response.read()
File "/usr/lib/python3.10/http/client.py", line 481, in read
s = self._safe_read(self.length)
File "/usr/lib/python3.10/http/client.py", line 632, in _safe_read
raise IncompleteRead(data, amt-len(data))
http.client.IncompleteRead: IncompleteRead(0 bytes read, 203085 more expected)
My code
YouTube(
url=f'https://www.youtube.com/watch?v={video_id}',
on_complete_callback=lambda stream, file_path:
self.__on_complete_download(
YouTubeVideoMeta(
video_id=video_id,
file_path=file_path,
file_name=file_path.split('/')[-1],
stream=stream,
),
),
on_progress_callback=self.__show_download_progress
).streams.get_highest_resolution().download(video_storage_path, filename=file_name)
System information Please provide the following information:
-
Python version (run
python --version
) Python 3.10.2 -
Pytube version (run
print(pytube.__version__)
in python) pytube==12.0.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
20 most common video errors & how to fix them
This article guide you how to fix all 20 problems or errors while playing videos like playback errors, audio video sync, issues, choppy, ......
Read more >Common uploading errors - YouTube Help - Google Support
This error message may occur if the uploaded file is shortened or invalid. It can also occur on reduced upload speeds. Try playing...
Read more >[Update: Dec. 16] YouTube bugs/issues & pending ...
An error message “endscreen element is too small” always popped up on trying to do so. Again, as it stands, YouTube today fixed...
Read more >Display Problems Playing Video Clips in Windows
RESOLUTION · Removing and Reinstalling Video Compression · Need more help?
Read more >How to Fix FaceBook Having Issues on Video Playing?
Though, if the video itself has been corrupted, then you can simply try Wondershare Video Repair to fix it. A complete video repairing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Modify the /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pytube/request.py file as follows:
it’s ok
I am having the same issue here
Is there any reason for using a low-level library like http.client, instead of something more straightforward like requests?