got the same problem, i have tested all your solution but nothing work for me :/
here is my code :
#importing libraries
from pytube import YouTube
from pytube.cli import on_progress
from customtkinter import *
#set the color theme
set_appearance_mode("System")
set_default_color_theme("blue")
# set the window
root = CTk()
root.title("Youtube Audio Downloader")
root.geometry("400x400")
root.iconbitmap("./assets/icone_ytb.ico")
#label
label = CTkLabel(root, text = "Entrez l'url de votre vidéo :", width = 250)
label.place(relx = 0.5, rely = 0.32, anchor = CENTER)
# input field
input = CTkEntry(master = root, width = 250, border_width = 0)
input.bind("<Button-1>", lambda e: input.delete(0, END))
input.place(relx = 0.5, rely = 0.4, anchor = CENTER)
# progress bar
progress_bar = CTkProgressBar(root, orient = 'horizontal')
progress_bar.place(relx = 0.5, rely = 0.58, anchor = CENTER)
progress_bar.set(0.0)
def on_complete(stream, file_path) :
print("Done !")
def on_progress(stream, chunk, file_handle, bytes_remaining):
total_size = stream.filesize
bytes_downloaded = total_size - bytes_remaining
percentage_of_completion = bytes_downloaded / total_size * 100
#function that download the video
def telecharger() :
url = str(input.get())
path = "./audios"
youtube = YouTube(url)
youtube.register_on_progress_callback(on_progress)
video = youtube.streams.get_highest_resolution()
video.download(path)
progress_bar.set(1)
# button
btn = CTkButton(master = root, text = "Valider", command = telecharger, width = 250)
btn.place(relx = 0.5, rely = 0.5, anchor = CENTER)
#run the window
root.mainloop()