mps-youtube / yewtube

yewtube, forked from mps-youtube , is a Terminal based YouTube player and downloader. No Youtube API key required.
GNU General Public License v3.0
8.07k stars 648 forks source link

Cache Error caused by setting another API Key #1070

Closed scoronado12 closed 4 years ago

scoronado12 commented 4 years ago

General Summary

In the wake of issue #1063, I have decided to register my own API keys to use with mps-youtube. Every once in a while that causes the following python error.

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/pafy/util.py", line 34, in call_gdata
    data = g.opener.open(url).read().decode('utf-8')
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/mpsyt", line 11, in <module>
    load_entry_point('mps-youtube==0.2.8', 'console_scripts', 'mpsyt')()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2859, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.8/site-packages/mps_youtube/__init__.py", line 8, in <module>
    init.init()
  File "/usr/lib/python3.8/site-packages/mps_youtube/init.py", line 62, in init
    cache.load()
  File "/usr/lib/python3.8/site-packages/mps_youtube/cache.py", line 34, in load
    pafy.load_cache(cached['pafy'])
  File "/usr/lib/python3.8/site-packages/pafy/pafy.py", line 184, in load_cache
    set_categories(newcache.get('categories', {}))
  File "/usr/lib/python3.8/site-packages/pafy/pafy.py", line 171, in set_categories
    catinfo = call_gdata('videoCategories', query)
  File "/usr/lib/python3.8/site-packages/pafy/util.py", line 42, in call_gdata
    raise GdataError(errmsg)
pafy.util.GdataError: Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project 422897895433 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=422897895433 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

Enviroment

mpsyt version      : 0.2.8
   notes           : released 17 February 2018
pafy version       : 0.5.5 (youtube-dl backend)
youtube-dl version : 2020.03.24
Python version     : 3.8.2 (default, Feb 26 2020, 22:21:03) 
[GCC 9.2.1 20200130]
Processor          : 
Machine type       : x86_64
Architecture       : 64bit, ELF
Platform           : Linux-5.5.13-arch1-1-x86_64-with-glibc2.2.5
sys.stdout.enc     : utf-8
default enc        : utf-8
Config dir         : /home/scoronado/.config/mps-youtube
env:TERM           : xterm-256color
env:SHELL          : /usr/bin/zsh
env:LANG           : en_US.UTF-8

OS: Arch Linux Package Used: mps-youtube-git 0.2.8.r146.gafab9fb-1

Mitigation

To solve this, I would have to delete ~/.config/mps-youtube/cache_py_3.8.* which really should not be a full solution.

ryanhilton commented 4 years ago

@scoronado12 Thanks for posting the fix for this, I appreciate it!

dkao1978 commented 4 years ago

This also causes api_key issues:

pafy.util.GdataError: Youtube Error 403: The request cannot be completed because you have exceeded your <a href="/youtube/v3/getting-started#quota">quota</a>.

Given the above error, I tried using set api_key and modifying config.py. Both failed until I cleared cache_py_3.*.py