Support saved playlists (#121)
This commit is contained in:
1 parent
1a72c69b8e
commit
f2f8baa6b1
3 files changed
+28
-1
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user