Skip to content

Commit e4d3bf3

Browse files
committed
begin implementing blurhash again
1 parent a428dac commit e4d3bf3

18 files changed

+355
-3
lines changed

components/ItemGrid/GridItem.brs

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ sub itemContentChanged()
3737

3838
' Set Random background colors from pallet
3939
posterBackgrounds = m.global.constants.poster_bg_pallet
40-
m.backdrop.blendColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
40+
if isValidAndNotEmpty(m.top.itemContent.posterBlurhashUrl):
41+
m.backdrop.uri = m.top.itemContent.posterBlurhashUrl
42+
else
43+
m.backdrop.blendColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
44+
end if
4145

4246
itemData = m.top.itemContent
4347

components/ItemGrid/GridItemSmall.brs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import "pkg:/source/utils/misc.brs"
22
import "pkg:/source/utils/config.brs"
3+
import "pkg:/source/utils/fakeBlurhash.brs"
34

45
sub init()
56
m.itemPoster = m.top.findNode("itemPoster")
@@ -23,7 +24,11 @@ sub init()
2324
end sub
2425

2526
sub itemContentChanged()
26-
m.backdrop.blendColor = "#101010"
27+
if isValidAndNotEmpty(m.top.itemContent.posterBlurhashUrl):
28+
m.backdrop.uri = m.top.itemContent.posterBlurhashUrl
29+
else
30+
m.backdrop.blendColor = "#101010"
31+
end if
2732

2833
m.title.visible = false
2934

components/data/ChannelData.brs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -14,11 +15,19 @@ end sub
1415
sub setPoster()
1516
if m.top.image <> invalid
1617
m.top.posterURL = m.top.image.url
17-
else if m.top.json.ImageTags <> invalid and m.top.json.ImageTags.Primary <> invalid
18+
else if isValid(m.top.json.ImageTags) and isValid(m.top.json.ImageTags.Primary)
1819
imgParams = { "maxHeight": 60, "Tag": m.top.json.ImageTags.Primary }
1920
m.top.hdsmalliconurl = ImageURL(m.top.json.id, "Primary", imgParams)
2021

2122
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
2223
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
24+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
25+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
26+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
27+
timer = CreateObject("roTimeSpan")
28+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
29+
print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in ChannelData."' DELETE THIS TEMPORARY LINE OF DEV CODE
30+
end if
31+
end if
2332
end if
2433
end sub

components/data/CollectionData.brs

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -24,9 +25,18 @@ sub setPoster()
2425
if m.top.json.ImageTags.Primary <> invalid
2526
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
2627
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
28+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
29+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
30+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
31+
'timer = CreateObject("roTimeSpan")
32+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
33+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in CollectionData."' DELETE THIS TEMPORARY LINE OF DEV CODE
34+
end if
35+
end if
2736
else if m.top.json.BackdropImageTags <> invalid
2837
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
2938
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
39+
3040
end if
3141

3242
' Add Backdrop Image

components/data/FolderData.brs

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -27,6 +28,14 @@ sub setPoster()
2728
else if m.top.json.ImageTags.Primary <> invalid
2829
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
2930
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
31+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
32+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
33+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
34+
'timer = CreateObject("roTimeSpan")
35+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
36+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in FolderData."' DELETE THIS TEMPORARY LINE OF DEV CODE
37+
end if
38+
end if
3039
end if
3140
end sub
3241

components/data/JFContentItem.xml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<field id="favorite" type="boolean" />
55
<field id="watched" type="boolean" />
66
<field id="posterUrl" type="string" />
7+
<field id="posterBlurhashUrl" type="string" />
78
<field id="backdropUrl" type="string" />
89
<field id="SubTitle" type="string" value="" />
910
<field id="iconUrl" type="string" value="" />

components/data/MovieData.brs

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
44
import "pkg:/source/utils/misc.brs"
5+
import "pkg:/source/utils/fakeBlurhash.brs"
56

67
sub setFields()
78
json = m.top.json
@@ -47,6 +48,14 @@ sub setPoster()
4748
if isValid(m.top.json.ImageTags) and isValid(m.top.json.ImageTags.Primary)
4849
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
4950
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
51+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
52+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
53+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
54+
'timer = CreateObject("roTimeSpan")
55+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
56+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MoviesData."' DELETE THIS TEMPORARY LINE OF DEV CODE
57+
end if
58+
end if
5059
else if isValid(m.top.json.BackdropImageTags) and isValid(m.top.json.BackdropImageTags[0])
5160
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
5261
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)

components/data/MusicAlbumSongListData.brs

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -18,6 +19,14 @@ sub setPoster()
1819
if m.top.json.ImageTags.Primary <> invalid
1920
imgParams = { "maxHeight": 440, "maxWidth": 295 }
2021
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
22+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
23+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
24+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
25+
'timer = CreateObject("roTimeSpan")
26+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
27+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MusicAlbumSongListData."' DELETE THIS TEMPORARY LINE OF DEV CODE
28+
end if
29+
end if
2130
else if m.top.json.BackdropImageTags[0] <> invalid
2231
imgParams = { "maxHeight": 440 }
2332
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)

components/data/MusicArtistData.brs

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -21,6 +22,14 @@ sub setPoster()
2122
if m.top.json.ImageTags.Primary <> invalid
2223
imgParams = { "maxHeight": 440, "maxWidth": 440 }
2324
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
25+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
26+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
27+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
28+
'timer = CreateObject("roTimeSpan")
29+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
30+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MusicArtistData."' DELETE THIS TEMPORARY LINE OF DEV CODE
31+
end if
32+
end if
2433
else if m.top.json.BackdropImageTags[0] <> invalid
2534
imgParams = { "maxHeight": 440 }
2635
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)

components/data/PersonData.brs

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -18,6 +19,14 @@ sub setPoster()
1819
if m.top.json.ImageTags.Primary <> invalid
1920
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
2021
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
22+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
23+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
24+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
25+
'timer = CreateObject("roTimeSpan")
26+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
27+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MoviesData."' DELETE THIS TEMPORARY LINE OF DEV CODE
28+
end if
29+
end if
2130
else if m.top.json.BackdropImageTags[0] <> invalid
2231
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
2332
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)

components/data/PhotoData.brs

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -20,6 +21,14 @@ sub setPoster()
2021
if m.top.json.ImageTags.Primary <> invalid
2122
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
2223
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
24+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
25+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
26+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
27+
'timer = CreateObject("roTimeSpan")
28+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
29+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in PhotoData."' DELETE THIS TEMPORARY LINE OF DEV CODE
30+
end if
31+
end if
2332
else if m.top.json.BackdropImageTags[0] <> invalid
2433
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
2534
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)

components/data/ScheduleProgramData.brs

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -42,6 +43,15 @@ sub setPoster()
4243
if m.top.json.ImageTags <> invalid and m.top.json.ImageTags.Thumb <> invalid
4344
imgParams = { "maxHeight": 500, "maxWidth": 500, "Tag": m.top.json.ImageTags.Thumb }
4445
m.top.posterURL = ImageURL(m.top.json.id, "Thumb", imgParams)
46+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
47+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
48+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
49+
'timer = CreateObject("roTimeSpan")
50+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
51+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in ScheduleProgramData."' DELETE THIS TEMPORARY LINE OF DEV CODE
52+
end if
53+
end if
54+
4555
end if
4656
end if
4757
end sub

components/data/SeriesData.brs

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -38,6 +39,14 @@ sub setPoster()
3839

3940
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
4041
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
42+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
43+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
44+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
45+
'timer = CreateObject("roTimeSpan")
46+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
47+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in SeriesData."' DELETE THIS TEMPORARY LINE OF DEV CODE
48+
end if
49+
end if
4150
else if m.top.json.BackdropImageTags <> invalid
4251
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
4352
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)

components/data/TVEpisode.brs

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -21,5 +22,13 @@ sub setPoster()
2122
else if m.top.json.ImageTags.Primary <> invalid
2223
imgParams = { "maxHeight": 440, "maxWidth": 295 }
2324
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
25+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
26+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
27+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
28+
'timer = CreateObject("roTimeSpan")
29+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
30+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MoviesData."' DELETE THIS TEMPORARY LINE OF DEV CODE
31+
end if
32+
end if
2433
end if
2534
end sub

components/data/VideoData.brs

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "pkg:/source/api/Image.brs"
22
import "pkg:/source/api/baserequest.brs"
33
import "pkg:/source/utils/config.brs"
4+
import "pkg:/source/utils/fakeBlurhash.brs"
45

56
sub setFields()
67
json = m.top.json
@@ -21,5 +22,13 @@ sub setPoster()
2122
else if m.top.json.ImageTags.Primary <> invalid
2223
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
2324
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
25+
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
26+
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
27+
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
28+
'timer = CreateObject("roTimeSpan")
29+
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
30+
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in VideoData."' DELETE THIS TEMPORARY LINE OF DEV CODE
31+
end if
32+
end if
2433
end if
2534
end sub

settings/settings.json

+7
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@
218218
"type": "integer",
219219
"default": "365"
220220
},
221+
{
222+
"title": "Render blurhashes",
223+
"description": "Use an EXPERIMENTAL algorithm to render image blurhashes. This may slow down page loading and cause the app the crash.",
224+
"settingName": "ui.design.renderblurhashes",
225+
"type": "bool",
226+
"default": "false"
227+
},
221228
{
222229
"title": "Show What's New Popup",
223230
"description": "Show What's New popup when Jellyfin is updated to a new version.",

0 commit comments

Comments
 (0)