Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions resources/lib/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, server=None, user_id=None, token=None):
self.verify_cert = settings.getSetting('verify_cert') == 'true'

def get(self, path):
if 'x-mediabrowser-token' not in self.headers or self.token not in self.headers:
if 'Authorization' not in self.headers or self.token not in self.headers:
self.create_headers(True)

# Fixes initial login where class is initialized before wizard completes
Expand Down Expand Up @@ -56,7 +56,7 @@ def get(self, path):
return response_data

def post(self, url, payload={}):
if 'x-mediabrowser-token' not in self.headers or self.token not in self.headers:
if 'Authorization' not in self.headers or self.token not in self.headers:
self.create_headers(True)

url = '{}{}'.format(self.server, url)
Expand All @@ -73,7 +73,7 @@ def post(self, url, payload={}):
return response_data

def delete(self, url):
if 'x-mediabrowser-token' not in self.headers or self.token not in self.headers:
if 'Authorization' not in self.headers or self.token not in self.headers:
self.create_headers(True)

url = '{}{}'.format(self.server, url)
Expand All @@ -98,7 +98,7 @@ def authenticate(self, auth_data):
def create_headers(self, force=False):

# If the headers already exist with an auth token, return unless we're regenerating
if self.headers and 'x-mediabrowser-token' in self.headers and force is False:
if self.headers and 'Authorization' in self.headers.get('Authorization', '') and force is False:
return

headers = {}
Expand All @@ -119,18 +119,18 @@ def create_headers(self, force=False):
version=version
)

headers['x-emby-authorization'] = authorization
headers['Authorization'] = authorization

# If we have a valid token, ensure it's included in the headers unless we're regenerating
if self.token and force is False:
headers['x-mediabrowser-token'] = self.token
headers['Authorization'] += ", Token={}".format(self.token)
else:
# Check for updated credentials since initialization
user_details = load_user_details()
token = user_details.get('token')
if token:
self.token = token
headers['x-mediabrowser-token'] = self.token
headers['Authorization'] += ", Token={}".format(self.token)

# Make headers available to api calls
self.headers = headers
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/play_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ def set_list_item_props(item_id, list_item, result, server, extra_props, title):
album = result.get("Album")
if album:
details['album'] = album

list_item.setInfo("Music", infoLabels=details)

else:
Expand Down Expand Up @@ -1287,7 +1287,7 @@ def get_play_url(media_source, play_session_id, channel_id=None):
"MediaSourceId": item_id,
"DeviceId": device_id,
"PlaySessionId": play_session_id,
"api_key": user_token,
"ApiKey": user_token,
"SegmentContainer": "ts",
"VideoCodec": "h264",
"VideoBitrate": bitrate,
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/websocket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def run(self):
else:
server = server.replace('http://', 'ws://')

websocket_url = "{}/socket?api_key={}&deviceId={}".format(
websocket_url = "{}/socket?ApiKey={}&deviceId={}".format(
server, token, self.device_id
)
log.debug("websocket url: {0}".format(websocket_url))
Expand Down
Loading