Last active
August 29, 2015 14:07
-
-
Save dmiro/73f02414bac9cc02c6bb to your computer and use it in GitHub Desktop.
Download youtube video with pafy library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pafy | |
| # code at : https://github.com/np1/pafy | |
| # you must copy pafy.py in your project directory | |
| # show info about youtube video | |
| url = "https://www.youtube.com/watch?v=oIlIVFBBbNw" | |
| video = pafy.new(url) | |
| print video.title | |
| print video.duration | |
| # list video formats/ if you want load stream number four -> s[4].download(myfilename) | |
| streams = video.streams | |
| for s in streams: | |
| print(s) | |
| # download best video format 3gp | |
| myfilename ="example.3pg" | |
| best = video.getbest(preftype="3gp") | |
| print best.resolution | |
| print best.extension | |
| best.download(filepath=myfilename, quiet=False) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment