Pytube length sometimes missing causes crash
See original GitHub issueOn certain urls trying to get the length of a youtube video crashes the program due to a key error in the object itself.
Ex: https://www.youtube.com/watch?v=4VR-6AS0-l4
Traceback (most recent call last):
if end_time >= yt.length:
File "/opt/python/run/venv/lib/python2.7/site-packages/pytube/__main__.py", line 286, in length
return self.player_config_args['length_seconds']
KeyError: 'length_seconds'
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Pytube length sometimes missing causes crash · Issue #448
On certain urls trying to get the length of a youtube video crashes the program due to a key error in the object...
Read more >pytube filesize() keyerror content-length - You.com - You.com
On certain urls trying to get the length of a youtube video crashes the program due to a key error in the object...
Read more >Python YouTube downloader with pytube crashes when I ...
I am making a YouTube video downloader with Python. I made the design with PyQt and edited the code in IDLE. Here is...
Read more >API — pytube 12.1.2 documentation
Parse a variable length sized list of codecs and returns a constant two element tuple, with the video codec as the first element...
Read more >Associative Knowledge Graph Using Fuzzy Clustering and ...
consideration of the different length of each video content and generate ... For this reason, sometimes, it is ambiguous to find simi-.
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
hey i figured out what is happening ! Go to line 286 and change the only line with
return ( self.player_config_args .get('player_response', {}) .get('videoDetails', {}) .get('lengthSeconds') )
It works really well for me 😉@marcounetB nailed it! However, if you don’t want to edit the source code… considering you have your object like
current_video = YouTube(video_url)
, you just need to use:current_video.player_config_args.get('player_response').get('videoDetails').get('lengthSeconds')
orcurrent_video.player_config_args['player_response']['videoDetails']['lengthSeconds']
Happy downloading 😃