0

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

  • 1
    as I remember YouTube removed `dislike count` from webpage some time ago and it may need changes in `pafy` - so you may need to check if there is newer version (and update your module `pip install --update ...`), or you will have to wait for newer version. – furas Aug 28 '22 at 17:36
  • 1
    it seems last version of [pafy](https://pypi.org/project/pafy/) is from 2019. You will have to use other module. ie. [youtube-dl](https://github.com/ytdl-org/youtube-dl) or [pytube](https://pytube.io/en/latest/) – furas Aug 28 '22 at 17:50
  • 1
    see also [KeyError: dislike\_count · Issue #306 · mps-youtube/pafy](https://github.com/mps-youtube/pafy/issues/306) – furas Aug 28 '22 at 17:52

2 Answers2

0

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

JialeDu
  • 6,021
  • 2
  • 5
  • 24
0

I commented the backend_youtube_dl.py file

line 53 and 54.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 18 '22 at 09:02