0

我想通过以下代码获得一个带有 pafy 的 youtube 播放列表标题:

import pafy
url = 'https://www.youtube.com/playlist?list=PLrSOXFDHBtfFrlG51dj8p_zCV994yWahY'
playlist = pafy.get_playlist(url)
print('Title:',playlist['title'])

当我执行它时,我得到了这个:

回溯(最近一次通话最后):

文件“F:\logiciel\informatique\programmation\Python\Projets\02_video_downloader\WX\final\PAF\01pla.py”,第 5 行,在

playlist = pafy.get_playlist(url)

文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pafy\playlist.py”,第 58 行,在 get_playlist

allinfo = fetch_decode(url)  # unicode

文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pafy\pafy.py”,第 67 行,在 fetch_decode

req = g.opener.open(url)

文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 531 行,打开

response = meth(req, response)

http_response 中的文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 640 行

response = self.parent.error(

文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 563 行,错误

result = self._call_chain(*args)

_call_chain 中的文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 502 行

result = func(*args)

文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 755 行,位于 http_error_302

return self.parent.open(new, timeout=req.timeout)

文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 531 行,打开

response = meth(req, response)

http_response 中的文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 640 行

response = self.parent.error(

文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 569 行,错误

return self._call_chain(*args)

_call_chain 中的文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 502 行

result = func(*args)

文件“C:\Users\hedid\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py”,第 649 行,位于 http_error_default

raise HTTPError(req.full_url, code, msg, hdrs, fp)

urllib.error.HTTPError:HTTP 错误 404:未找到

请问有什么解决办法吗?谢谢你。

4

0 回答 0