[oauth] add the 'extractor.oauth.browser' option

enables/disables the use of webbrowser.open() during OAuth authorization
This commit is contained in:
Mike Fährmann
2017-06-20 16:06:14 +02:00
parent 1a9b4759a2
commit b4c438c9ad
2 changed files with 3 additions and 2 deletions

View File

@@ -73,7 +73,7 @@ modules = [
"imagehosts",
"directlink",
"recursive",
"oauthhelper",
"oauth",
"test",
]

View File

@@ -65,7 +65,8 @@ class OAuthBase(Extractor):
"""Open 'url' in browser amd return response parameters"""
import webbrowser
url += "?" + urllib.parse.urlencode(params)
if not webbrowser.open(url):
browser = self.config("browser", True)
if not browser or (browser and not webbrowser.open(url)):
print("Please open this URL in your browser:")
print(url, end="\n\n", flush=True)
return self.recv()