use ox.api.signin

This commit is contained in:
j 2018-05-31 21:21:34 +02:00
parent fa3855b4c8
commit f81fa3a7d6

View file

@ -5,26 +5,10 @@ import json
import sys import sys
import ox import ox
import ox.web.auth import ox.api
site = 'pandora.cinemusespace.com' site = 'pandora.cinemusespace.com'
api = ox.API('https://%s/api/' % site) api = ox.api.signin('https://%s/api/' % site)
update = False
try:
credentials = ox.web.auth.get(site)
except:
credentials = {}
print('Please provide your username and password for %s:' % site)
credentials['username'] = input('Username: ')
credentials['password'] = getpass.getpass('Password: ')
update = True
r = api.signin(**credentials)
if 'errors' in r.get('data', {}):
for kv in r['data']['errors'].items():
print('%s: %s' % kv)
sys.exit(1)
if update:
ox.web.auth.update(site, credentials)
keywords = set() keywords = set()
for annotation in api.findAnnotations({ for annotation in api.findAnnotations({