Skip to content

Commit

Permalink
Fix episode list regression + limit all queries to 2000 items
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert committed Sep 23, 2023
1 parent 4dcc3ad commit e4f0510
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/tvshows/TVEpisodes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</children>
<interface>
<field id="episodeSelected" alias="picker.itemSelected" />
<field id="quickPlayNode" type="node" alwaysNotify="true" />
<field id="quickPlayNode" type="node" />
<field id="seasonData" type="assocarray" onChange="setSeasonLoading" />
<field id="objects" alias="picker.objects" />
</interface>
Expand Down
5 changes: 3 additions & 2 deletions source/Main.brs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ sub Main (args as dynamic) as void
if isValid(reportingNode)
itemNode = reportingNode.quickPlayNode
reportingNodeType = reportingNode.subtype()
' prevent double fire on continue watching home row
if isValid(reportingNodeType) and reportingNodeType = "Home"
print "Quick Play reporting node type=", reportingNodeType
' prevent double fire bug
if isValid(reportingNodeType) and (reportingNodeType = "Home" or reportingNodeType = "TVEpisodes")
reportingNode.quickPlayNode = invalid
end if
end if
Expand Down
33 changes: 27 additions & 6 deletions source/utils/quickplay.bs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace quickplay
"parentId": itemNode.id,
"imageTypeLimit": 1,
"sortBy": "SortName",
"limit": 2000,
"enableUserData": false,
"EnableTotalRecordCount": false
})
Expand All @@ -99,6 +100,7 @@ namespace quickplay
"artistIds": itemNode.id,
"includeItemTypes": "Audio",
"sortBy": "Album",
"limit": 2000,
"imageTypeLimit": 1,
"Recursive": true,
"enableUserData": false,
Expand All @@ -124,6 +126,7 @@ namespace quickplay
data = api.items.GetByQuery({
"userid": m.global.session.user.id,
"parentid": itemNode.id,
"limit": 2000,
"EnableTotalRecordCount": false
})
if isValid(data) and isValidAndNotEmpty(data.Items)
Expand Down Expand Up @@ -181,6 +184,7 @@ namespace quickplay
data = api.shows.GetEpisodes(itemNode.id, {
"userid": m.global.session.user.id,
"SortBy": "Random",
"limit": 2000,
"EnableTotalRecordCount": false
})

Expand All @@ -196,10 +200,13 @@ namespace quickplay
' Shuffle play all watched episodes
sub multipleSeries(itemNodes as object)
if isValidAndNotEmpty(itemNodes)
numTotal = 0
numLimit = 2000
for each tvshow in itemNodes
' grab all watched episodes for each series
showData = api.shows.GetEpisodes(tvshow.id, {
"userId": m.global.session.user.id,
"SortBy": "Random",
"imageTypeLimit": 0,
"EnableTotalRecordCount": false,
"enableImages": false
Expand All @@ -214,6 +221,13 @@ namespace quickplay
end if
end if
end for

' keep track of how many items we've seen
numTotal = numTotal + showData.items.count()
if numTotal >= numLimit
' stop grabbing more items if we hit our limit
exit for
end if
end if
end for
if m.global.queueManager.callFunc("getCount") > 1
Expand All @@ -231,6 +245,7 @@ namespace quickplay
unwatchedData = api.shows.GetEpisodes(itemNode.json.SeriesId, {
"seasonId": itemNode.id,
"userid": m.global.session.user.id,
"limit": 2000,
"EnableTotalRecordCount": false
})

Expand Down Expand Up @@ -292,7 +307,8 @@ namespace quickplay
if not isValid(itemNode) or not isValid(itemNode.id) then return
' get playlist items
myPlaylist = api.playlists.GetItems(itemNode.id, {
"userId": m.global.session.user.id
"userId": m.global.session.user.id,
"limit": 2000
})

if isValid(myPlaylist) and isValidAndNotEmpty(myPlaylist.Items)
Expand All @@ -311,15 +327,14 @@ namespace quickplay
"includeItemTypes": ["Episode", "Movie", "Video"],
"videoTypes": "VideoFile",
"sortBy": "Random",
"limit": 2000,
"imageTypeLimit": 1,
"Recursive": true,
"enableUserData": false,
"EnableTotalRecordCount": false
}
' modify api query based on folder type
folderType = Lcase(itemNode.json.type)

' modify qpi query based on folder type
if folderType = "studio"
paramArray["studioIds"] = itemNode.id
else if folderType = "genre"
Expand All @@ -331,7 +346,7 @@ namespace quickplay
else
paramArray["parentId"] = itemNode.id
end if
' loof for tv series in stead of video files
' look for tv series instead of video files
if isValid(itemNode.json.SeriesCount) and itemNode.json.SeriesCount > 0
paramArray["includeItemTypes"] = "Series"
paramArray.Delete("videoTypes")
Expand Down Expand Up @@ -370,7 +385,8 @@ namespace quickplay
if collectionType = "movies"
' get randomized list of movies inside
data = api.users.GetItemsByQuery(m.global.session.user.id, {
"parentId": itemNode.id
"parentId": itemNode.id,
"limit": 2000
})

if isValid(data) and isValidAndNotEmpty(data.items)
Expand All @@ -395,6 +411,7 @@ namespace quickplay
"includeItemTypes": "Audio",
"sortBy": "Album",
"Recursive": true,
"limit": 2000,
"imageTypeLimit": 1,
"enableUserData": false,
"EnableTotalRecordCount": false
Expand All @@ -410,6 +427,7 @@ namespace quickplay
' get list of all boxsets inside
boxsetData = api.users.GetItemsByQuery(m.global.session.user.id, {
"parentId": itemNode.id,
"limit": 2000,
"imageTypeLimit": 0,
"enableUserData": false,
"EnableTotalRecordCount": false,
Expand Down Expand Up @@ -438,6 +456,7 @@ namespace quickplay
' get list of tv shows inside
tvshowsData = api.users.GetItemsByQuery(m.global.session.user.id, {
"parentId": itemNode.id,
"sortBy": "Random",
"imageTypeLimit": 0,
"enableUserData": false,
"EnableTotalRecordCount": false,
Expand All @@ -456,6 +475,7 @@ namespace quickplay
"includeItemTypes": "MusicVideo",
"sortBy": "Random",
"Recursive": true,
"limit": 2000,
"imageTypeLimit": 1,
"enableUserData": false,
"EnableTotalRecordCount": false
Expand Down Expand Up @@ -501,7 +521,8 @@ namespace quickplay
print "myPlaylist=", myPlaylist
playlistItems = api.playlists.GetItems(myPlaylist.id, {
"userId": m.global.session.user.id,
"EnableTotalRecordCount": false
"EnableTotalRecordCount": false,
"limit": 2000
})
' validate api results
if isValid(playlistItems) and isValidAndNotEmpty(playlistItems.items)
Expand Down

0 comments on commit e4f0510

Please sign in to comment.