mirror of
https://github.com/hrfee/jellyfin-accounts.git
synced 2024-11-01 03:50:11 +00:00
Added extra auths with jellyfin to avoid expiry
Also fixed running multiple authentications on one Jellyfin object.
This commit is contained in:
parent
785cf76a17
commit
9b8204eb12
@ -76,6 +76,11 @@ class Jellyfin:
|
||||
json = response.json()
|
||||
self.userId = json['User']['Id']
|
||||
self.accessToken = json['AccessToken']
|
||||
self.auth = "MediaBrowser "
|
||||
self.auth += f"Client={self.client}, "
|
||||
self.auth += f"Device={self.device}, "
|
||||
self.auth += f"DeviceId={self.deviceId}, "
|
||||
self.auth += f"Version={self.version}"
|
||||
self.auth += f", Token={self.accessToken}"
|
||||
self.header['X-Emby-Authorization'] = self.auth
|
||||
return True
|
||||
|
@ -52,10 +52,12 @@ jf = Jellyfin(config['jellyfin']['server'],
|
||||
config['jellyfin']['device_id'])
|
||||
|
||||
attempts = 0
|
||||
success = False
|
||||
while attempts != 3:
|
||||
try:
|
||||
jf.authenticate(config['jellyfin']['username'],
|
||||
config['jellyfin']['password'])
|
||||
success = True
|
||||
log.info(('Successfully authenticated with ' +
|
||||
config['jellyfin']['server']))
|
||||
break
|
||||
@ -66,6 +68,9 @@ while attempts != 3:
|
||||
'. Retrying...'))
|
||||
time.sleep(5)
|
||||
|
||||
if not success:
|
||||
log.error('Could not authenticate after 3 tries.')
|
||||
|
||||
|
||||
def switchToIds():
|
||||
try:
|
||||
@ -127,6 +132,8 @@ def newUser():
|
||||
if valid:
|
||||
log.debug('User password valid')
|
||||
try:
|
||||
jf.authenticate(config['jellyfin']['username'],
|
||||
config['jellyfin']['password'])
|
||||
user = jf.newUser(data['username'], data['password'])
|
||||
except Jellyfin.UserExistsError:
|
||||
error = 'User already exists with name '
|
||||
@ -293,6 +300,8 @@ def getUsers():
|
||||
except (FileNotFoundError, json.decoder.JSONDecodeError):
|
||||
emails = {}
|
||||
response = {'users': []}
|
||||
jf.authenticate(config['jellyfin']['username'],
|
||||
config['jellyfin']['password'])
|
||||
users = jf.getUsers(public=False)
|
||||
for user in users:
|
||||
entry = {'name': user['Name']}
|
||||
@ -311,6 +320,8 @@ def modifyUsers():
|
||||
emails = json.load(f)
|
||||
except (FileNotFoundError, json.decoder.JSONDecodeError):
|
||||
emails = {}
|
||||
jf.authenticate(config['jellyfin']['username'],
|
||||
config['jellyfin']['password'])
|
||||
for key in data:
|
||||
uid = jf.getUsers(key, public=False)['Id']
|
||||
log.debug(f'Email for user "{key}" modified')
|
||||
|
Loading…
Reference in New Issue
Block a user