Skip to content

Commit

Permalink
begin implementing blurhash again
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenrats committed Nov 10, 2023
1 parent a428dac commit e4d3bf3
Show file tree
Hide file tree
Showing 18 changed files with 355 additions and 3 deletions.
6 changes: 5 additions & 1 deletion components/ItemGrid/GridItem.brs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ sub itemContentChanged()

' Set Random background colors from pallet
posterBackgrounds = m.global.constants.poster_bg_pallet
m.backdrop.blendColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
if isValidAndNotEmpty(m.top.itemContent.posterBlurhashUrl):
m.backdrop.uri = m.top.itemContent.posterBlurhashUrl
else
m.backdrop.blendColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
end if

itemData = m.top.itemContent

Expand Down
7 changes: 6 additions & 1 deletion components/ItemGrid/GridItemSmall.brs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "pkg:/source/utils/misc.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub init()
m.itemPoster = m.top.findNode("itemPoster")
Expand All @@ -23,7 +24,11 @@ sub init()
end sub

sub itemContentChanged()
m.backdrop.blendColor = "#101010"
if isValidAndNotEmpty(m.top.itemContent.posterBlurhashUrl):
m.backdrop.uri = m.top.itemContent.posterBlurhashUrl
else
m.backdrop.blendColor = "#101010"
end if

m.title.visible = false

Expand Down
11 changes: 10 additions & 1 deletion components/data/ChannelData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand All @@ -14,11 +15,19 @@ end sub
sub setPoster()
if m.top.image <> invalid
m.top.posterURL = m.top.image.url
else if m.top.json.ImageTags <> invalid and m.top.json.ImageTags.Primary <> invalid
else if isValid(m.top.json.ImageTags) and isValid(m.top.json.ImageTags.Primary)
imgParams = { "maxHeight": 60, "Tag": m.top.json.ImageTags.Primary }
m.top.hdsmalliconurl = ImageURL(m.top.json.id, "Primary", imgParams)

imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in ChannelData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
end if
end sub
10 changes: 10 additions & 0 deletions components/data/CollectionData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand All @@ -24,9 +25,18 @@ sub setPoster()
if m.top.json.ImageTags.Primary <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in CollectionData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
else if m.top.json.BackdropImageTags <> invalid
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)

end if

' Add Backdrop Image
Expand Down
9 changes: 9 additions & 0 deletions components/data/FolderData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

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

Expand Down
1 change: 1 addition & 0 deletions components/data/JFContentItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<field id="favorite" type="boolean" />
<field id="watched" type="boolean" />
<field id="posterUrl" type="string" />
<field id="posterBlurhashUrl" type="string" />
<field id="backdropUrl" type="string" />
<field id="SubTitle" type="string" value="" />
<field id="iconUrl" type="string" value="" />
Expand Down
9 changes: 9 additions & 0 deletions components/data/MovieData.brs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/misc.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand Down Expand Up @@ -47,6 +48,14 @@ sub setPoster()
if isValid(m.top.json.ImageTags) and isValid(m.top.json.ImageTags.Primary)
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MoviesData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
else if isValid(m.top.json.BackdropImageTags) and isValid(m.top.json.BackdropImageTags[0])
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
Expand Down
9 changes: 9 additions & 0 deletions components/data/MusicAlbumSongListData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand All @@ -18,6 +19,14 @@ sub setPoster()
if m.top.json.ImageTags.Primary <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295 }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MusicAlbumSongListData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
else if m.top.json.BackdropImageTags[0] <> invalid
imgParams = { "maxHeight": 440 }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
Expand Down
9 changes: 9 additions & 0 deletions components/data/MusicArtistData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand All @@ -21,6 +22,14 @@ sub setPoster()
if m.top.json.ImageTags.Primary <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 440 }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MusicArtistData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
else if m.top.json.BackdropImageTags[0] <> invalid
imgParams = { "maxHeight": 440 }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
Expand Down
9 changes: 9 additions & 0 deletions components/data/PersonData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand All @@ -18,6 +19,14 @@ sub setPoster()
if m.top.json.ImageTags.Primary <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MoviesData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
else if m.top.json.BackdropImageTags[0] <> invalid
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
Expand Down
9 changes: 9 additions & 0 deletions components/data/PhotoData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand All @@ -20,6 +21,14 @@ sub setPoster()
if m.top.json.ImageTags.Primary <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in PhotoData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
else if m.top.json.BackdropImageTags[0] <> invalid
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
Expand Down
10 changes: 10 additions & 0 deletions components/data/ScheduleProgramData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand Down Expand Up @@ -42,6 +43,15 @@ sub setPoster()
if m.top.json.ImageTags <> invalid and m.top.json.ImageTags.Thumb <> invalid
imgParams = { "maxHeight": 500, "maxWidth": 500, "Tag": m.top.json.ImageTags.Thumb }
m.top.posterURL = ImageURL(m.top.json.id, "Thumb", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in ScheduleProgramData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if

end if
end if
end sub
9 changes: 9 additions & 0 deletions components/data/SeriesData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand Down Expand Up @@ -38,6 +39,14 @@ sub setPoster()

imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in SeriesData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
else if m.top.json.BackdropImageTags <> invalid
imgParams = { "maxHeight": 440, "Tag": m.top.json.BackdropImageTags[0] }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
Expand Down
9 changes: 9 additions & 0 deletions components/data/TVEpisode.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand All @@ -21,5 +22,13 @@ sub setPoster()
else if m.top.json.ImageTags.Primary <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295 }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in MoviesData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
end if
end sub
9 changes: 9 additions & 0 deletions components/data/VideoData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "pkg:/source/api/Image.brs"
import "pkg:/source/api/baserequest.brs"
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/fakeBlurhash.brs"

sub setFields()
json = m.top.json
Expand All @@ -21,5 +22,13 @@ sub setPoster()
else if m.top.json.ImageTags.Primary <> invalid
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
if isValidAndNotEmpty(m.top.json.ImageBlurHashes.Primary)
blurhash = m.top.json.ImageBlurHashes.Primary[m.top.json.ImageTags.Primary]
if get_user_setting("ui.design.renderblurhashes") = "true" and isValidAndNotEmpty(blurhash)
'timer = CreateObject("roTimeSpan")
m.top.posterBlurHashUrl = renderFakeBlurhash(blurhash, imgParams.maxWidth, imgParams.maxHeight)
'print "Took " + Str(timer.totalMilliseconds()) + " milliseconds to render a blurhash in VideoData."' DELETE THIS TEMPORARY LINE OF DEV CODE
end if
end if
end if
end sub
7 changes: 7 additions & 0 deletions settings/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@
"type": "integer",
"default": "365"
},
{
"title": "Render blurhashes",
"description": "Use an EXPERIMENTAL algorithm to render image blurhashes. This may slow down page loading and cause the app the crash.",
"settingName": "ui.design.renderblurhashes",
"type": "bool",
"default": "false"
},
{
"title": "Show What's New Popup",
"description": "Show What's New popup when Jellyfin is updated to a new version.",
Expand Down
Loading

0 comments on commit e4d3bf3

Please sign in to comment.