ClearCode

general

Mar 24th, 2022
1,315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. from pytube import YouTube
  2.  
  3. def on_complete(stream, file_path):
  4.     print(stream)
  5.     print(file_path)
  6.  
  7. def on_progress(stream, chunk, bytes_remaining):
  8.     print(100 - (bytes_remaining / stream.filesize * 100))
  9.  
  10. video_object = YouTube(
  11.     'https://www.youtube.com/watch?v=T9vYgZJCmeI',
  12.     on_complete_callback = on_complete,
  13.     on_progress_callback = on_progress)
  14.  
  15. # video information
  16. # print(video_object.title)
  17. # print(f'{video_object.length / 60} minutes')
  18. # print(video_object.views)
  19. # print(video_object.author)
  20. # print(video_object.description)
  21.  
  22. # video streams
  23. # for stream in video_object.streams:
  24. #   print(stream)
  25. # print(video_object.streams.get_highest_resolution())
  26. # print(video_object.streams.get_lowest_resolution())
  27. # print(video_object.streams.get_audio_only())
  28.  
  29. # download
  30. video_object.streams.get_highest_resolution().download()
Advertisement
Add Comment
Please, Sign In to add comment