Pytube: How to set a timeout when calling YouTube object?

Created on 23 Nov 2018  路  4Comments  路  Source: pytube/pytube

How does one set a timeout for grabbing the description of the video?

YouTube('https://www.youtube.com/watch?v=B4BorKfhjYU')

Don't know if this is related to a connection issue or not, but would be nice to be able to set a timeout so we can close the connection and raise a error.

Suggestion:

YouTube('https://www.youtube.com/watch?v=B4BorKfhjYU', timeout=5)

stale

Most helpful comment

Is there any news about this?

All 4 comments

Is there any news about this?

I'd also like to see this. I've been downloading videos, and sometimes it gets stuck. Right now, it's at 88.0%, but it's been there for nearly 30 minutes. I automate multiple videos in a row, so it prevents all the other videos from downloading. Looking for a timeout fix.

Programmer have been ready urllib2(python2)/urllib(python3) for you. And your python version must more than 2.6
You could change request.py under:

< python directory >/site-packages/pytube

find out 27 line, it is:

response = urlopen(req)

change it to:

response = urlopen(req,timeout=< you want time >)

If your VPN disconnected while your computer are downloading, this might be work.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

harindu95 picture harindu95  路  20Comments

waterholic picture waterholic  路  24Comments

haroldfry picture haroldfry  路  58Comments

Winedays picture Winedays  路  31Comments

stephanemombuleau picture stephanemombuleau  路  19Comments