Change download location to "Downloads" in Pytube in Python

Question:

I want to change the download location to "Downloads" in pytube in Python. Can anyone tell me how to do this? Thanks in advance:)

Asked By: Arefin Anwar

||

Answers:

Hope this helps:

from pytube import YouTube

youtube = YouTube('https://www.youtube.com/watch?v=5m8BAffnuA8&list=PLTgRMOcmRb3PQEztkPnMvAeehReJPoSNP')

my_video = youtube.streams.first()

my_video.download('~/Downloads')

Answered By: Hossein Heydari

use can use this import os
from pathlib import Path

path_to_download = str(os.path.join(Path.home(), ‘Downloads’))
stream.download()

Answered By: Amity
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.