OS: mac os x 10.15.5 python: 3.8.0 python version control: pyenv
pytube is a python library that installs youtube videos. Since google has released youtube Data API, use the youtube video download function for business etc. In that case, we recommend that you do not use pytube.
pytube is a private, non-profit activity and should be used to the extent that it does not send excessive requests.
If you are using python3, please install pytube3.
pip install pytube3
If you are using python2, please install pytube.
pip install pytube
youtube_links.csv
https://www.youtube.com/watch?v=-VoogELsBms
https://www.youtube.com/watch?v=cN1qnAx8tqg
main.py
import csv
from pytube import YouTube
def download(url, index):
yt = YouTube(url)
print(str(index) + "Download the second video.")
yt.streams.filter(progressive=True, file_extension='mp4').order_by(
'resolution').desc().first().download('./news', str(index))
with open('youtube_links.csv') as f:
reader = csv.reader(f)
for index, row in enumerate(reader):
url = row[0]
print("start download")
download(url, index)
print("completed download")
$ python main.py
I will post the source code on github. https://github.com/SeiyaTakahashi/pytube3-project
Recommended Posts