Add channel and playlist endpoints (#29)
* Add channel and playlist endpoints * Fix playlist title
This commit is contained in:
1 parent
493a8f7d17
commit
9a65bd4657
2 files changed
+64
-14
No files matched your search
@@ -4,7 +4,6 @@
|
||||
"name": "trending",
|
||||
"displayName": "Trending",
|
||||
"url": "/api/v1/trending",
|
||||
"authenticated": false,
|
||||
"queryParams": {
|
||||
"type": {
|
||||
"required": false,
|
||||
@@ -22,7 +21,7 @@
|
||||
"fields": {
|
||||
"required": false,
|
||||
"type": "string",
|
||||
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow"
|
||||
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow,isUpcoming,premiereTimestamp"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -30,12 +29,11 @@
|
||||
"name": "popular",
|
||||
"displayName": "Popular",
|
||||
"url": "/api/v1/popular",
|
||||
"authenticated": false,
|
||||
"queryParams": {
|
||||
"fields": {
|
||||
"required": false,
|
||||
"type": "string",
|
||||
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow"
|
||||
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow,isUpcoming,premiereTimestamp"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -106,7 +104,7 @@
|
||||
"fields": {
|
||||
"required": false,
|
||||
"type": "string",
|
||||
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow"
|
||||
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow,isUpcoming,premiereTimestamp"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -129,6 +127,38 @@
|
||||
"retryCount": 3
|
||||
},
|
||||
"responseHandler": "AuthPlaylistsHandler"
|
||||
},
|
||||
{
|
||||
"name": "playlist",
|
||||
"displayName": "Playlist",
|
||||
"url": "/api/v1/playlists/:plid",
|
||||
"responseHandler": "PlaylistHandler"
|
||||
},
|
||||
{
|
||||
"name": "mix",
|
||||
"displayName": "Mix",
|
||||
"url": "/api/v1/mixes/:rdid",
|
||||
"responseHandler": "PlaylistHandler"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"displayName": "Channel",
|
||||
"url": "/api/v1/channels/videos/:ucid",
|
||||
"queryParams": {
|
||||
"sort_by": {
|
||||
"required": false,
|
||||
"type": [
|
||||
"newest",
|
||||
"oldest",
|
||||
"popular"
|
||||
]
|
||||
},
|
||||
"fields": {
|
||||
"required": false,
|
||||
"type": "string",
|
||||
"default": "title,videoId,videoThumbnails,lengthSeconds,viewCount,author,publishedText,liveNow,isUpcoming,premiereTimestamp"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -18,7 +18,8 @@ class InvidiousService
|
||||
m.responseHanlders = {
|
||||
DefaultHandler: m.DefaultHandler,
|
||||
AuthFeedHandler: m.AuthFeedHandler,
|
||||
AuthPlaylistsHandler: m.AuthPlaylistsHandler
|
||||
AuthPlaylistsHandler: m.AuthPlaylistsHandler,
|
||||
PlaylistHandler: m.PlaylistHandler
|
||||
}
|
||||
end function
|
||||
|
||||
@@ -64,6 +65,12 @@ class InvidiousService
|
||||
args.params.append(requestData.queryParams)
|
||||
end if
|
||||
|
||||
if requestData.pathParams <> invalid
|
||||
for each param in requestData.pathParams
|
||||
url = url.Replace(`:${param}`, requestData.pathParams[param])
|
||||
end for
|
||||
end if
|
||||
|
||||
if endpoint.requestArgs <> invalid
|
||||
args.append(endpoint.requestArgs)
|
||||
end if
|
||||
@@ -106,21 +113,27 @@ class InvidiousService
|
||||
playlists = response.json
|
||||
result = {}
|
||||
for each playlist in playlists
|
||||
title = requestData.title
|
||||
title = m.ProcessTemplate(title, playlist)
|
||||
result[title] = playlist.videos
|
||||
result.append(m.ProcessPlaylist(requestData, playlist))
|
||||
end for
|
||||
return result
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function DeleteExpiredToken(response as object)
|
||||
if response.statuscode = 403
|
||||
print(`Server responded with 403: ${response.text}`)
|
||||
print("deleting token...")
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
function PlaylistHandler(m as object, requestData as object, response as object) as object
|
||||
if response.statuscode = 200
|
||||
playlist = response.json
|
||||
return m.ProcessPlaylist(requestData, playlist)
|
||||
end if
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function ProcessPlaylist(requestData as object, playlist as object) as object
|
||||
title = requestData.title
|
||||
title = m.ProcessTemplate(title, playlist)
|
||||
result = {}
|
||||
result[title] = playlist.videos
|
||||
return result
|
||||
end function
|
||||
|
||||
function ProcessTemplate(template as string, data as object) as string
|
||||
@@ -130,4 +143,11 @@ class InvidiousService
|
||||
return template
|
||||
end function
|
||||
|
||||
function DeleteExpiredToken(response as object)
|
||||
if response.statuscode = 403
|
||||
print(`Server responded with 403: ${response.text}`)
|
||||
print("deleting token...")
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
end if
|
||||
end function
|
||||
end class
|
||||
Reference in new issue
Block a user