Calculate device id on login and use for API calls

Fixes #1417
This commit is contained in:
1hitsong 2023-10-27 10:51:09 -04:00
parent dff9a69d0a
commit a78dcca4f7
5 changed files with 12 additions and 3 deletions

View File

@ -35,7 +35,7 @@ end function
' Returns an array of playback info to be displayed during playback.
' In the future, with a custom playback info view, we can return an associated array.
sub getPlaybackInfoTask()
sessions = api.sessions.Get()
sessions = api.sessions.Get({ "deviceId": m.global.device.serverDeviceName })
m.playbackInfo = ItemPostPlaybackInfo(m.top.videoID)

View File

@ -468,7 +468,8 @@ end sub
' Returns an array of playback info to be displayed during playback.
' In the future, with a custom playback info view, we can return an associated array.
function GetPlaybackInfo()
sessions = api.sessions.Get()
sessions = api.sessions.Get({ "deviceId": m.global.device.serverDeviceName })
if isValid(sessions) and sessions.Count() > 0
return GetTranscodingStats(sessions[0])
end if

View File

@ -1374,7 +1374,7 @@ namespace api
end function
' Gets a list of sessions.
function Get(params = { "deviceId": m.global.device.id } as object)
function Get(params = {} as object)
req = APIRequest("/sessions", params)
return getJson(req)
end function

View File

@ -107,6 +107,7 @@ sub SaveDeviceToGlobal()
uuid: deviceInfo.GetRandomUUID(),
name: displayName,
friendlyName: filteredFriendly,
serverDeviceName: "",
model: deviceInfo.GetModel(),
modelType: deviceInfo.GetModelType(),
modelDetails: deviceInfo.GetModelDetails(),

View File

@ -177,6 +177,13 @@ namespace session
' Load and parse Display Settings from server
sub LoadUserPreferences()
' Save device id so we don't calculate it every time we need it
if isValid(m.global.session.user) and isValid(m.global.session.user.friendlyName)
m.global.device.serverDeviceName = m.global.device.id + m.global.session.user.friendlyName
else
m.global.device.serverDeviceName = m.global.device.id
end if
id = m.global.session.user.id
' Currently using client "emby", which is what website uses so we get same Display prefs as web.
' May want to change to specific Roku display settings