browser.py 625 B

12345678910111213141516171819
  1. from .. import lib
  2. try:
  3. from youtube_upload.auth import webkit_qt as backend
  4. WEBKIT_BACKEND = "qt"
  5. except ImportError:
  6. try:
  7. from youtube_upload.auth import webkit_gtk as backend
  8. WEBKIT_BACKEND = "gtk"
  9. except ImportError:
  10. WEBKIT_BACKEND = None
  11. def get_code(url, size=(640, 480), title="Google authentication"):
  12. if WEBKIT_BACKEND:
  13. lib.debug("Using webkit backend: " + WEBKIT_BACKEND)
  14. with lib.default_sigint():
  15. return backend.get_code(url, size=size, title=title)
  16. else:
  17. raise NotImplementedError("GUI auth requires pywebkitgtk or qtwebkit")