gonzopi

git clone https://git.tarina.org/gonzopi
Log | Files | Refs | README | LICENSE

console.py (790B)


      1 import sys
      2 import pyshorteners
      3 
      4 def shorten_url(url):
      5     s = pyshorteners.Shortener()
      6     short_url = s.tinyurl.short(url)
      7     return short_url
      8 
      9 def get_code(authorize_url):
     10     sys.stderr.write("\x1b[2J\x1b[H")
     11     short_url = shorten_url(authorize_url)
     12     """Show authorization URL and return the code the user wrote."""
     13     message = "Check this link in your browser: " + short_url 
     14     sys.stderr.write("\n")
     15     sys.stderr.write("\n")
     16     sys.stderr.write("Youtube authentication required!\n")
     17     sys.stderr.write(message + "\n")
     18     try: input = raw_input #For Python2 compatability
     19     except NameError: 
     20         #For Python3 on Windows compatability
     21         try: from builtins import input as input 
     22         except ImportError: pass
     23     return input("Enter verification code: ")