> 2024/07/30 (火) 08:00:35 ◆ ▼ ◇ [misao]> Youtubeを高画質でDLする際と教えて(;´Д`)
from pytube import YouTube
# Function to download YouTube video
def download_youtube_video(url, save_path="."):
try:
# Create a YouTube object
yt = YouTube(url)
# Get the highest resolution stream available
stream = yt.streams.get_highest_resolution()
# Download the video
stream.download(save_path)
print(f"Video downloaded successfully and saved to {save_path}")
except Exception as e:
print(f"An error occurred: {e}")
# Input URL
url = input("Enter the YouTube video URL: ")
# Specify the path to save the video
save_path = input("Enter the path to save the video (leave blank for current directory): ")
if not save_path:
save_path = "."
# Download the video
download_youtube_video(url, save_path)
gptくんに作ってもらったよ(;´Д`)pip install pytubeしてね
参考:2024/07/30(火)07時47分15秒