Skip to content

Commit

Permalink
Merge pull request #1889 from cewert/fix-season-details-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert authored Jul 31, 2024
2 parents a4c9800 + 74c1f2c commit 3b13fab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions source/Main.bs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,12 @@ sub Main (args as dynamic) as void
else if selectedItemType = "Series"
group = CreateSeriesDetailsGroup(selectedItem.json.id)
else if selectedItemType = "Season"
group = CreateSeasonDetailsGroupByID(selectedItem.json.SeriesId, selectedItem.id)
if isValid(selectedItem.json) and isValid(selectedItem.json.SeriesId) and isValid(selectedItem.id)
group = CreateSeasonDetailsGroupByID(selectedItem.json.SeriesId, selectedItem.id)
else
stopLoadingSpinner()
message_dialog(tr("Error loading Season"))
end if
else if selectedItemType = "Movie"
' open movie detail page
group = CreateMovieDetailsGroup(selectedItem)
Expand Down Expand Up @@ -810,7 +815,7 @@ sub Main (args as dynamic) as void
selectedItem = m.global.queueManager.callFunc("getHold")
m.global.queueManager.callFunc("clearHold")

if isValid(selectedItem) and selectedItem.count() > 0 and isValid(selectedItem[0])
if isValidAndNotEmpty(selectedItem) and isValid(selectedItem[0])
if popupNode.returnData.indexselected = 0
'Resume video from resume point
startLoadingSpinner()
Expand Down Expand Up @@ -838,7 +843,13 @@ sub Main (args as dynamic) as void
CreateSeriesDetailsGroup(selectedItem[0].json.SeriesId)
else if popupNode.returnData.indexselected = 3
' User chose Go to season
CreateSeasonDetailsGroupByID(selectedItem[0].json.SeriesId, selectedItem[0].json.seasonID)
if isValid(selectedItem[0].json) and isValid(selectedItem[0].json.SeriesId) and isValid(selectedItem[0].json.seasonID)
CreateSeasonDetailsGroupByID(selectedItem[0].json.SeriesId, selectedItem[0].json.seasonID)
else
stopLoadingSpinner()
message_dialog(tr("Error loading Season"))
end if

else if popupNode.returnData.indexselected = 4
' User chose Go to episode
CreateMovieDetailsGroup(selectedItem[0])
Expand Down
2 changes: 1 addition & 1 deletion source/ShowScenes.bs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ function CreateSeriesDetailsGroup(seriesID as string) as dynamic
' Get season data early in the function so we can check number of seasons.
seasonData = TVSeasons(seriesID)
' Divert to season details if user setting goStraightToEpisodeListing is enabled and only one season exists.
if m.global.session.user.settings["ui.tvshows.goStraightToEpisodeListing"] = true and seasonData.Items.Count() = 1
if seasonData <> invalid and m.global.session.user.settings["ui.tvshows.goStraightToEpisodeListing"] and seasonData.Items.Count() = 1
stopLoadingSpinner()
return CreateSeasonDetailsGroupByID(seriesID, seasonData.Items[0].id)
end if
Expand Down

0 comments on commit 3b13fab

Please sign in to comment.