###### tags: `Python` # 批量下載 youtube 影片 ```cmd pip install pytube ``` ```python= from pytube import YouTube # 放入所有要下載影片的網址 video_name = ['https://www.youtube.com/watch?','https://www.youtube.com/'] j = 0 for i in video_name: # 建立 YouTube 物件 yt = YouTube(video_name[j]) # 影片標題 print(yt.title) # 篩選 progressive 類型的 MP4 影片格式 progMP4 = yt.streams.filter(progressive=True, file_extension='mp4') # 找出解析度最好的 MP4 影片 targetMP4 = progMP4.order_by('resolution').desc().first() # 下載影片並儲存至 /tmp/youtube_dl 目錄 video_file = targetMP4.download("C:\\Users\Admin\Desktop\movie") j+=1 ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up