Skip to content

Instantly share code, notes, and snippets.

@bhuiyanmobasshir94
Created October 19, 2020 06:47
Show Gist options
  • Save bhuiyanmobasshir94/8bab80981a9a7023b9540df349ae6c6e to your computer and use it in GitHub Desktop.
Save bhuiyanmobasshir94/8bab80981a9a7023b9540df349ae6c6e to your computer and use it in GitHub Desktop.
import pafy
import os
os.environ["PAFY_BACKEND"] = "internal"
PAFY_BACKEND = "internal"
url = input(" > Enter youtube video url: ")
video = pafy.new(url)
print(video.title)
print(video.rating)
print(video.viewcount, video.author, video.length)
print(video.duration, video.likes, video.dislikes)
print(video.description)
streams = video.streams
for s in streams:
print(s)
for s in streams:
print(s.resolution, s.extension, s.get_filesize(), s.url)
best = video.getbest() # video.getbest(preftype="webm")
print(best.resolution, best.extension)
print(best.url)
print(best.download(quiet=False))
# filename = best.download(filepath="/tmp/")
# filename = best.download(filepath="/tmp/Game." + best.extension)
audiostreams = video.audiostreams
for a in audiostreams:
print(a.bitrate, a.extension, a.get_filesize())
audiostreams[1].download()
bestaudio = video.getbestaudio()
print(bestaudio.bitrate)
bestaudio.download()
allstreams = video.allstreams
for s in allstreams:
print(s.mediatype, s.extension, s.quality)
print("Download Successfull !")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment