5
import pafy
import vlc
url = "https://www.youtube.com/watch?v=h_D3VFfhvs4"
video = pafy.new(url)

KeyError: 'dislike_count'

lol you
  • 61
  • 1
  • 1
  • 2
  • 2
    The latest commit to https://github.com/mps-youtube/pafy is from 5 months ago. Its issues page (https://github.com/mps-youtube/pafy/issues) already has reports of that exact error; clearly that module is out-of-date. There's already a Pull Request with the fix, so you'll just have to keep track of it: https://github.com/mps-youtube/pafy/pull/305 In the future I suggest doing basic research like looking at the module's official pages and all that. All this info was trivial to find. – Random Davis Dec 09 '21 at 21:40
  • Does this answer your question? [backend\_youtube\_dl.py", line 54, in \_fetch\_basic self.\_dislikes = self.\_ydl\_info\['dislike\_count'\] KeyError: 'dislike\_count'](https://stackoverflow.com/questions/70344739/backend-youtube-dl-py-line-54-in-fetch-basic-self-dislikes-self-ydl-info) – Bharel Dec 14 '21 at 07:13
  • please check this answer as it provides a working solution : [Solved pafy dislike_count error](https://stackoverflow.com/a/72417919/14000587) – Michael Amadi May 28 '22 at 17:43

4 Answers4

11

There's a less heinous solution than editing package files by using an older version of youtube-dl.

Just run pip install youtube-dl==2020.12.2

snarik
  • 1,035
  • 2
  • 9
  • 15
7

just comment the line 53 and 54 from backend_youtube_dl.py in your pafy packages path

  • 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 Dec 31 '21 at 17:55
  • if you are using a virtual env then go to .venv\Lib\site-packages\pafy\backend_youtube_dl.py and comment out the 54 line – carlo711 Jan 30 '22 at 13:59
  • And if you are working with jupyter notebooks you need to restart your kernel to make those changes work with your code – Adam Kuzański Sep 02 '22 at 23:36
1

I face this same issue [solved]:

Here is problem screenshot: Key Error Pafy "dislike_count"

How solve this issue?

1: Open Pafy package directory pafy keyword dislike_count issue

2: Open backend_youtube_dl.py file in any txt editor

3: Add comment line number 54 pafy keyword dislike_count solution

pafy dislike_count error solved

0

Or you can replace these two lines

self._likes = self._ydl_info.get('like_count',0)
self._dislikes = self._ydl_info.get('dislike_count',0)

https://github.com/mps-youtube/pafy/pull/288

buddemat
  • 4,552
  • 14
  • 29
  • 49
Peques
  • 1
  • 1