Skip to content

Commit

Permalink
refactor to use one function instead of two
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert committed Nov 22, 2023
1 parent fc2d005 commit 555460a
Showing 1 changed file with 51 additions and 20 deletions.
71 changes: 51 additions & 20 deletions source/utils/quickplay.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 555460a

Please sign in to comment.