I have a problem with dislike error when creating an pafy.new url, perhaps it's because youtube hid numer of dislikes
Asked Answered
W

4

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

KeyError: 'dislike_count'

Workroom answered 9/12, 2021 at 21:38 Comment(3)
The latest commit to github.com/mps-youtube/pafy is from 5 months ago. Its issues page (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: 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.Germanous
Does this answer your question? backend_youtube_dl.py", line 54, in _fetch_basic self._dislikes = self._ydl_info['dislike_count'] KeyError: 'dislike_count'Player
please check this answer as it provides a working solution : Solved pafy dislike_count errorTellurium
L
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

Lebron answered 16/1, 2022 at 0:41 Comment(0)
I
7

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

Ing answered 31/12, 2021 at 14:14 Comment(3)
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.Blackmore
if you are using a virtual env then go to .venv\Lib\site-packages\pafy\backend_youtube_dl.py and comment out the 54 lineVale
And if you are working with jupyter notebooks you need to restart your kernel to make those changes work with your codeHalfassed
S
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

Swarts answered 23/9, 2022 at 18:31 Comment(2)
good solve it work fine :) but I have docker image :( your solution need to do manual work ...Swindle
I had to comment out likes and dislikes FYI (Jan 2023)Elielia
F
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

Fleabane answered 9/2, 2023 at 20:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.