-1

I'm trying to use the Pafy library in Python, so i just followed the documentation and tried to create new Pafy object:

>>> import pafy
>>> myvid=pafy.new("https://youtu.be/kXYiU_JCYtU")

but i got the message like

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    myvid=pafy.new("https://youtu.be/kXYiU_JCYtU")
  File "C:\Python\lib\site-packages\pafy\pafy.py", line 125, in new
    return Pafy(url, basic, gdata, signature, size, callback, ydl_opts)
  File "C:\Python\lib\site-packages\pafy\backend_youtube_dl.py", line 29, in __init__
    super(YtdlPafy, self).__init__(*args, **kwargs)
  File "C:\Python\lib\site-packages\pafy\backend_shared.py", line 95, in __init__
    self._fetch_basic()
  File "C:\Python\lib\site-packages\pafy\backend_youtube_dl.py", line 53, in _fetch_basic
    self._category = self._ydl_info['categories'][0]
TypeError: 'NoneType' object is not subscriptable

Does anyone know how to fix it?

WhiteRaven
  • 13
  • 3
  • 1
    Possible duplicate of [Python Math - TypeError: 'NoneType' object is not subscriptable](https://stackoverflow.com/questions/9320766/python-math-typeerror-nonetype-object-is-not-subscriptable) – dfundako Mar 15 '18 at 14:12

1 Answers1

0

make you if have all dependencies

$ python3 -m venv _venv
$ source _venv/bin/activate
$ pip install pafy
Successfully installed pafy-0.5.4
$ pip install youtube_dl
Successfully installed youtube-dl-2018.3.14
$ pip freeze
pafy==0.5.4
youtube-dl==2018.3.14
$ python
>>> import pafy
>>> url = "https://youtu.be/kXYiU_JCYtU"
>>> myvid=pafy.new(url)
>>> myvid
Title: Numb (Official Video) - Linkin Park
Author: Linkin Park
ID: kXYiU_JCYtU
Duration: 00:03:06
Rating: 4.91022443771
Views: 804098340
Thumbnail: http://i.ytimg.com/vi/kXYiU_JCYtU/default.jpg
>>> exit()
$ deactivate
alp
  • 389
  • 2
  • 5