im currently getting a key error when trying to download a playlist, anyone know a fix for this?
File "C:\Python34\lib\tkinter\__init__.py", line 1487, in __call__
return self.func(*args)
File "D:/Pycharm/idk/playlist activator/youtubedownloaderguiNEW.py", line 38, in func
pl.download_all('C:\\pythonmusic',prefix_number= True)
File "C:\Users\nicton\PycharmProjects\abs\venv\lib\site-packages\pytube\contrib\playlist.py", line 172, in download_all
dl_stream.download(download_path, filename_prefix=prefix)
File "C:\Users\nicton\PycharmProjects\abs\venv\lib\site-packages\pytube\streams.py", line 206, in download
filename = filename or self.default_filename
File "C:\Users\nicton\PycharmProjects\abs\venv\lib\site-packages\pytube\streams.py", line 176, in default_filename
title = self.player_config_args['title']
KeyError: 'title'
Me Too.
Something happening here...
I Just tried to download youtube video, It worked well until yesterday But error came out from today
I think something changed in Youtube system
File "/usr/local/lib/python3.5/dist-packages/pytube/streams.py", line 206, in download
filename = filename or self.default_filename
File "/usr/local/lib/python3.5/dist-packages/pytube/streams.py", line 176, in default_filename
title = self.player_config_args['title']
KeyError: 'title'
Please...
Same here lads - it worked yesterday but not today! I have been breaking my head for about 30 minutes now to find a fix.
I am a super beginner in the field and I wanted to devise a simple program that will ask for a YT url-> confirm the title that I want to dl->ask for download location ->confirm download location-> proceed to download
This is the error I get:
Traceback (most recent call last):
File "C:/Users/David/PycharmProjects/Ultimate YT Downloader/Ultimate YT Downloader.py", line 14, in
print ("Download item: " + yt.title)
File "C:UsersDavidPycharmProjectsUltimate YT Downloadervenvlibsite-packagespytube__main__.py", line 254, in title
return self.player_config_args['title']
KeyError: 'title'
Process finished with exit code 1
My code below:
import sys
import __future__
import pytube
import os
from pytube import YouTube
download_link = input ("Please insert download link: ")
yt = YouTube(download_link)
print ("Download item: " + yt.title)
download_folder = input ("Please insert download folder location:")
print ("Target folder is set to " + download_folder)
YouTube(download_link).streams.first().download(download_folder)
Seems like a general error getting the video title:
>>> from pytube import YouTube
>>> yt = YouTube('https://www.youtube.com/watch?v=9bZkp7q19f0')
>>> yt.title
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pytube/__main__.py", line 254, in title
return self.player_config_args['title']
KeyError: 'title'
Hopefully that pull request fixes the problem.
@ndg63276 Thanks for the PR; it seems to fix the issue in the YouTube class, but Stream suffers from the same issue at streams.py:176.
@shostakun - Ok, try it now,
@ndg63276 that latest fix is working for me. I am able to download videos now. Thanks.
@ndg63276 that latest fix is working for me. I am able to download videos now. Thanks.
How did you fix it?
@TheGameIsAboutGlory using the commit the ndg63276 just pushed
@ndg63276 It's working! Thank you.
it worked for me too, at first thumbnail_url,title,length where not working but they are working now. check out commits on https://github.com/ndg63276/alexa-youtube/commit/94d671dbd5c214a88df6d568b745c36b272b2dc4
it worked for me too, at first thumbnail_url,title,length where not working but they are working now. check out commits on ndg63276/alexa-youtube@94d671d
What is wrong with me...
Even though I fix that code part, I still have KeyError : title from streams.py
@TheGameIsAboutGlory there is also a change to streams.py, you can see it here: https://github.com/nficano/pytube/pull/435/files
sorry, https://github.com/nficano/pytube/issues/434#issuecomment-516767955 i also just realised it.
Thank you https://github.com/nficano/pytube/issues/434#issuecomment-516771176
Same here with KeyError: 'length_seconds'
@Klakinoumi - there is a fix for length_seconds as part of https://github.com/nficano/pytube/pull/435/files
@ndg63276 Yeah I saw it after posting. Thanks for your help resolving the issue it is greatly appreciated. How can I apply your "patch" easily (sorry I quite a noob on github)?
Thank you Guys So Much!~!~!
You Guys Saved me.
Thanks a lot
Downloading Video is now working fine :)
@Klakinoumi - If you use git from the command line, use this command:
git pull origin pull/435/head
If not, you may just have to edit the 2 files manually.
@ndg63276 Ah ! Thanks for the info.
The reason for this problem is that youtube return on getting video info this 'reason=Invalid+parameters.&status=fail&errorcode=2'. Need to check what youtube return in prefetch method after self.vid_info = request.get(self.vid_info_url)
Hopefully that pull request fixes the problem.
Working. thank you
I executed "git pull origin pull/435/head", compile && install then tried to download a file
YouTube('https://www.youtube.com/watch?v=602kWwpHmt0&list=RD602kWwpHmt0&start_radio=1').streams.filter(progressive=True).first().download() and I got this forbidden error
File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
@josanabr - might be worth raising a new ticket for that, looks like a new issue.
I executed "git pull origin pull/435/head", compile && install then tried to download a file
YouTube('https://www.youtube.com/watch?v=602kWwpHmt0&list=RD602kWwpHmt0&start_radio=1').streams.filter(progressive=True).first().download() and I got this forbidden error
File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
I faced the very same problem but i managed to solve it using two other fixes:
Hope it helps.
@TheGameIsAboutGlory there is also a change to streams.py, you can see it here: https://github.com/nficano/pytube/pull/435/files
this works!
pip update pytube isn't fixing this. Can I please have some instructions on what I need to do?
You have to edit the source files for pytube on your computer. You will then need to make the following changes below https://github.com/nficano/pytube/pull/435/files. The quickest way to find the files for Pytube, is to import pytube and check it鈥檚 ___file___ method!
In order to fix the KeyError, you have to specify the filename in the download() functions parameters because pytube looks for a specified filename and if that is not set then it looks for the default title in the self.player_config_args['title'] dictionary entry.
In your script to download a video explicitly define the file name in this one liner
Code Fix:
YouTube(link).streams.first().download(output_path=path, filename=filename)
Hi, it didn't solve the problem for me...
Buit this issue did!
Thanks a lot it works for me as well.
I did it!! Thank you!!!
import os
YouTube(link).streams.first().download(output_path=os.getcwd(), filename="myvid")
It worked for me when I specified the filename parameter of download function:
YouTube(link).streams.first().download(output_path=path, filename=filename)
fixed in my Python 3 only fork: https://github.com/hbmartin/pytube3
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.
Most helpful comment
Hopefully that pull request fixes the problem.