Skip to content

Commit

Permalink
Create My List - a personal queue
Browse files Browse the repository at this point in the history
  • Loading branch information
1hitsong committed Dec 23, 2024
1 parent 0c083c4 commit d7bba36
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 2 deletions.
34 changes: 34 additions & 0 deletions components/ItemGrid/LoadItemsTask2.bs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,40 @@ sub loadItems()
params.limit = 100 ' If you have more than 100 in your Next Up queue, maybe go outside a bit more.
params.append({ ImageTypeLimit: 1 })
params.append({ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" })
else if isStringEqual(m.top.ItemType, "mylist")
data = api.GetUserViews({ "userId": m.global.session.user.id })
if not isChainValid(data, "Items") then return

myListPlaylist = invalid

for each item in data.LookupCI("items")
if isStringEqual(item.LookupCI("CollectionType"), "playlists")
myListPlaylist = api.items.Get({
"userid": m.global.session.user.id,
"includeItemTypes": "Playlist",
"nameStartsWith": "[ROKU] My List",
"parentId": item.LookupCI("id")
})
exit for
end if
end for

if not isValid(myListPlaylist) or not isValidAndNotEmpty(myListPlaylist.items) then return

playlistID = myListPlaylist.items[0].LookupCI("id")

if not isValid(playlistID) then return

url = "/items/"

params.append(
{ UserId: m.global.session.user.id,
ImageTypeLimit: 1,
EnableImageTypes: `${ImageType.PRIMARY}, ${ImageType.BACKDROP}, ${ImageType.THUMB}`,
Limit: 50,
EnableTotalRecordCount: false,
ParentId: playlistID
})
else
url = Substitute("Users/{0}/Items/", m.global.session.user.id)
end if
Expand Down
25 changes: 23 additions & 2 deletions components/Libraries/VisualLibraryScene.bs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,15 @@ sub loadInitialItems()

' Boxsets are sorted by Premiere Data by default
if not isValidAndNotEmpty(m.sortField)
m.sortField = isStringEqual(getCollectionType(), ItemType.BOXSET) ? "PremiereDate,SortName" : "SortName"
if isStringEqual(getCollectionType(), ItemType.BOXSET)
m.sortField = "PremiereDate,SortName"
else if isStringEqual(getCollectionType(), ItemType.MYLIST)
m.sortField = "OrderAdded"
else
m.sortField = "SortName"
end if
end if

if not isValidAndNotEmpty(m.filter) then m.filter = "All"
if not isValidAndNotEmpty(m.filterOptions) then m.filterOptions = "{}"
if not isValidAndNotEmpty(m.view) then m.view = "presentation"
Expand Down Expand Up @@ -335,6 +342,10 @@ function setOptions() as object
return setMovieOptions()
end if

if isStringEqual(m.top.mediaType, ItemType.MYLIST)
return setMovieOptions()
end if

if isStringEqual(m.top.mediaType, ItemType.SERIES)
return setSeriesOptions()
end if
Expand Down Expand Up @@ -392,6 +403,10 @@ function setMovieOptions() as object
]
end if

if inArray([ItemType.MYLIST], getCollectionType())
options.sort.unshift({ "Title": tr("Order Added"), "Name": "OrderAdded", "Track": { "description": tr("Order Added") } })
end if

if isStringEqual(m.view, "genres")
options.sort = [{ "Title": tr("TITLE"), "Name": "SortName", "Track": { "description": tr("TITLE") } }]
options.filter = [{ "Title": tr("All"), "Name": "All" }]
Expand Down Expand Up @@ -1178,7 +1193,13 @@ sub onViewChange()
m.loadItemsTask.searchTerm = string.EMPTY
m.filter = "All"
m.filterOptions = {}
m.sortField = "SortName"
if isStringEqual(getCollectionType(), ItemType.BOXSET)
m.sortField = "PremiereDate,SortName"
else if isStringEqual(getCollectionType(), ItemType.MYLIST)
m.sortField = "OrderAdded"
else
m.sortField = "SortName"
end if
m.sortAscending = true

' Reset view to defaults
Expand Down
15 changes: 15 additions & 0 deletions components/home/LoadItemsTask.bs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,21 @@ function loadMyList() as object
results.push(tmp)
end for

if myListData.Items.count() > 3
tmp = CreateObject("roSGNode", "HomeData")
tmp.id = playlistID
tmp.type = ItemType.COLLECTIONFOLDER
tmp.usePoster = false
tmp.json = {
id: playlistID,
IsFolder: true,
Name: tr("View Full List"),
Type: ItemType.COLLECTIONFOLDER,
CollectionType: "mylist"
}
results.Unshift(tmp)
end if

return results
end function

Expand Down
6 changes: 6 additions & 0 deletions source/MainEventHandlers.bs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,12 @@ sub onLibrarySelection(selectedItem)
return
end if

if isStringEqual(selectedItem.collectionType, CollectionType.MYLIST)
group = CreateVisualLibraryScene(selectedItem, ITEMTYPE.MYLIST)
m.global.sceneManager.callFunc("pushScene", group)
return
end if

group = CreateItemGrid(selectedItem)
m.global.sceneManager.callFunc("pushScene", group)
end sub
Expand Down
1 change: 1 addition & 0 deletions source/enums/CollectionType.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum CollectionType
MOVIES = "movies"
MUSIC = "music"
MUSICVIDEOS = "musicvideos"
MYLIST = "mylist"
NEXTUP = "nextup"
TVSHOWS = "tvshows"
end enum
1 change: 1 addition & 0 deletions source/enums/ItemType.bs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum ItemType
MUSICALBUM = "musicalbum"
MUSICARTIST = "musicartist"
MUSICVIDEO = "musicvideo"
MYLIST = "mylist"
PERSON = "person"
PHOTO = "photo"
PHOTOALBUM = "photoalbum"
Expand Down
8 changes: 8 additions & 0 deletions source/static/whatsNew/1.1.4.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@
{
"description": "Fix possible crash if music album doesn't have an image",
"author": "1hitsong"
},
{
"description": "Create My List - a personal queue",
"author": "1hitsong"
},
{
"description": "Fix default sort after changing view of boxset items",
"author": "1hitsong"
}
]

0 comments on commit d7bba36

Please sign in to comment.