mirror of
https://github.com/hrfee/jellyfin-accounts.git
synced 2024-10-31 19:40:10 +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()
|
json = response.json()
|
||||||
self.userId = json['User']['Id']
|
self.userId = json['User']['Id']
|
||||||
self.accessToken = json['AccessToken']
|
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.auth += f", Token={self.accessToken}"
|
||||||
self.header['X-Emby-Authorization'] = self.auth
|
self.header['X-Emby-Authorization'] = self.auth
|
||||||
return True
|
return True
|
||||||
|
@ -52,10 +52,12 @@ jf = Jellyfin(config['jellyfin']['server'],
|
|||||||
config['jellyfin']['device_id'])
|
config['jellyfin']['device_id'])
|
||||||
|
|
||||||
attempts = 0
|
attempts = 0
|
||||||
|
success = False
|
||||||
while attempts != 3:
|
while attempts != 3:
|
||||||
try:
|
try:
|
||||||
jf.authenticate(config['jellyfin']['username'],
|
jf.authenticate(config['jellyfin']['username'],
|
||||||
config['jellyfin']['password'])
|
config['jellyfin']['password'])
|
||||||
|
success = True
|
||||||
log.info(('Successfully authenticated with ' +
|
log.info(('Successfully authenticated with ' +
|
||||||
config['jellyfin']['server']))
|
config['jellyfin']['server']))
|
||||||
break
|
break
|
||||||
@ -66,6 +68,9 @@ while attempts != 3:
|
|||||||
'. Retrying...'))
|
'. Retrying...'))
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
if not success:
|
||||||
|
log.error('Could not authenticate after 3 tries.')
|
||||||
|
|
||||||
|
|
||||||
def switchToIds():
|
def switchToIds():
|
||||||
try:
|
try:
|
||||||
@ -127,6 +132,8 @@ def newUser():
|
|||||||
if valid:
|
if valid:
|
||||||
log.debug('User password valid')
|
log.debug('User password valid')
|
||||||
try:
|
try:
|
||||||
|
jf.authenticate(config['jellyfin']['username'],
|
||||||
|
config['jellyfin']['password'])
|
||||||
user = jf.newUser(data['username'], data['password'])
|
user = jf.newUser(data['username'], data['password'])
|
||||||
except Jellyfin.UserExistsError:
|
except Jellyfin.UserExistsError:
|
||||||
error = 'User already exists with name '
|
error = 'User already exists with name '
|
||||||
@ -293,6 +300,8 @@ def getUsers():
|
|||||||
except (FileNotFoundError, json.decoder.JSONDecodeError):
|
except (FileNotFoundError, json.decoder.JSONDecodeError):
|
||||||
emails = {}
|
emails = {}
|
||||||
response = {'users': []}
|
response = {'users': []}
|
||||||
|
jf.authenticate(config['jellyfin']['username'],
|
||||||
|
config['jellyfin']['password'])
|
||||||
users = jf.getUsers(public=False)
|
users = jf.getUsers(public=False)
|
||||||
for user in users:
|
for user in users:
|
||||||
entry = {'name': user['Name']}
|
entry = {'name': user['Name']}
|
||||||
@ -311,6 +320,8 @@ def modifyUsers():
|
|||||||
emails = json.load(f)
|
emails = json.load(f)
|
||||||
except (FileNotFoundError, json.decoder.JSONDecodeError):
|
except (FileNotFoundError, json.decoder.JSONDecodeError):
|
||||||
emails = {}
|
emails = {}
|
||||||
|
jf.authenticate(config['jellyfin']['username'],
|
||||||
|
config['jellyfin']['password'])
|
||||||
for key in data:
|
for key in data:
|
||||||
uid = jf.getUsers(key, public=False)['Id']
|
uid = jf.getUsers(key, public=False)['Id']
|
||||||
log.debug(f'Email for user "{key}" modified')
|
log.debug(f'Email for user "{key}" modified')
|
||||||
|
Loading…
Reference in New Issue
Block a user