diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ab11ad4..0f8965b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Support for saved playlists. By adding a playlist from a youtube channel to your Invidious profile, you can see the playlist on Playlet. + ## [0.10.2] - 2023-07-10 ### Added diff --git a/playlet-lib/src/source/services/Invidious.bs b/playlet-lib/src/source/services/Invidious.bs index bcdcda4d..9d9fd8fa 100644 --- a/playlet-lib/src/source/services/Invidious.bs +++ b/playlet-lib/src/source/services/Invidious.bs @@ -13,6 +13,7 @@ namespace Invidious const STATS_ENDPOINT = "/api/v1/stats" const VIDEOS_ENDPOINT = "/api/v1/videos" + const PLAYLISTS_ENDPOINT = "/api/v1/playlists" const HISTORY_ENDPOINT = "/api/v1/auth/history" const SEARCH_SUGGEST_ENDPOINT = "/api/v1/search/suggestions" @@ -80,6 +81,18 @@ namespace Invidious } end function + function GetPlaylist(playlistId as string) as object + instance = InvidiousSettings.GetCurrentInstance() + url = `${instance}${Invidious.PLAYLISTS_ENDPOINT}/${playlistId}` + + args = Invidious.DefaultArgs() + response = Requests().get(url, args) + if not response.ok + return invalid + end if + return response.json + end function + function MarkVideoWatched(videoId as string) as boolean authToken = InvidiousSettings.GetAuthToken() if authToken = invalid diff --git a/playlet-lib/src/source/services/InvidiousService.bs b/playlet-lib/src/source/services/InvidiousService.bs index b22abf6b..84db22f0 100644 --- a/playlet-lib/src/source/services/InvidiousService.bs +++ b/playlet-lib/src/source/services/InvidiousService.bs @@ -4,6 +4,7 @@ import "pkg:/source/utils/RegistryUtils.bs" import "pkg:/source/utils/General.bs" import "pkg:/source/utils/Crypto.bs" import "pkg:/source/services/InvidiousSettings.bs" +import "pkg:/source/services/Invidious.bs" class InvidiousService private endpoints @@ -118,7 +119,14 @@ class InvidiousService playlists = response.json result = [] for each playlist in playlists - result.push(m.ProcessPlaylist(requestData, playlist)) + ' Saved playlists are not included in the response + ' https://github.com/iv-org/invidious/issues/3995 + if playlist.videos.count() = 0 and playlist.authorId = invalid and not playlist.playlistId.StartsWith("IV") + playlist = Invidious.GetPlaylist(playlist.playlistId) + end if + if playlist <> invalid + result.push(m.ProcessPlaylist(requestData, playlist)) + end if end for return result end if