提问人:StrangePigeon79 提问时间:11/18/2023 最后编辑:StrangePigeon79 更新时间:11/18/2023 访问量:25
收到 pytube.exceptions.RegexMatchError:regex_search:找不到匹配项 (?:v=|\/)([0-9A-Za-z_-]{11}).* 错误。溶液?
Getting pytube.exceptions.RegexMatchError: regex_search: could not find match for (?:v=|\/)([0-9A-Za-z_-]{11}).* error. Solution?
问:
当我运行这部分代码时,我收到了已经提到的错误:
def downlad_playlist(listurl, destination, only_audio = True):
list_url = Playlist(listurl)
print(f'Downloading: {list_url.title}')
for url in list_url.video_urls:
vid_url = YouTube(url)
window["-DOWNLOAD_TEXT-"].update("Downloading: " + vid_url.title)
window.refresh()
vid_url.register_on_progress_callback(on_progress)
# try:
video = vid_url.streams.filter(only_audio=True).first()
out_file = video.download(output_path=destination)
完整的错误消息:
Traceback (most recent call last):
File "C:\Users\gamer\Desktop\yt-py\yt_downloaderV3.py", line 111, in <module>
download_video(values["-YOUTUBE_URL-"], values["-SAVE_LOCATION-"])
File "C:\Users\gamer\Desktop\yt-py\yt_downloaderV3.py", line 36, in download_video
yt = YouTube(url)
^^^^^^^^^^^^
File "C:\Users\gamer\Desktop\yt-py\venv\Lib\site-packages\pytube\__main__.py", line 71, in __init__
self.video_id = extract.video_id(url)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\gamer\Desktop\yt-py\venv\Lib\site-packages\pytube\extract.py", line 133, in video_id
return regex_search(r"(?:v=|\/)([0-9A-Za-z_-]{11}).*", url, group=1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\gamer\Desktop\yt-py\venv\Lib\site-packages\pytube\helpers.py", line 129, in regex_search
raise RegexMatchError(caller="regex_search", pattern=pattern)
pytube.exceptions.RegexMatchError: regex_search: could not find match for (?:v=|\/)([0-9A-Za-z_-]{11}).*
我正在使用 pysimplegui 作为 GUI。
URL 是正确的,代码在其他项目中运行良好,所以我不知道为什么它会出错。
可能我搞砸了一些简单的东西,但我找不到它,所以我在这里寻求帮助。
答: 暂无答案
评论
YouTube(url)