| 23 | |
| 24 | # function start download to start the download of files |
| 25 | def startDownload(): |
| 26 | global file_size |
| 27 | try: |
| 28 | URL = urlField.get() |
| 29 | dBtn.config(text="Please wait...") |
| 30 | dBtn.config(state=DISABLED) |
| 31 | path_save = askdirectory() |
| 32 | if path_save is None: |
| 33 | return |
| 34 | ob = YouTube(URL, on_progress_callback=progress) |
| 35 | strm = ob.streams[0] |
| 36 | x = ob.description.split("|") |
| 37 | file_size = strm.filesize |
| 38 | dfile_size = file_size |
| 39 | dfile_size /= 1000000 |
| 40 | dfile_size = round(dfile_size, 2) |
| 41 | label.config(text="Size: " + str(dfile_size) + " MB") |
| 42 | label.pack(side=TOP, pady=10) |
| 43 | desc.config( |
| 44 | text=ob.title |
| 45 | + "\n\n" |
| 46 | + "Label: " |
| 47 | + ob.author |
| 48 | + "\n\n" |
| 49 | + "length: " |
| 50 | + str(round(ob.length / 60, 1)) |
| 51 | + " mins\n\n" |
| 52 | "Views: " + str(round(ob.views / 1000000, 2)) + "M" |
| 53 | ) |
| 54 | desc.pack(side=TOP, pady=10) |
| 55 | strm.download(path_save, strm.title) |
| 56 | dBtn.config(state=NORMAL) |
| 57 | showinfo("Download Finished", "Downloaded Successfully") |
| 58 | urlField.delete(0, END) |
| 59 | label.pack_forget() |
| 60 | desc.pack_forget() |
| 61 | dBtn.config(text="Start Download") |
| 62 | |
| 63 | except Exception as e: |
| 64 | print(e) |
| 65 | print("Error!!") |
| 66 | |
| 67 | |
| 68 | def startDownloadthread(): |