Merge pull request #1212 from cewert/fix-crash-logs

This commit is contained in:
Charles Ewert 2023-05-18 21:42:38 -04:00 committed by GitHub
commit ede16c7c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 30 deletions

View File

@ -397,11 +397,13 @@ function BackdropImage(id as string)
end function end function
' Seasons for a TV Show ' Seasons for a TV Show
function TVSeasons(id as string) function TVSeasons(id as string) as dynamic
url = Substitute("Shows/{0}/Seasons", id) url = Substitute("Shows/{0}/Seasons", id)
resp = APIRequest(url, { "UserId": get_setting("active_user") }) resp = APIRequest(url, { "UserId": get_setting("active_user") })
data = getJson(resp) data = getJson(resp)
' validate data
if data = invalid or data.Items = invalid then return invalid
results = [] results = []
for each item in data.Items for each item in data.Items
imgParams = { "AddPlayedIndicator": item.UserData.Played } imgParams = { "AddPlayedIndicator": item.UserData.Played }
@ -414,11 +416,14 @@ function TVSeasons(id as string)
return data return data
end function end function
function TVEpisodes(show_id as string, season_id as string) function TVEpisodes(show_id as string, season_id as string) as dynamic
url = Substitute("Shows/{0}/Episodes", show_id) url = Substitute("Shows/{0}/Episodes", show_id)
resp = APIRequest(url, { "seasonId": season_id, "UserId": get_setting("active_user"), "fields": "MediaStreams" }) resp = APIRequest(url, { "seasonId": season_id, "UserId": get_setting("active_user"), "fields": "MediaStreams" })
data = getJson(resp) data = getJson(resp)
' validate data
if data = invalid or data.Items = invalid then return invalid
results = [] results = []
for each item in data.Items for each item in data.Items
imgParams = { "maxWidth": 400, "maxheight": 250 } imgParams = { "maxWidth": 400, "maxheight": 250 }
@ -428,7 +433,11 @@ function TVEpisodes(show_id as string, season_id as string)
tmp.image.posterDisplayMode = "scaleToZoom" tmp.image.posterDisplayMode = "scaleToZoom"
end if end if
tmp.json = item tmp.json = item
tmp.overview = ItemMetaData(item.id).overview tmpMetaData = ItemMetaData(item.id)
' validate meta data
if tmpMetaData <> invalid and tmpMetaData.overview <> invalid
tmp.overview = tmpMetaData.overview
end if
results.push(tmp) results.push(tmp)
end for end for
data.Items = results data.Items = results

View File

@ -35,13 +35,15 @@ function buildParams(params = {} as object) as string
return param_array.join("&") return param_array.join("&")
end function end function
function buildURL(path as string, params = {} as object) as string function buildURL(path as string, params = {} as object) as dynamic
serverURL = get_url()
if serverURL = invalid then return invalid
' Add intial '/' if path does not start with one ' Add intial '/' if path does not start with one
if path.Left(1) = "/" if path.Left(1) = "/"
full_url = get_url() + path full_url = serverURL + path
else else
full_url = get_url() + "/" + path full_url = serverURL + "/" + path
end if end if
if params.count() > 0 if params.count() > 0
@ -51,17 +53,19 @@ function buildURL(path as string, params = {} as object) as string
return full_url return full_url
end function end function
function APIRequest(url as string, params = {} as object) function APIRequest(url as string, params = {} as object) as dynamic
full_url = buildURL(url, params)
if full_url = invalid then return invalid
req = createObject("roUrlTransfer") req = createObject("roUrlTransfer")
req.setUrl(full_url)
req = authorize_request(req)
' SSL cert
serverURL = get_setting("server") serverURL = get_setting("server")
if serverURL <> invalid and serverURL.left(8) = "https://" if serverURL <> invalid and serverURL.left(8) = "https://"
req.setCertificatesFile("common:/certs/ca-bundle.crt") req.setCertificatesFile("common:/certs/ca-bundle.crt")
end if end if
full_url = buildURL(url, params)
req.setUrl(full_url)
req = authorize_request(req)
return req return req
end function end function
@ -119,18 +123,18 @@ function deleteVoid(req)
end function end function
function get_url() function get_url()
base = get_setting("server") serverURL = get_setting("server")
if base <> invalid if serverURL = invalid then return invalid
if base.right(1) = "/"
base = base.left(base.len() - 1)
end if
' append http:// to the start if not specified if serverURL.right(1) = "/"
if base.left(7) <> "http://" and base.left(8) <> "https://" serverURL = serverURL.left(serverURL.len() - 1)
base = "http://" + base
end if
end if end if
return base
' append http:// to the start if not specified
if serverURL.left(7) <> "http://" and serverURL.left(8) <> "https://"
serverURL = "http://" + serverURL
end if
return serverURL
end function end function
function authorize_request(request) function authorize_request(request)

View File

@ -84,17 +84,18 @@ function setupSubtitle(video, subtitles, subtitle_idx = -1) as integer
selectedSubtitle = subtitles[subtitleSelIdx] selectedSubtitle = subtitles[subtitleSelIdx]
if selectedSubtitle.IsEncoded if isValid(selectedSubtitle) and isValid(selectedSubtitle.IsEncoded)
' With encoded subtitles, turn off captions if selectedSubtitle.IsEncoded
video.globalCaptionMode = "Off" ' With encoded subtitles, turn off captions
else video.globalCaptionMode = "Off"
' If this is a text-based subtitle, set relevant settings for roku captions else
video.globalCaptionMode = "On" ' If this is a text-based subtitle, set relevant settings for roku captions
video.subtitleTrack = video.availableSubtitleTracks[availSubtitleTrackIdx(video, subtitleSelIdx)].TrackName video.globalCaptionMode = "On"
video.subtitleTrack = video.availableSubtitleTracks[availSubtitleTrackIdx(video, subtitleSelIdx)].TrackName
end if
end if end if
return subtitleSelIdx return subtitleSelIdx
end function end function
' The subtitle index on the server differs from the index we track locally ' The subtitle index on the server differs from the index we track locally