diff --git a/CHANGELOG.md b/CHANGELOG.md index 28f6661d..94a17a71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Web server allowing the recption of the token through call back - The web server can also be used to serve a web app, facilitating the configuration of the Roku app, as well as controlling the app itself -- Added `auth/feed`, to read the subscriptions of the current user +- `auth/feed`, to read the subscriptions of the current user - Video information (Author, view count, release date) -- Added trending categories, subscription view, and custom (hardcoded) search categories +- Trending categories, subscription view, and custom (hardcoded) search categories +- User Playlist support ## [0.1.0] - 2022-10-30 ### Added diff --git a/src/components/RowListItemComponent/RowListItemComponent.bs b/src/components/RowListItemComponent/RowListItemComponent.bs index b8a6799a..79bbdf37 100644 --- a/src/components/RowListItemComponent/RowListItemComponent.bs +++ b/src/components/RowListItemComponent/RowListItemComponent.bs @@ -18,6 +18,9 @@ sub OnContentSet() end sub function FormatViewCount(viewCount) + if viewCount = invalid + return invalid + end if if viewCount < 1000 return `${FormatFloat(viewCount)} views` end if diff --git a/src/components/tasks/MainLoaderTask.brs b/src/components/tasks/MainLoaderTask.brs index 2954e51c..be94be4e 100644 --- a/src/components/tasks/MainLoaderTask.brs +++ b/src/components/tasks/MainLoaderTask.brs @@ -40,6 +40,17 @@ sub GetContent() end if end for + playlists = RokuYoutube.Services.Invidious.GetUserPlaylists() + if playlists <> invalid + for each playlist in playlists + data = GetCategoryContent(`Playlist - ${playlist.title}`, playlist.videos) + if data <> invalid + rootChildren.Push(data) + end if + + end for + end if + ' set up a root ContentNode to represent rowList on the GridScreen contentNode = CreateObject("roSGNode", "ContentNode") contentNode.Update({ diff --git a/src/source/services/Invidious.bs b/src/source/services/Invidious.bs index 8e999626..0335ade1 100644 --- a/src/source/services/Invidious.bs +++ b/src/source/services/Invidious.bs @@ -14,6 +14,7 @@ namespace RokuYoutube.Services.Invidious const SEARCH_ENDPOINT = "/api/v1/search" const AUTH_FEED = "/api/v1/auth/feed" + const AUTH_PLAYLISTS = "/api/v1/auth/playlists" function GetCountryCode() if m.countryCode = invalid or m.countryCode = "" then @@ -165,4 +166,28 @@ namespace RokuYoutube.Services.Invidious return response.json.videos end if end function + + function GetUserPlaylists() + headers = GetAuthenticationHeaders() + if headers = invalid + return invalid + end if + + url = `${API_URL}${AUTH_PLAYLISTS}` + + args = { + headers: headers, + retryCount: 3 'Sometimes authentication fails randomly with a valid token... + } + + response = Requests().get(url, args) + + if response.statuscode = 403 + RokuYoutube.Utils.Registry.Delete("token") + end if + if response.statuscode = 200 + return response.json + end if + + end function end namespace \ No newline at end of file