Skip to content

Instantly share code, notes, and snippets.

@cooperpellaton
Created November 11, 2016 03:45
Show Gist options
  • Save cooperpellaton/bdc011ff084b9636f798ba235a8bd392 to your computer and use it in GitHub Desktop.
Save cooperpellaton/bdc011ff084b9636f798ba235a8bd392 to your computer and use it in GitHub Desktop.
from pytube import YouTube
import sys
import os
def get_video():
yt_url = sys.argv = raw_input("Enter the video you want to download: ")
to_download = YouTube(yt_url)
print(to_download.filename)
print(to_download.get_videos())
# Here we are just trying to download the most basic video which each upload should have.
video = to_download.get('mp4','360p')
# Check if the target directory exists. If not, make it.
if not os.path.exists('videos/'):
os.makedirs('videos/')
video.download('videos/')
sys.exit()
if __name__ == '__main__':
get_video()
@cooperpellaton
Copy link
Author

Be sure that you do a pip install pytube before you run this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment