pip install pytube
from pytube import YouTube from pytube import Playlist import os # youtube清單 playlist = Playlist('https://www.youtube.com/playlist?list=PLL7LXvkhjsoKqhM5eLDub6D8BdJUEKGF0') # 你要放的位置 target_path = "e:" totol = len(playlist) t = 0 for url in playlist.video_urls: t = t + 1 print("==============") print("總共%d首歌" % totol) print(">>>>目前第%d首歌" % (t)) yt = YouTube(url) video = yt.streams.filter(only_audio=True).first() out_file = video.download(output_path=target_path) base, ext = os.path.splitext(out_file) new_file = base +'z'+ '.mp3' os.rename(out_file, new_file) print("target path = " + (new_file)) print("mp3 has been successfully downloaded.")
此時進去的連結就是你要下載的清單
pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W
請到你的錯誤訊息裡面,按一下有寫 cipher.py 的連結 (ctrl + 左鍵 還是 右鍵)
到大約第30行,把 var_regex 從
var_regex = re.compile(r"^\w+\W")
改成下面這一行
var_regex = re.compile(r"^\$*\w+\W")
祝你有個美好的一天
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up