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

Problem playing last item: HTTP Error 403: Forbidden #1071

Closed tchernomax closed 1 year ago

tchernomax commented 4 years ago

When a forbidden video is encounter in a playlist, mps-youtube stop there.

Issue / Suggestion

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/mps_youtube/main.py", line 70, in matchfunction
    func(*matches)
  File "/usr/lib/python3.8/site-packages/mps_youtube/commands/play.py", line 121, in play_all
    play(options, "1-" + str(len(g.model)))
  File "/usr/lib/python3.8/site-packages/mps_youtube/commands/play.py", line 102, in play
    g.PLAYER_OBJ.play(songlist, shuffle, repeat, override)
  File "/usr/lib/python3.8/site-packages/mps_youtube/player.py", line 79, in play
    self._playsong()
  File "/usr/lib/python3.8/site-packages/mps_youtube/player.py", line 132, in _playsong
    size = streams.get_size(self.song.ytid, self.stream['url'])
  File "/usr/lib/python3.8/site-packages/mps_youtube/streams.py", line 142, in get_size
    stream['size'] = _get_content_length(url, preloading=preloading)
  File "/usr/lib/python3.8/site-packages/mps_youtube/streams.py", line 152, in _get_content_length
    response = urlopen(url)
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  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

Problem playing last item: HTTP Error 403: Forbidden
> ERROR: zu5xfnUz7c0: YouTube said: This video contains content from SME, who has blocked it in your country on copyright grounds.

This error is fixed by https://github.com/mps-youtube/mps-youtube/pull/872

Your Environment

max@mde-oxalide % mpsyt --version
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-arch2-1-x86_64-with-glibc2.2.5
sys.stdout.enc     : utf-8
default enc        : utf-8
Config dir         : /home/max/.config/mps-youtube
env:TERM           : screen-256color
env:SHELL          : /usr/bin/zsh
env:LANG           : fr_FR.UTF-8

Archlinux

max@mde-oxalide % yay -Qi mps-youtube-git
Name            : mps-youtube-git
Version         : 0.2.8.r146.gafab9fb-1
…
Jeronimo17 commented 4 years ago

Now the whole list gives that error Edit: The problem is from youtube-dl

hypnull commented 4 years ago

See https://github.com/mps-youtube/mps-youtube/issues/1063#issuecomment-590101397 for the temporary fix

atropo commented 4 years ago

Try deleting the youtube-dl cache. Works for me:

 youtube-dl --rm-cache-dir 
timostrating commented 4 years ago

Try deleting the youtube-dl cache. Works for me:

 youtube-dl --rm-cache-dir 

The problem is related to cache memory but that commando will not always help. You need to remove this file ~/.config/mps-youtube/cache_py_* See: https://github.com/mps-youtube/mps-youtube/issues/1076#issuecomment-615467264

A temporary workaround to keep this from happening because this file will be created again after a while can be found here: https://github.com/mps-youtube/mps-youtube/issues/1063#issuecomment-602245793