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.")
Learn More →
此時進去的連結就是你要下載的清單
Learn More →
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")
Learn More →
Learn More →
祝你有個美好的一天
<a href = "https://hackmd.io/@HIPP0/notebook"><img src="http://n.sinaimg.cn/sinacn20122/764/w1280h1084/20190909/d990-iekuaqt0941767.jpg" height = 25> Hippotumux</a>
Jan 6, 2025上課內容統整
Oct 7, 2024@-moz-document regexp(‘https://.hackmd.io/.’) {
Jul 15, 2024or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up