-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyError: 'url_encoded_fmt_stream_map' #467
Comments
I have the same, it was working this morning and now I get the same error. |
I'm assuming that YouTube has changed something big as both ytdl-org/youtube-dl and TeamNewPipe/NewPipe are having similar issues. |
All those "free youtube downloader" websites that my co-workers often use seem to be broken as well, so YouTube definitely changed something. |
I found ytdl-org/youtube-dl@bf1317d from youtube-dl, but no idea how to port the change to pytube. |
Got the same error. I thought it was only on a specific set of url's but it seems to be on every one of them :(( |
Same here, stuck with the |
The strange part was that I started using pytube just a few hours ago. All of the sudden the commands that I was using were not working anymore. |
Seems like this line: |
it seems everything works again. I have the same problem this morning, but now the same script works like before. So definitely, it's Youtube side thing. |
confirm that everything is working again. |
It's see stream_data without [url_encoded_fmt_stream_map] Key in mixins |
It seems some video has this "url_encoded_fmt_stream_map" key, and some does not. fEnC5gwNAN0 has the key, but So, pytube would work on the first video, but not the second video. To find out if the video has the "url_encoded_fmt_stream_map" key, one can obtain it from a browser with the follow: Sorry, that I don' t have a solution. Hopefully, get_video_info could help someone to show us a solution. |
The reason for getting this KeyError is that there are many videos in YouTube now which does not have 'url_encoded_fmt_stream_map' and 'adaptive_fmts' keys in self.player_config_args. |
you can replace the apply_descrambler function inside the mixins.py file with the following if key == 'url_encoded_fmt_stream_map' and not stream_data.get('url_encoded_fmt_stream_map'):
formats = json.loads(stream_data['player_response'])['streamingData']['formats']
formats.extend(json.loads(stream_data['player_response'])['streamingData']['adaptiveFormats'])
stream_data[key] = [{u'url': format_item[u'url'],
u'type': format_item[u'mimeType'],
u'quality': format_item[u'quality'],
u'itag': format_item[u'itag']} for format_item in formats]
else:
stream_data[key] = [
{k: unquote(v) for k, v in parse_qsl(i)}
for i in stream_data[key].split(',')
]
logger.debug(
'applying descrambler\n%s',
pprint.pformat(stream_data[key], indent=2),
) |
Im having issues with this fix, with latest pytube im getting url not found errors on videos: |
@bennyb518 attempted implementation of your code as above, but i'm receiving the error: KeyError: 'url' now... Traceback (most recent call last): |
I am also experiencing this issue. |
@bennyb518 tested your fix for a few videos that didn't work before and for a few that did work, and now they all worked correctly. Thanks! |
@bennyb518 tested the fix too. Fixed it for a few videos, did not for some others. You should still commit your solution? |
@bennyb518 tested that fix and it seems to work |
try @bennyb518 and somes video still have error because formats not include have "url" key, it replace by "cipher" so I made some change like this (I have learnt python about 2 months, so may be my code is a little long, may be someone can improve, but it work) :
|
Created a fix for this bug. If you want to install the package with the fix before it gets to the main package, run the following: |
@giacaglia it seems to work, thanks for forking and patching it ! |
@giacaglia thanks, it works, but default ordering doesn't work anymore, I always have to add .order_by('resolution').desc() |
I am facing an error like this and the Key Error of 'url_encoded_fmt_stream_map' is not fixed |
Thanks for the fix. Really appreciate it. @giacaglia |
Hello ! How can I fix this ? |
still broke after pip install git+, i'm getting KeyError: 'url' like jakub and also VideoUnavailable sometimes for v=bLfcwDZ5GzQ |
I implemented the code provided by @FidoDidoVN , and it works very well. All we need to do is to replace the code provided by @FidoDidoVN in the apply_descrambler function within the mixins.py file. |
hello! |
thank you,it works |
@ValentiaSulli can you show your code? may be your code is wrong. 'YouTube' object has no attribute 'download', you have to use this code: YouTube(link video).streams.first().download(yours path). For more advanced you can google how to download youtube video by pytube |
I get this Error after benny518's solution: |
Funcionou perfeitamente! |
Thank you @FidoDidoVN. This Solution Works for me :) |
Just wondering if someone could provide a PR to integrate the fix upstream? Manually patching source code is a quick workaround only. |
I wouldn't count on it any time soon. This repo almost seems abandoned. The last commit was in October. There are 151 issues and 49 PRs. This issue has been open since September. But the owner was making commits on other repos 3 days ago. |
I was wondering about this as well. @nficano - are you the only maintainer? Is there a current status of the project? If it's 'abandoned' or 'looking for maintainers' - maybe this could be reflected in the README file, and maybe others are interested in taking over/helping out... |
fixed in my Python 3 only fork: https://github.com/hbmartin/pytube3 |
@hbmartin i am getting this error using your fork |
@pintonos this is a recent YouTube change, tracking work in: https://github.com/hbmartin/pytube3/issues/12 |
I am getting this |
clone repo from https://github.com/hbmartin/pytube3 |
@braindotai Thanks! |
Please don't do this. It will prevent you from getting pytube3 upgrades and will probably lead to weird bugs. Better to ‘pip uninstall pytube; pip install pytube3’ |
That's correct 👍 |
@bennyb518 it still returns error please help me out |
I combined the two solutions in this thread as well as added support for another error:
Pull Requests have been made to both this repo and that of @giacaglia. As of writing the |
ImportError: cannot import name 'quote' from 'pytube.compat' (/home/islam/projects/youtube/venv/lib/python3.7/site-packages/pytube/compat.py) |
I hereby thank you officially in the name of the whole planet.
|
Seems like starting from today every video will cause this error when initialize a YouTube instance. Is there a quick way to fix this? I was using the same code yesterday and everything works fine.
python version 3.6
I've tried various pytube version such as 8.0.0, 9.5.0 and 9.5.2. None of them works and all lead to this error.
The text was updated successfully, but these errors were encountered: