-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Key Error of 'Assets' when attempting to call 'YouTube()' #777
Comments
Hi, I found a problem. I don't know regex, so my solution is primitive but works fully.
Doesn't work with age-restricted videos, but now I know why, I'll post a revised code tomorrow. Today I downloaded over 500 videos without any errors. |
@vincehartman38 @AssesBesses this problem was fixed in the most recent update to the repository, so you will need to reinstall pytube in order to fix it. To install from this repository, I recommend you first uninstall pytube with |
Hello! im still encountering the same issue(yes im on the latest version of pytube) after running the test:
|
@FeedFall8 are you sure you've installed it correctly? that error is coming from code that is no longer in the codebase |
I can confirm that this version works very well. |
confirm too |
@tfdahlin yes im using latest, the error still occurs though, should i use python 3.7 rather than 3.8 for pytube? |
It will not work if you install the using the pip. I tried reinstalling "python -m pip install git+https://github.com/nficano/pytube" in command line but nothing happened. I copied the fix in the codebase and paste in the whole code in the extract.py and it works fine. @tfdahlin I don't know why pip install doesn't work for me but your fix does. thanks. |
ah ok thanks |
@FeedFall8 there are a few possible reasons that I can think of that you might be running into an issue with your installation.
|
While @arpitdiwan's solution will work as a short term solution, it will most likely be better to correctly install the package rather than rely on modifying a bad package install. |
Believe this should be fixed now in most recent version @vincehartman38 -- please reopen issue if not so. Thanks! |
We confirmed this now works. Thanks so much everyone for responding so quickly! |
When doing the following command:
I'm seeing the key error 'assets':
KeyError Traceback (most recent call last)
in
----> 1 yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
C:\Program Files\Anaconda3\lib\site-packages\pytube_main_.py in init(self, url, defer_prefetch_init, on_progress_callback, on_complete_callback, proxies)
89
90 if not defer_prefetch_init:
---> 91 self.prefetch()
92 self.descramble()
93
C:\Program Files\Anaconda3\lib\site-packages\pytube_main_.py in prefetch(self)
181 self.vid_info_raw = request.get(self.vid_info_url)
182 if not self.age_restricted:
--> 183 self.js_url = extract.js_url(self.watch_html)
184 self.js = request.get(self.js_url)
185
C:\Program Files\Anaconda3\lib\site-packages\pytube\extract.py in js_url(html)
141 The html contents of the watch page.
142 """
--> 143 base_js = get_ytplayer_config(html)["assets"]["js"]
144 return "https://youtube.com" + base_js
145
KeyError: 'assets'
The text was updated successfully, but these errors were encountered: