2019-10-12 01:23:53 +00:00
|
|
|
function ItemImages(id = "" as string, params = {} as object)
|
2021-07-09 20:08:32 +00:00
|
|
|
' This seems to cause crazy core dumps
|
|
|
|
' if there is a conflict between on disk images, and library.db
|
|
|
|
resp = APIRequest(Substitute("Items/{0}/Images", id))
|
|
|
|
data = getJson(resp)
|
|
|
|
if data = invalid then return invalid
|
2019-05-10 04:42:25 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
results = []
|
|
|
|
for each item in data
|
|
|
|
tmp = CreateObject("roSGNode", "ImageData")
|
|
|
|
tmp.json = item
|
|
|
|
tmp.url = ImageURL(id, tmp.imagetype, params)
|
|
|
|
results.push(tmp)
|
|
|
|
end for
|
|
|
|
return results
|
2019-04-20 22:28:28 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
|
2019-10-12 01:23:53 +00:00
|
|
|
function PosterImage(id as string, params = {} as object)
|
2021-07-09 20:08:32 +00:00
|
|
|
images = ItemImages(id, params)
|
|
|
|
if images = invalid then return invalid
|
|
|
|
primary_image = invalid
|
2019-05-10 04:24:19 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
for each image in images
|
|
|
|
if image.imagetype = "Primary"
|
|
|
|
primary_image = image
|
|
|
|
else if image.imagetype = "Logo" and primary_image = invalid
|
|
|
|
primary_image = image
|
|
|
|
else if image.imagetype = "Thumb" and primary_image = invalid
|
|
|
|
primary_image = image
|
|
|
|
' maybe find more fallback images
|
|
|
|
end if
|
|
|
|
end for
|
2019-05-10 04:24:19 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
return primary_image
|
2019-05-10 04:24:19 +00:00
|
|
|
end function
|
|
|
|
|
2019-10-11 19:01:46 +00:00
|
|
|
function ImageURL(id, version = "Primary", params = {})
|
2021-07-09 20:08:32 +00:00
|
|
|
' set defaults
|
|
|
|
if params.maxHeight = invalid
|
2022-07-12 23:15:59 +00:00
|
|
|
param = { "maxHeight": "384" }
|
2021-07-09 20:08:32 +00:00
|
|
|
params.append(param)
|
|
|
|
end if
|
|
|
|
if params.maxWidth = invalid
|
2022-07-12 23:15:59 +00:00
|
|
|
param = { "maxWidth": "196" }
|
2021-07-09 20:08:32 +00:00
|
|
|
params.append(param)
|
|
|
|
end if
|
|
|
|
if params.quality = invalid
|
2022-07-12 23:15:59 +00:00
|
|
|
param = { "quality": "90" }
|
2021-07-09 20:08:32 +00:00
|
|
|
params.append(param)
|
|
|
|
end if
|
|
|
|
url = Substitute("Items/{0}/Images/{1}", id, version)
|
|
|
|
' ?maxHeight=384&maxWidth=256&tag=<tag>&quality=90"
|
|
|
|
return buildURL(url, params)
|
2019-04-20 22:28:28 +00:00
|
|
|
end function
|
2020-03-21 21:22:26 +00:00
|
|
|
|
|
|
|
function UserImageURL(id, params = {})
|
2021-07-09 20:08:32 +00:00
|
|
|
' set defaults
|
|
|
|
if params.maxHeight = invalid
|
|
|
|
params.append({ "maxHeight": "300" })
|
|
|
|
end if
|
|
|
|
if params.maxWidth = invalid
|
|
|
|
params.append({ "maxWidth": "300" })
|
|
|
|
end if
|
|
|
|
if params.quality = invalid
|
2022-07-12 23:15:59 +00:00
|
|
|
params.append({ "quality": "90" })
|
2021-07-09 20:08:32 +00:00
|
|
|
end if
|
2020-03-21 21:22:26 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
url = Substitute("Users/{0}/Images/Primary", id)
|
|
|
|
return buildURL(url, params)
|
2020-03-21 21:22:26 +00:00
|
|
|
end function
|