ZussM4n
ZussM4n

Reputation: 35

How do i change the directory of a downloaded video?

I did this simple python program using tkinter and pytube, for downloading youtube videos. It works perfectly fine, but i want to change the destination folder and don't know how.

from tkinter import*
from pytube import YouTube

root = Tk()
root.geometry('500x300')
root.resizable(0,0)
root.title("Youtube Video Downloader")

Label(root,text = 'Youtube Video Downloader', font = 'arial 20 bold').pack()

#field for entering link
link = StringVar()
Label(root, text='Paste link here:', font = 'arial 15 bold').place(x = 160, y = 60)
link_enter = Entry(root, width = 70, textvariable = link).place(x = 32, y = 90)

#def for downloading
def Downloader():     
 url =YouTube(str(link.get()))
 video = url.streams.first()
 video.download()
 Label(root, text = 'DOWNLOADED', font = 'arial 15').place(x= 180 , y = 210)
 
Button(root,text = 'DOWNLOAD', font = 'arial 15 bold' ,bg = 'pale violet red', padx = 2, command = Downloader).place(x=180 ,y = 150)
root.mainloop()

Upvotes: 0

Views: 847

Answers (1)

Paul
Paul

Reputation: 46

Just like this:

yt_url = YouTube("your url to the video which should be downloaded")
yt_vid = yt_url.streams.filter(file_extension="mp4").first()
mp4file = yt_vid.download(output_path="path where video should be stored")

So, you have to put output_path into your download function:

#def for downloading
def Downloader():     
 url =YouTube(str(link.get()))
 video = url.streams.first()
 video.download(output_path="path where the video should be stored")

Upvotes: 3

Related Questions