So i have a browse button that indicates a path for a download but since it puts out a regular string it won't download since there are backslashes involved and they aren't litteraly interpreted. Edit: I added other parts of my code a bit since some parts weren't really clear.
def browse():
global folder_path
filename = filedialog.askdirectory()
Path = filename
print(Path)
BROWSEbutton = tk.Button(src, text="Browse", font="Courier 12", command=browse).place(x=425,y=0)
def Convert():
try:
video = yt.YouTube(URL.get()).streams.first()
try:
video.download(Path)
print("succesful")
except:
print("error")
msgb.showerror("Error","Invalid Path")
except:
print("error")
msgb.showerror("Error","Invalid URL")
CONVERTbutton = tk.Button(src, text="Convert", font="Courier 12",command=Convert).place(x=243,y=220)
folder_path
and you are not using itfolder_path
should have been used.filedialog.askdirectory()
also works for video.download()
after removing these mistakes your code should be,
folder_path=""
def browse():
global folder_path
folder_path = filedialog.askdirectory()
print(folder_path)
def Convert():
global folder_path
try:
video = yt.YouTube(URL.get()).streams.first()
try:
video.download(folder_path)
print("succesful")
except:
print("error")
msgb.showerror("Error","Invalid Path")
except:
print("error")
msgb.showerror("Error","Invalid URL")
BROWSEbutton = tk.Button(src, text="Browse", font="Courier 12", command=browse).place(x=425,y=0)
CONVERTbutton = tk.Button(src, text="Convert", font="Courier 12",command=Convert).place(x=243,y=220)
hope this helps you!