def set_video(self, vurl): if bool(self.video) and self.video.video_id == extract.video_id(vurl): return self.curr_url = vurl self.video = Youtube(vurl) self.video.register_on_progress_callback(self.update_progress) self.video.register_on_complete_callback(self.on_download_completed)
class Downloader: download_path = str(Path.home() / "Downloads") curr_url = None video = None busy = False def set_video(self, vurl): if bool(self.video) and self.video.video_id == extract.video_id(vurl): return self.curr_url = vurl self.video = Youtube(vurl) self.video.register_on_progress_callback(self.update_progress) self.video.register_on_complete_callback(self.on_download_completed) def download(self, itag): if self.busy: return False stream = self.video.streams.get_by_itag(itag) if bool(stream): stream.download(self.download_path, skip_existing=False) def update_progress(self, stream, chunk, bytes_remaining): self.busy = True total_size = stream.filesize bytes_downloaded = total_size - bytes_remaining percentage_of_completion = bytes_downloaded / total_size * 100 window.evaluate_js("updateProgress({progress});".format( progress=percentage_of_completion)) def on_download_completed(self, stream, file_path): window.evaluate_js("onDownloadCompleted({fp})".format(fp=file_path)) return def is_busy(self): return self.busy
def downloadVid(): global E1 string = E1.get() yt = Youtube(str(string)) videos = yt.get_videos() s = 1 for v in videos: print(str(s) + '.' + str(v)) s += 1 n = int(input("Enter your choice")) vid = videos[n - 1] destination = str(input("Enter your destination")) vid.download(destination) print(yt.filename + "\n Has been downloaded")
def Downlaoder(): url = Youtube(str(link.get())) video = url.streams.first() video.download() Label(YoutubeDownloader, text="Downloaded", font="arial 15 bold").place(x=180, y=210) Button(YoutubeDownloader, text="Download", font="arail 15 bold", padx=2 , pady=2, command= Downloader).place(x=180, y=150) YoutubeDownloader.mainloop()
def videosearch(vlink, format, filepath, quality): try: yt_obj = Youtube(vlink) if (format == mp4): dvideo(format, filepath, quality) else: daudio(format, filepath) except Exception as e: print(e)
url = input("Enter the link of the Youtube to be Downloaded!!!") time.sleep(3) dir = input("Enter the location of download!!!") video = pafy.new(url) print("Now Downloading /n in best resolution /n .........") time.sleep(2) #Prints video details as given print(video.title, " by:- ", video.author, "of duration", video.duration) time.sleep(2) print("Likes:-", video.likes, " Dislikes:-", video.dislikes) print("Description:-", video.description) try: sd = Youtube(url) except: print("Error in Connecting ") #filters only mp4 file mp4files = sd.filter('mp4') sd.set_filename("video.title") d_video = sd.get(mp4files[-1].extension, mp4files[-1].resolution) try: d_video.download(dir) except: print("Some Error!") print('Task Completed!')
# -*- coding: utf-8 -*- """ Created on Sat Oct 24 15:19:14 2020 @author: user """ from pytube import Youtube progress = 0 def prgress(stream, chunk, bytes_remaining): size = stream.filesize global progress preprogress = progress currentprogress = int((size - bytes_remaining) * 100 / size) progress = currentprogress if preprogress != progress: print("目前進度:" + (currentprogress) + "%") if progress == 100: print("下載完成") yt = Youtube("https://youtu.be/bdCK7JQryhQ", on_progress_callback=progress) stream = yt.streams.first() stream.download("C:\\Users\\user\\Videos\\Captures")
# importing Youtube from pytube from pytube import Youtube # asking user to enter link link = input("Enter the link ") # showing user that the process has started print("Downloading...") # main code to download video Youtube(link).streams.first().download() # showing user that the video has downloaded print("Video downloaded sucessfully")
from pytube import Youtube from pytube import playlsit url = 'https://youtu.be/DXUAyRRkI6k' ytd = Youtube(url).streams.first().download() print(ytd)
from pytube import YouTube as Youtube link = input('link to youtube video: ') yt = Youtube(link) yt.streams.filter(progressive=True, file_extension='mp4', res='720p').first().download() print('downloaded', link)
def Downloader(self): Youtube( self.youtubeurl.text).streams.get_highest_resolution().download( "C:\\Users\\julio\\Videos")
def onClick(): global var var.set(entry.get()) yt=Youtube(var.get(),on_progress_callback=showProgress) stream=yt.streams.first stream.downlaod()
from pytube import Youtube link = input("O link: ") video = Youtube(link) stream = video.streams.get_highest_resolution() stream.download