#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ai ts=4 sts=4 et sw=4
#        File:  getube
#      Author:  Sergio Araujo
#     Purpose:  Download youtube videos
# Last Change:  2018 mai 22 07:47
#     Created:  ter 22 mai 2018 07:31:29 -03
#       email:  <voyeg3r ✉ gmail.com>
#      Github:  https://github.com/voyeg3r
#     twitter:  @voyeg3r

import pafy
import sys
import os

if len(sys.argv) > 1:
    url = sys.argv[1]
else:
    url = input("Type the youtube url or ID: ")

def cls():
    if os.name == 'posix':
        os.system('clear')
    else:
        os.system('cls')

cls()

video = pafy.new(url)
bestvideo = video.getbestvideo()
print("Baixando: ", video.title)
bestvideo.download()
