mps-youtube / pafy

Python library to download YouTube content and retrieve metadata
1.38k stars 315 forks source link

youtube_dl & internal backends are obsolete #329

Open elig0n opened 1 year ago

elig0n commented 1 year ago

youtube_dl is obsolete. yt-dlp replaced it but its backend needs to be implemented.

>>> import pafy
>>> pafy.new("https://www.youtube.com/watch?v=bMt47wvK6u0")
ERROR: Unable to extract uploader id; please report this issue 
on https://yt-dl.org/bug . Make sure you are using the latest v
ersion; see  https://yt-dl.org/update  on how to update. Be sur
e to call youtube-dl with the --verbose flag and include its co
mplete output.
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    pafy.new("https://www.youtube.com/watch?v=bMt47wvK6u0")
  File "/home/user/.local/lib/python3.10/site-packages/pafy/pafy.py", line 124, in new
    return Pafy(url, basic, gdata, size, callback, ydl_opts=ydl_opts)
  File "/home/user/.local/lib/python3.10/site-packages/pafy/backend_youtube_dl.py", line 31, in __init__
    super(YtdlPafy, self).__init__(*args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/pafy/backend_shared.py", line 97, in __init__
    self._fetch_basic()
  File "/home/user/.local/lib/python3.10/site-packages/pafy/backend_youtube_dl.py", line 43, in _fetch_basic
    raise IOError(str(e).replace('YouTube said', 'Youtube says'
))
OSError: ERROR: Unable to extract uploader id; please report th
is issue on https://yt-dl.org/bug . Make sure you are using the
 latest version; see  https://yt-dl.org/update  on how to updat
e. Be sure to call youtube-dl with the --verbose flag and inclu
de its complete output.

Internal backend looks outdated as well:

>>> import pafy
>>> pafy.new("https://www.youtube.com/watch?v=bMt47wvK6u0")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    pafy.new("https://www.youtube.com/watch?v=bMt47wvK6u0")
  File "/home/user/.local/lib/python3.10/site-packages/pafy/pafy.py", line 124, in new
    return Pafy(url, basic, gdata, size, callback, ydl_opts=ydl_opts)
  File "/home/user/.local/lib/python3.10/site-packages/pafy/backend_internal.py", line 42, in __init_
_
    super(InternPafy, self).__init__(*args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/pafy/backend_shared.py", line 97, in __init__
    self._fetch_basic()
  File "/home/user/.local/lib/python3.10/site-packages/pafy/backend_internal.py", line 50, in _fetch_
basic
    allinfo = get_video_info(self.videoid, self.callback)
  File "/home/user/.local/lib/python3.10/site-packages/pafy/backend_internal.py", line 271, in get_vi
deo_info
    sts = re.search(r'sts"\s*:\s*(\d+)', embed_webpage).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
jjmachan commented 1 year ago

I'm really new to youtube-dl and pafy but wanted to use this for a project of mine. Seems like we need to change the backend to support yt-dlp also?

I'll look into this and see if this is something I can contribute

elig0n commented 1 year ago

I'm really new to youtube-dl and pafy but wanted to use this for a project of mine. Seems like we need to change the backend to support yt-dlp also?

I'll look into this and see if this is something I can contribute

look around in the other issues you will find there are a few methods to adapt it to yt-dlp, i.e. link the youtube-dl binary to yt-dlp