From fc2d005d1a0e8eec957b9db7bf5767c9ca2f64b3 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Wed, 22 Nov 2023 13:37:20 -0500 Subject: [PATCH 1/6] add quickplay support for libraries that are userviews instead of collection folders --- source/utils/quickplay.bs | 95 ++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 35 deletions(-) diff --git a/source/utils/quickplay.bs b/source/utils/quickplay.bs index 44b94aa1a..1a0024abd 100644 --- a/source/utils/quickplay.bs +++ b/source/utils/quickplay.bs @@ -244,6 +244,60 @@ namespace quickplay end if end sub + ' A folder with Videos inside of it. + ' Shuffle play all videos inside that are not resumable. + sub videoFolder(itemNode as object) + print "itemNode=", itemNode + if isValidAndNotEmpty(itemNode) + ' get randomized list of videos inside + data = api.users.GetItemsByQuery(m.global.session.user.id, { + "parentId": itemNode.id, + "sortBy": "Random", + "recursive": true, + "includeItemTypes": "Movie,Video", + "limit": 2000 + }) + print "data=", data + if isValid(data) and isValidAndNotEmpty(data.items) + videoList = [] + ' add each item to the queue + for each item in data.Items + print "data.Item=", item + ' only add videos we're not currently watching + if isValid(item.userdata) and isValid(item.userdata.PlaybackPositionTicks) + if item.userdata.PlaybackPositionTicks = 0 + videoList.push(item) + end if + end if + end for + quickplay.pushToQueue(videoList) + end if + end if + end sub + + ' A folder with Series inside of it + ' Shuffle play all watched Episodes found inside + sub seriesFolder(itemNode as object) + print "itemNode=", itemNode + ' get list of tv shows inside + tvshowsData = api.users.GetItemsByQuery(m.global.session.user.id, { + "parentId": itemNode.id, + "sortBy": "Random", + "recursive": true, + "includeItemTypes": "Series", + "imageTypeLimit": 0, + "enableUserData": false, + "EnableTotalRecordCount": false, + "enableImages": false + }) + + print "tvshowsData=", tvshowsData + + if isValid(tvshowsData) and isValidAndNotEmpty(tvshowsData.items) + quickplay.multipleSeries(tvshowsData.items) + end if + end sub + ' A TV Show Season. ' Play the first unwatched episode. ' If none, play the whole season starting with episode 1. @@ -465,26 +519,7 @@ namespace quickplay print "collectionType=", collectionType if collectionType = "movies" - ' get randomized list of movies inside - data = api.users.GetItemsByQuery(m.global.session.user.id, { - "parentId": itemNode.id, - "sortBy": "Random", - "limit": 2000 - }) - - if isValid(data) and isValidAndNotEmpty(data.items) - movieList = [] - ' add each item to the queue - for each item in data.Items - ' only add movies we're not currently watching - if isValid(item.userdata) and isValid(item.userdata.PlaybackPositionTicks) - if item.userdata.PlaybackPositionTicks = 0 - movieList.push(item) - end if - end if - end for - quickplay.pushToQueue(movieList) - end if + quickplay.videoFolder(itemNode) else if collectionType = "music" ' get audio files from under this collection ' sort songs by album then artist @@ -532,21 +567,7 @@ namespace quickplay end if end if else if collectionType = "tvshows" or collectionType = "collectionfolder" - ' 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, - "enableImages": false - }) - - print "tvshowsData=", tvshowsData - - if isValid(tvshowsData) and isValidAndNotEmpty(tvshowsData.items) - quickplay.multipleSeries(tvshowsData.items) - end if + quickplay.seriesFolder(itemNode) else if collectionType = "musicvideos" ' get randomized list of videos inside data = api.users.GetItemsByQuery(m.global.session.user.id, { @@ -644,6 +665,10 @@ namespace quickplay ' play channel quickplay.tvChannel(myChannel) end if + else if collectionType = "movies" + quickplay.videoFolder(itemNode) + else if collectionType = "tvshows" + quickplay.seriesFolder(itemNode) else print "Quick Play CollectionFolder WARNING: Unknown collection type" end if From 555460a06e08d5c429d404506bb4e300365e2e29 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Wed, 22 Nov 2023 14:37:24 -0500 Subject: [PATCH 2/6] refactor to use one function instead of two --- source/utils/quickplay.bs | 71 ++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/source/utils/quickplay.bs b/source/utils/quickplay.bs index 1a0024abd..8342bbaad 100644 --- a/source/utils/quickplay.bs +++ b/source/utils/quickplay.bs @@ -275,26 +275,57 @@ namespace quickplay end if end sub - ' A folder with Series inside of it + ' A container with some kind of videos inside of it ' Shuffle play all watched Episodes found inside - sub seriesFolder(itemNode as object) + sub videoContainer(itemNode as object) print "itemNode=", itemNode - ' get list of tv shows inside - tvshowsData = api.users.GetItemsByQuery(m.global.session.user.id, { - "parentId": itemNode.id, - "sortBy": "Random", - "recursive": true, - "includeItemTypes": "Series", - "imageTypeLimit": 0, - "enableUserData": false, - "EnableTotalRecordCount": false, - "enableImages": false - }) + includeItemTypes = "" + collectionType = Lcase(itemNode.collectionType) + if collectionType = "movies" + includeItemTypes = "Movie,Video" + ' get randomized list of videos inside + data = api.users.GetItemsByQuery(m.global.session.user.id, { + "parentId": itemNode.id, + "sortBy": "Random", + "recursive": true, + "includeItemTypes": "Movie,Video", + "limit": 2000 + }) + print "data=", data + if isValid(data) and isValidAndNotEmpty(data.items) + videoList = [] + ' add each item to the queue + for each item in data.Items + print "data.Item=", item + ' only add videos we're not currently watching + if isValid(item.userdata) and isValid(item.userdata.PlaybackPositionTicks) + if item.userdata.PlaybackPositionTicks = 0 + videoList.push(item) + end if + end if + end for + quickplay.pushToQueue(videoList) + end if + return + else if collectionType = "tvshows" + includeItemTypes = "Series" - print "tvshowsData=", tvshowsData + tvshowsData = api.users.GetItemsByQuery(m.global.session.user.id, { + "parentId": itemNode.id, + "sortBy": "Random", + "recursive": true, + "includeItemTypes": includeItemTypes, + "imageTypeLimit": 0, + "enableUserData": false, + "EnableTotalRecordCount": false, + "enableImages": false + }) - if isValid(tvshowsData) and isValidAndNotEmpty(tvshowsData.items) - quickplay.multipleSeries(tvshowsData.items) + print "tvshowsData=", tvshowsData + + if isValid(tvshowsData) and isValidAndNotEmpty(tvshowsData.items) + quickplay.multipleSeries(tvshowsData.items) + end if end if end sub @@ -519,7 +550,7 @@ namespace quickplay print "collectionType=", collectionType if collectionType = "movies" - quickplay.videoFolder(itemNode) + quickplay.videoContainer(itemNode) else if collectionType = "music" ' get audio files from under this collection ' sort songs by album then artist @@ -567,7 +598,7 @@ namespace quickplay end if end if else if collectionType = "tvshows" or collectionType = "collectionfolder" - quickplay.seriesFolder(itemNode) + quickplay.videoContainer(itemNode) else if collectionType = "musicvideos" ' get randomized list of videos inside data = api.users.GetItemsByQuery(m.global.session.user.id, { @@ -666,9 +697,9 @@ namespace quickplay quickplay.tvChannel(myChannel) end if else if collectionType = "movies" - quickplay.videoFolder(itemNode) + quickplay.videoContainer(itemNode) else if collectionType = "tvshows" - quickplay.seriesFolder(itemNode) + quickplay.videoContainer(itemNode) else print "Quick Play CollectionFolder WARNING: Unknown collection type" end if From 48af6ba8f2b1217595168babd40467e8b80cf74d Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Fri, 24 Nov 2023 21:47:13 -0500 Subject: [PATCH 3/6] fix quickplay on recordings library --- source/utils/quickplay.bs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/utils/quickplay.bs b/source/utils/quickplay.bs index 8342bbaad..970dfe6b0 100644 --- a/source/utils/quickplay.bs +++ b/source/utils/quickplay.bs @@ -276,13 +276,10 @@ namespace quickplay end sub ' A container with some kind of videos inside of it - ' Shuffle play all watched Episodes found inside sub videoContainer(itemNode as object) print "itemNode=", itemNode - includeItemTypes = "" collectionType = Lcase(itemNode.collectionType) if collectionType = "movies" - includeItemTypes = "Movie,Video" ' get randomized list of videos inside data = api.users.GetItemsByQuery(m.global.session.user.id, { "parentId": itemNode.id, @@ -307,14 +304,14 @@ namespace quickplay quickplay.pushToQueue(videoList) end if return - else if collectionType = "tvshows" - includeItemTypes = "Series" + else if collectionType = "tvshows" or collectionType = "collectionfolder" + ' get list of tv shows inside tvshowsData = api.users.GetItemsByQuery(m.global.session.user.id, { "parentId": itemNode.id, "sortBy": "Random", "recursive": true, - "includeItemTypes": includeItemTypes, + "excludeItemTypes": "Season", "imageTypeLimit": 0, "enableUserData": false, "EnableTotalRecordCount": false, @@ -324,7 +321,13 @@ namespace quickplay print "tvshowsData=", tvshowsData if isValid(tvshowsData) and isValidAndNotEmpty(tvshowsData.items) - quickplay.multipleSeries(tvshowsData.items) + ' the type of media returned from api may change. + if tvshowsData.items[0].Type = "Series" + quickplay.multipleSeries(tvshowsData.items) + else + ' if first item is not a series, then assume they are all videos and/or episodes + quickplay.pushToQueue(tvshowsData.items) + end if end if end if end sub From 3c883c046c4068d9360437b6f6a05afe0bd710e3 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Fri, 24 Nov 2023 22:00:01 -0500 Subject: [PATCH 4/6] stop spinners when no items are returned or there's an unknown type --- source/utils/quickplay.bs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/utils/quickplay.bs b/source/utils/quickplay.bs index 970dfe6b0..42d988721 100644 --- a/source/utils/quickplay.bs +++ b/source/utils/quickplay.bs @@ -302,6 +302,8 @@ namespace quickplay end if end for quickplay.pushToQueue(videoList) + else + stopLoadingSpinner() end if return else if collectionType = "tvshows" or collectionType = "collectionfolder" @@ -328,7 +330,12 @@ namespace quickplay ' if first item is not a series, then assume they are all videos and/or episodes quickplay.pushToQueue(tvshowsData.items) end if + else + stopLoadingSpinner() end if + else + stopLoadingSpinner() + print "Quick Play videoContainer WARNING: Unknown collection type" end if end sub From fd1b424e4746e27b9b5a93543cbecad3254ebce6 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Tue, 28 Nov 2023 22:13:44 -0500 Subject: [PATCH 5/6] quickplay a season from the start when the episodes have no index (recordings) --- source/utils/quickplay.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/utils/quickplay.bs b/source/utils/quickplay.bs index 42d988721..8d284af6c 100644 --- a/source/utils/quickplay.bs +++ b/source/utils/quickplay.bs @@ -358,7 +358,7 @@ namespace quickplay for each item in unwatchedData.Items if isValid(item.UserData) if isValid(item.UserData.Played) and item.UserData.Played = false - firstUnwatchedEpisodeIndex = item.IndexNumber - 1 + firstUnwatchedEpisodeIndex = isValid(item.IndexNumber) ? item.IndexNumber - 1 : 0 if isValid(item.UserData.PlaybackPositionTicks) item.startingPoint = item.UserData.PlaybackPositionTicks end if From e318c829729cb1b110e7bdc420e8ff31c7ed9198 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Wed, 29 Nov 2023 22:15:01 -0500 Subject: [PATCH 6/6] remove unused code --- source/utils/quickplay.bs | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/source/utils/quickplay.bs b/source/utils/quickplay.bs index e963e0a06..a022be0f9 100644 --- a/source/utils/quickplay.bs +++ b/source/utils/quickplay.bs @@ -256,37 +256,6 @@ namespace quickplay end if end sub - ' A folder with Videos inside of it. - ' Shuffle play all videos inside that are not resumable. - sub videoFolder(itemNode as object) - print "itemNode=", itemNode - if isValidAndNotEmpty(itemNode) - ' get randomized list of videos inside - data = api.users.GetItemsByQuery(m.global.session.user.id, { - "parentId": itemNode.id, - "sortBy": "Random", - "recursive": true, - "includeItemTypes": "Movie,Video", - "limit": 2000 - }) - print "data=", data - if isValid(data) and isValidAndNotEmpty(data.items) - videoList = [] - ' add each item to the queue - for each item in data.Items - print "data.Item=", item - ' only add videos we're not currently watching - if isValid(item.userdata) and isValid(item.userdata.PlaybackPositionTicks) - if item.userdata.PlaybackPositionTicks = 0 - videoList.push(item) - end if - end if - end for - quickplay.pushToQueue(videoList) - end if - end if - end sub - ' A container with some kind of videos inside of it sub videoContainer(itemNode as object) print "itemNode=", itemNode