Ensure deviceId is unique and URL safe

This commit is contained in:
Matt
2022-01-17 15:16:51 -05:00
parent a316a6e094
commit 6efa62ced2
2 changed files with 9 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ import xbmcaddon
import requests
import json
import hashlib
from six.moves.urllib.parse import urlparse
from base64 import b64encode
from collections import defaultdict
@@ -473,12 +474,11 @@ class DownloadUtils:
log.debug("User NOT Authenticated")
def get_auth_header(self, authenticate=True):
txt_mac = get_device_id()
device_id = get_device_id()
version = get_version()
client = 'Kodi JellyCon'
settings = xbmcaddon.Addon()
username = settings.getSetting('username')
device_name = settings.getSetting('deviceName')
# remove none ascii chars
device_name = py2_decode(device_name)
@@ -492,12 +492,12 @@ class DownloadUtils:
headers["Accept-Charset"] = "UTF-8,*"
if authenticate is False:
auth_string = 'MediaBrowser Client="{}",Device="{}",DeviceId="{}{}",Version="{}'.format(client, device_name, txt_mac, username, version)
auth_string = 'MediaBrowser Client="{}",Device="{}",DeviceId="{}",Version="{}'.format(client, device_name, device_id, version)
headers['X-Emby-Authorization'] = auth_string
return headers
else:
userid = self.get_user_id()
auth_string = 'MediaBrowser UserId="{}",Client="{}",Device="{}",DeviceId="{}{}",Version="{}"'.format(userid, client, device_name, txt_mac, username, version)
auth_string = 'MediaBrowser UserId="{}",Client="{}",Device="{}",DeviceId="{}",Version="{}"'.format(userid, client, device_name, device_id, version)
headers['X-Emby-Authorization'] = auth_string
auth_token = self.authenticate()

View File

@@ -13,6 +13,7 @@ import json
import time
import math
import os
import hashlib
from datetime import datetime
import re
from uuid import uuid4
@@ -113,10 +114,12 @@ def translate_string(string_id):
def get_device_id():
window = HomeWindow()
username = window.get_property('username')
client_id = window.get_property("client_id")
hashed_name = hashlib.md5(username.encode()).hexdigest()
if client_id:
return client_id
return '{}-{}'.format(client_id, hashed_name)
jellyfin_guid_path = py2_decode(xbmc.translatePath("special://temp/jellycon_guid"))
log.debug("jellyfin_guid_path: {0}".format(jellyfin_guid_path))
@@ -135,7 +138,7 @@ def get_device_id():
log.debug("jellyfin_client_id: {0}".format(client_id))
window.set_property("client_id", client_id)
return client_id
return '{}-{}'.format(client_id, hashed_name)
def get_version():