Support saved playlists (#121)

This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-07-24 08:48:07 -04:00
1 parent 1a72c69b8e
commit f2f8baa6b1
3 files changed
+28 -1

No files matched your search

+6
View File
@@ -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
@@ -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
@@ -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