python pafy youtube to mp3 error, KeyError: 'dislike_count'

625 Views Asked by At

this is my code it is very simple:

import pafy
link = input("paste youtube link:  ")

video = pafy.new(link)
bestaudio = video.getbestaudio()
print(video.title)
bestaudio.download()

and this is the error:

Traceback (most recent call last): File "c:\Users\neodi\Desktop\yt to mp3\input.py", line 4, in video = pafy.new(link) File "C:\Users\neodi\AppData\Roaming\Python\Python310\site-packages\pafy\pafy.py", line 124, in new return Pafy(url, basic, gdata, size, callback, ydl_opts=ydl_opts) File "C:\Users\neodi\AppData\Roaming\Python\Python310\site-packages\pafy\backend_youtube_dl.py", line 31, in init super(YtdlPafy, self).init(*args, **kwargs) File "C:\Users\neodi\AppData\Roaming\Python\Python310\site-packages\pafy\backend_shared.py", line 97, in init self._fetch_basic() File "C:\Users\neodi\AppData\Roaming\Python\Python310\site-packages\pafy\backend_youtube_dl.py", line 54, in _fetch_basic self._dislikes = self._ydl_info['dislike_count'] KeyError: 'dislike_count'

can anyone help? and thank you if you do

2

There are 2 best solutions below

0
JialeDu On

Temporary fix:

run pip install -e git+git://github.com/mohamed-challal/pafy.git@develop#egg=pafy or simply add -e git+git://github.com/mohamed-challal/pafy.git@develop#egg=pafy to your requirements.txt

1
José Francisco Jiménez On

I commented the backend_youtube_dl.py file

line 53 and 54.