2023-09-23 21:06:36 +00:00
|
|
|
import "pkg:/source/utils/misc.brs"
|
|
|
|
|
2023-09-21 18:46:18 +00:00
|
|
|
' Functions that update the registry based on the last run version and the currently running version
|
|
|
|
|
|
|
|
' Run all necessary registry mirations on the "global" Jellyfin registry section
|
|
|
|
sub runGlobalMigrations()
|
|
|
|
' Global registry migrations
|
|
|
|
if isValid(m.global.app.lastRunVersion) and not versionChecker(m.global.app.lastRunVersion, "1.7.0")
|
|
|
|
' last app version used was less than 1.7.0
|
|
|
|
print "Running 1.7.0 global registry migrations"
|
|
|
|
' no longer saving raw password to registry
|
|
|
|
' auth token and username are now stored in user settings and not global settings
|
2023-09-23 21:06:36 +00:00
|
|
|
|
|
|
|
savedUserId = get_setting("active_user")
|
|
|
|
if isValid(savedUserId)
|
|
|
|
registry_write("serverId", m.global.session.server.id, savedUserId)
|
|
|
|
' copy saved credentials to user block
|
|
|
|
savedUsername = get_setting("username")
|
|
|
|
if isValid(savedUsername)
|
|
|
|
registry_write("username", savedUsername, savedUserId)
|
|
|
|
end if
|
|
|
|
|
|
|
|
savedToken = get_setting("token")
|
|
|
|
if isValid(savedToken)
|
|
|
|
registry_write("token", savedToken, savedUserId)
|
|
|
|
end if
|
|
|
|
end if
|
2023-09-21 18:46:18 +00:00
|
|
|
unset_setting("port")
|
|
|
|
unset_setting("token")
|
|
|
|
unset_setting("username")
|
|
|
|
unset_setting("password")
|
|
|
|
' remove saved credentials from saved_servers
|
|
|
|
saved = get_setting("saved_servers")
|
|
|
|
if isValid(saved)
|
|
|
|
savedServers = ParseJson(saved)
|
|
|
|
if isValid(savedServers.serverList) and savedServers.serverList.Count() > 0
|
|
|
|
newServers = { serverList: [] }
|
|
|
|
for each item in savedServers.serverList
|
|
|
|
item.Delete("username")
|
|
|
|
item.Delete("password")
|
|
|
|
newServers.serverList.Push(item)
|
|
|
|
end for
|
|
|
|
set_setting("saved_servers", FormatJson(newServers))
|
|
|
|
end if
|
|
|
|
end if
|
2023-09-23 21:06:36 +00:00
|
|
|
end if
|
|
|
|
if m.global.app.lastRunVersion <> invalid
|
|
|
|
runRegistryUserMigrations(m.global.app.lastRunVersion)
|
2023-09-21 18:46:18 +00:00
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
2023-09-23 21:06:36 +00:00
|
|
|
sub runRegistryUserMigrations(version as string)
|
|
|
|
regSections = getRegistrySections()
|
|
|
|
for each section in regSections
|
|
|
|
if section <> "Jellyfin"
|
|
|
|
if version = "1.7.0"
|
|
|
|
print "Running User Registry Migration for 1.7.0"
|
|
|
|
' now saving LastRunVersion globally and per user so that we can run user specific registry migrations
|
|
|
|
' duplicate LastRunVersion to all user settings in the registry so that we can run user specific migrations
|
|
|
|
'
|
2023-09-30 18:31:32 +00:00
|
|
|
' now saving LastRunVersion per user in addition to globally
|
2023-09-23 21:06:36 +00:00
|
|
|
registry_write("LastRunVersion", m.global.app.version, section)
|
2023-09-30 18:31:32 +00:00
|
|
|
' no longer saving password to registry
|
2023-09-23 21:06:36 +00:00
|
|
|
registry_delete("password", section)
|
2023-09-30 18:31:32 +00:00
|
|
|
' av1 playback no longer hidden behind user setting
|
|
|
|
registry_delete("playback.av1", section)
|
2023-09-23 21:06:36 +00:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
2023-09-21 18:46:18 +00:00
|
|
|
end sub
|