Skip to content

Commit

Permalink
Merge pull request #1876 from jellyfin/2.1.z
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert authored Jul 28, 2024
2 parents e64bcdc + b748dd4 commit adfa437
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# If you want to get_images, you'll also need convert from ImageMagick
##########################################################################

VERSION := 2.1.2
VERSION := 2.1.3

## usage

Expand Down
2 changes: 1 addition & 1 deletion components/ItemGrid/MovieLibraryView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ end sub
'
'Swap Complete
sub swapDone()
if m.swapAnimation.state = "stopped"
if isValid(m.swapAnimation) and m.swapAnimation.state = "stopped"
'Set main BG node image and hide transitioning node
m.backdrop.uri = m.newBackdrop.uri
m.backdrop.opacity = 1
Expand Down
12 changes: 9 additions & 3 deletions components/ListPoster.bs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ sub init()

m.backdrop = m.top.findNode("backdrop")

' Randmomise the background colors
posterBackgrounds = m.global.constants.poster_bg_pallet
m.backdrop.color = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
' Randomize the background colors
backdropColor = "#00a4db" ' set default in case global var is invalid
localGlobal = m.global

if isValid(localGlobal) and isValid(localGlobal.constants) and isValid(localGlobal.constants.poster_bg_pallet)
posterBackgrounds = localGlobal.constants.poster_bg_pallet
backdropColor = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
end if

m.backdrop.color = backdropColor
updateSize()
end sub

Expand Down
22 changes: 19 additions & 3 deletions components/home/HomeItem.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import "pkg:/source/roku_modules/log/LogMixin.brs"

sub init()
m.log = log.Logger("HomeItem")
m.itemText = m.top.findNode("itemText")
m.itemPoster = m.top.findNode("itemPoster")
initItemText()
initItemPoster()
m.itemProgress = m.top.findNode("progress")
m.itemProgressBackground = m.top.findNode("progressBackground")
m.itemIcon = m.top.findNode("itemIcon")
m.itemTextExtra = m.top.findNode("itemTextExtra")
initItemTextExtra()
m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged")
m.unplayedCount = m.top.findNode("unplayedCount")
m.unplayedEpisodeCount = m.top.findNode("unplayedEpisodeCount")
Expand All @@ -34,6 +34,17 @@ sub init()
m.backdrop.color = backdropColor
end sub

sub initItemText()
m.itemText = m.top.findNode("itemText")
end sub

sub initItemPoster()
m.itemPoster = m.top.findNode("itemPoster")
end sub

sub initItemTextExtra()
m.itemTextExtra = m.top.findNode("itemTextExtra")
end sub

sub itemContentChanged()
if isValid(m.unplayedCount) then m.unplayedCount.visible = false
Expand All @@ -43,6 +54,11 @@ sub itemContentChanged()

itemData.Title = itemData.name ' Temporarily required while we move from "HomeItem" to "JFContentItem"

' validate to prevent crash
if not isValid(m.itemPoster) then initItemPoster()
if not isValid(m.itemText) then initItemText()
if not isValid(m.itemTextExtra) then initItemTextExtra()

m.itemPoster.width = itemData.imageWidth
m.itemText.maxWidth = itemData.imageWidth
m.itemTextExtra.width = itemData.imageWidth
Expand Down
156 changes: 80 additions & 76 deletions components/movies/MovieDetails.bs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ end sub
' onMoviePosterSwapAnimationStateChange: Handler for changes to m.moviePosterSwapAnimation.state
'
sub onMoviePosterSwapAnimationStateChange()
if not isValid(m.moviePosterSwapAnimation) then return
if LCase(m.moviePosterSwapAnimation.state) <> "stopped" then return
m.moviePoster.uri = m.moviePosterSwap.uri
m.moviePoster.opacity = 1
Expand Down Expand Up @@ -95,102 +96,105 @@ end sub
sub itemContentChanged()
' Updates video metadata
item = m.top.itemContent
itemData = item.json
m.top.id = itemData.id
m.top.findNode("moviePoster").uri = m.top.itemContent.posterURL

' Set default video source if user hasn't selected one yet
if m.top.selectedVideoStreamId = "" and isValid(itemData.MediaSources)
m.top.selectedVideoStreamId = itemData.MediaSources[0].id
end if
if isValid(item) and isValid(item.json)
itemData = item.json
m.top.id = itemData.id
m.top.findNode("moviePoster").uri = m.top.itemContent.posterURL

' Set default video source if user hasn't selected one yet
if m.top.selectedVideoStreamId = "" and isValid(itemData.MediaSources)
m.top.selectedVideoStreamId = itemData.MediaSources[0].id
end if

' Find first Audio Stream and set that as default
SetDefaultAudioTrack(itemData)
' Find first Audio Stream and set that as default
SetDefaultAudioTrack(itemData)

' Handle all "As Is" fields
m.top.overhangTitle = itemData.name
setFieldText("releaseYear", itemData.productionYear)
setFieldText("overview", itemData.overview)
' Handle all "As Is" fields
m.top.overhangTitle = itemData.name
setFieldText("releaseYear", itemData.productionYear)
setFieldText("overview", itemData.overview)

if itemData.officialRating <> invalid
setFieldText("officialRating", itemData.officialRating)
else
m.infoGroup.removeChild(m.top.findNode("officialRating"))
end if

if m.global.session.user.settings["ui.movies.showRatings"]
if isValid(itemData.communityRating)
setFieldText("communityRating", int(itemData.communityRating * 10) / 10)
if itemData.officialRating <> invalid
setFieldText("officialRating", itemData.officialRating)
else
m.infoGroup.removeChild(m.top.findNode("communityRatingGroup"))
m.infoGroup.removeChild(m.top.findNode("officialRating"))
end if
if isValid(itemData.CriticRating)
setFieldText("criticRatingLabel", itemData.criticRating)
if itemData.CriticRating > 60
tomato = "pkg:/images/fresh.png"

if m.global.session.user.settings["ui.movies.showRatings"]
if isValid(itemData.communityRating)
setFieldText("communityRating", int(itemData.communityRating * 10) / 10)
else
m.infoGroup.removeChild(m.top.findNode("communityRatingGroup"))
end if
if isValid(itemData.CriticRating)
setFieldText("criticRatingLabel", itemData.criticRating)
if itemData.CriticRating > 60
tomato = "pkg:/images/fresh.png"
else
tomato = "pkg:/images/rotten.png"
end if
criticRatingIcon = m.top.findNode("criticRatingIcon")
if isValid(criticRatingIcon) then criticRatingIcon.uri = tomato
else
tomato = "pkg:/images/rotten.png"
m.infoGroup.removeChild(m.top.findNode("criticRatingGroup"))
end if
m.top.findNode("criticRatingIcon").uri = tomato
else
m.infoGroup.removeChild(m.top.findNode("communityRatingGroup"))
m.infoGroup.removeChild(m.top.findNode("criticRatingGroup"))
end if
else
m.infoGroup.removeChild(m.top.findNode("communityRatingGroup"))
m.infoGroup.removeChild(m.top.findNode("criticRatingGroup"))
end if

if type(itemData.RunTimeTicks) = "LongInteger"
setFieldText("runtime", stri(getRuntime()) + " mins")
if m.global.session.user.settings["ui.design.hideclock"] <> true
setFieldText("ends-at", tr("Ends at %1").Replace("%1", getEndTime()))
if type(itemData.RunTimeTicks) = "LongInteger"
setFieldText("runtime", stri(getRuntime()) + " mins")
if m.global.session.user.settings["ui.design.hideclock"] <> true
setFieldText("ends-at", tr("Ends at %1").Replace("%1", getEndTime()))
end if
end if
end if

if itemData.genres.count() > 0
setFieldText("genres", tr("Genres") + ": " + itemData.genres.join(", "))
else
m.top.findNode("details").removeChild(m.top.findNode("genres"))
end if
if itemData.genres.count() > 0
setFieldText("genres", tr("Genres") + ": " + itemData.genres.join(", "))
else
m.top.findNode("details").removeChild(m.top.findNode("genres"))
end if

' show tags if there are no genres to display
if itemData.genres.count() = 0 and isValid(itemData.tags) and itemData.tags.count() > 0
setFieldText("genres", tr("Tags") + ": " + itemData.tags.join(", "))
end if
' show tags if there are no genres to display
if itemData.genres.count() = 0 and isValid(itemData.tags) and itemData.tags.count() > 0
setFieldText("genres", tr("Tags") + ": " + itemData.tags.join(", "))
end if

directors = []
for each person in itemData.people
if person.type = "Director"
directors.push(person.name)
directors = []
for each person in itemData.people
if person.type = "Director"
directors.push(person.name)
end if
end for
if directors.count() > 0
setFieldText("director", tr("Director") + ": " + directors.join(", "))
else
m.top.findNode("details").removeChild(m.top.findNode("director"))
end if
end for
if directors.count() > 0
setFieldText("director", tr("Director") + ": " + directors.join(", "))
else
m.top.findNode("details").removeChild(m.top.findNode("director"))
end if

if m.global.session.user.settings["ui.details.hidetagline"] = false
if itemData.taglines.count() > 0
setFieldText("tagline", itemData.taglines[0])
if m.global.session.user.settings["ui.details.hidetagline"] = false
if itemData.taglines.count() > 0
setFieldText("tagline", itemData.taglines[0])
end if
else
m.details.removeChild(m.tagline)
end if
else
m.details.removeChild(m.tagline)
end if

'set aired date if type is Episode
if itemData.PremiereDate <> invalid and itemData.Type = "Episode"
airDate = CreateObject("roDateTime")
airDate.FromISO8601String(itemData.PremiereDate)
m.top.findNode("aired").text = tr("Aired") + ": " + airDate.AsDateString("short-month-no-weekday")
'remove movie release year label
m.infoGroup.removeChild(m.top.findNode("releaseYear"))
end if
'set aired date if type is Episode
if itemData.PremiereDate <> invalid and itemData.Type = "Episode"
airDate = CreateObject("roDateTime")
airDate.FromISO8601String(itemData.PremiereDate)
m.top.findNode("aired").text = tr("Aired") + ": " + airDate.AsDateString("short-month-no-weekday")
'remove movie release year label
m.infoGroup.removeChild(m.top.findNode("releaseYear"))
end if

setFavoriteColor()
setWatchedColor()
SetUpVideoOptions(itemData.mediaSources)
SetUpAudioOptions(itemData.mediaStreams)
setFavoriteColor()
setWatchedColor()
SetUpVideoOptions(itemData.mediaSources)
SetUpAudioOptions(itemData.mediaStreams)
end if
m.buttonGrp.visible = true
stopLoadingSpinner()
end sub
Expand Down
9 changes: 6 additions & 3 deletions components/video/VideoPlayerView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,12 @@ end sub

' When Video Player state changes
sub onPositionChanged()

' Pass video position data into OSD
m.osd.progressPercentage = m.top.position / m.top.duration
if m.top.duration = 0
m.osd.progressPercentage = 0
else
m.osd.progressPercentage = m.top.position / m.top.duration
end if
m.osd.positionTime = m.top.position
m.osd.remainingPositionTime = m.top.duration - m.top.position

Expand Down Expand Up @@ -662,7 +665,7 @@ sub ReportPlayback(state = "update" as string)
"PositionTicks": int(m.top.position) * 10000000&, 'Ensure a LongInteger is used
"IsPaused": (m.top.state = "paused")
}
if m.top.content.live
if isValid(m.top.content) and isValid(m.top.content.live) and m.top.content.live
params.append({
"MediaSourceId": m.top.transcodeParams.MediaSourceId,
"LiveStreamId": m.top.transcodeParams.LiveStreamId
Expand Down
2 changes: 1 addition & 1 deletion manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
title=Jellyfin
major_version=2
minor_version=1
build_version=2
build_version=3

### Main Menu Icons / Channel Poster Artwork

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jellyfin-roku",
"type": "module",
"version": "2.1.2",
"version": "2.1.3",
"description": "Roku app for Jellyfin media server",
"dependencies": {
"@rokucommunity/bslib": "0.1.1",
Expand Down
5 changes: 3 additions & 2 deletions source/ShowScenes.bs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ function LoginFlow()
SendPerformanceBeacon("AppDialogInitiate") ' Roku Performance monitoring - Dialog Starting

publicUsers = GetPublicUsers()
savedUsers = getSavedUsers()
numPubUsers = 0
if isValid(publicUsers) then numPubUsers = publicUsers.count()

numPubUsers = publicUsers.count()
savedUsers = getSavedUsers()
numSavedUsers = savedUsers.count()

if numPubUsers > 0 or numSavedUsers > 0
Expand Down

0 comments on commit adfa437

Please sign in to comment.