Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'dislike_count' in pafy #1180

Closed
snyamwong opened this issue Nov 22, 2021 · 8 comments
Closed

KeyError: 'dislike_count' in pafy #1180

snyamwong opened this issue Nov 22, 2021 · 8 comments

Comments

@snyamwong
Copy link

I think the API no longer returns dislike counts (given the recent Youtube fiasco with removing dislikes...), and now pafy will throw an exception when playing a video.

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/site-packages/mps_youtube/streams.py", line 180, in _preload
    streamlist = get(song)
  File "/usr/local/lib/python3.9/site-packages/mps_youtube/streams.py", line 51, in get
    p = util.get_pafy(vid, force=force, callback=callback)
  File "/usr/local/lib/python3.9/site-packages/mps_youtube/util.py", line 221, in get_pafy
    p = pafy.new(ytid, callback=callback_fn)
  File "/usr/local/lib/python3.9/site-packages/pafy/pafy.py", line 124, in new
    return Pafy(url, basic, gdata, size, callback, ydl_opts=ydl_opts)
  File "/usr/local/lib/python3.9/site-packages/pafy/backend_youtube_dl.py", line 31, in __init__
    super(YtdlPafy, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pafy/backend_shared.py", line 97, in __init__
    self._fetch_basic()
  File "/usr/local/lib/python3.9/site-packages/pafy/backend_youtube_dl.py", line 54, in _fetch_basic
    self._dislikes = self._ydl_info['dislike_count']
KeyError: 'dislike_count'

Issue / Suggestion

The easiest fix is to go into site-packages/pafy/backend_youtube_dl.py and comment out this line

#self._dislikes = self._ydl_info['dislike_count']

Your Environment

mpsyt version      : 0.2.8
   notes           : released 17 February 2018
pafy version       : 0.5.5 (youtube-dl backend)
youtube-dl version : 2021.06.06
Python version     : 3.9.8 (main, Nov 10 2021, 09:21:22) 
[Clang 13.0.0 (clang-1300.0.29.3)]
Processor          : i386
Machine type       : x86_64
Architecture       : 64bit, 
Platform           : macOS-11.4-x86_64-i386-64bit
sys.stdout.enc     : utf-8
default enc        : utf-8
Config dir         : /Users/twong/.config/mps-youtube
env:TERM           : xterm-256color
env:SHELL          : /bin/zsh
env:LANG           : en_US.UTF-8
mpv 0.34.0 Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
 built on Tue Nov 16 13:41:55 UTC 2021
FFmpeg library versions:
   libavutil       56.70.100
   libavcodec      58.134.100
   libavformat     58.76.100
   libswscale      5.9.100
   libavfilter     7.110.100
   libswresample   3.9.100
FFmpeg version: 4.4.1
@snyamwong snyamwong changed the title Key error with dislike count in pafy KeyError: 'dislike_count' in pafy Nov 22, 2021
@Sophira
Copy link

Sophira commented Nov 24, 2021

It looks like pafy already has a pull request for this, which takes the same approach: mps-youtube/pafy#305

@talhatugsat
Copy link

i found the error and solution on my own, i was going to create a pull request for their fix on github. thx

@Elias-Gill
Copy link

i found the error and solution on my own, i was going to create a pull request for their fix on github. thx

how do you fix the problem ?

@jaybharti2804
Copy link

Thanks man

@Ciliane
Copy link

Ciliane commented Dec 20, 2021

It looks like pafy already has a pull request for this, which takes the same approach: mps-youtube/pafy#305

But is it going to make in the repo and a release any time soon? This repo hasn't seen any commits in a while, is there some fork of it that is maintained?

@yardenac
Copy link

@Ciliane there's a more-maintained fork at https://github.com/otisdog8/termitube/ but they haven't merged their PR yet either

@Sophira
Copy link

Sophira commented Dec 20, 2021

@yardenac That repo is a fork of mps-youtube, but the edits need to take place in both that and pafy, which are maintained as separate projects. The pull request I linked to is the one for the pafy repo. So far as I know, there isn't a fork for that one yet.

As for termitube, it hasn't had any commits for about two and a half months either, and the project doesn't have an Issues tab so it's difficult to report issues with it. Hopefully they'll accept the pull request, but as I say, pafy needs to be updated as well.

@iamtalhaasghar
Copy link
Contributor

was fixed iamtalhaasghar#3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants