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",
|
"name": "trending",
|
||||||
"displayName": "Trending",
|
"displayName": "Trending",
|
||||||
"url": "/api/v1/trending",
|
"url": "/api/v1/trending",
|
||||||
"authenticated": false,
|
|
||||||
"queryParams": {
|
"queryParams": {
|
||||||
"type": {
|
"type": {
|
||||||
"required": false,
|
"required": false,
|
||||||
@@ -22,7 +21,7 @@
|
|||||||
"fields": {
|
"fields": {
|
||||||
"required": false,
|
"required": false,
|
||||||
"type": "string",
|
"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",
|
"name": "popular",
|
||||||
"displayName": "Popular",
|
"displayName": "Popular",
|
||||||
"url": "/api/v1/popular",
|
"url": "/api/v1/popular",
|
||||||
"authenticated": false,
|
|
||||||
"queryParams": {
|
"queryParams": {
|
||||||
"fields": {
|
"fields": {
|
||||||
"required": false,
|
"required": false,
|
||||||
"type": "string",
|
"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": {
|
"fields": {
|
||||||
"required": false,
|
"required": false,
|
||||||
"type": "string",
|
"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
|
"retryCount": 3
|
||||||
},
|
},
|
||||||
"responseHandler": "AuthPlaylistsHandler"
|
"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 = {
|
m.responseHanlders = {
|
||||||
DefaultHandler: m.DefaultHandler,
|
DefaultHandler: m.DefaultHandler,
|
||||||
AuthFeedHandler: m.AuthFeedHandler,
|
AuthFeedHandler: m.AuthFeedHandler,
|
||||||
AuthPlaylistsHandler: m.AuthPlaylistsHandler
|
AuthPlaylistsHandler: m.AuthPlaylistsHandler,
|
||||||
|
PlaylistHandler: m.PlaylistHandler
|
||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -64,6 +65,12 @@ class InvidiousService
|
|||||||
args.params.append(requestData.queryParams)
|
args.params.append(requestData.queryParams)
|
||||||
end if
|
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
|
if endpoint.requestArgs <> invalid
|
||||||
args.append(endpoint.requestArgs)
|
args.append(endpoint.requestArgs)
|
||||||
end if
|
end if
|
||||||
@@ -106,21 +113,27 @@ class InvidiousService
|
|||||||
playlists = response.json
|
playlists = response.json
|
||||||
result = {}
|
result = {}
|
||||||
for each playlist in playlists
|
for each playlist in playlists
|
||||||
title = requestData.title
|
result.append(m.ProcessPlaylist(requestData, playlist))
|
||||||
title = m.ProcessTemplate(title, playlist)
|
|
||||||
result[title] = playlist.videos
|
|
||||||
end for
|
end for
|
||||||
return result
|
return result
|
||||||
end if
|
end if
|
||||||
return invalid
|
return invalid
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function DeleteExpiredToken(response as object)
|
function PlaylistHandler(m as object, requestData as object, response as object) as object
|
||||||
if response.statuscode = 403
|
if response.statuscode = 200
|
||||||
print(`Server responded with 403: ${response.text}`)
|
playlist = response.json
|
||||||
print("deleting token...")
|
return m.ProcessPlaylist(requestData, playlist)
|
||||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
|
||||||
end if
|
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
|
end function
|
||||||
|
|
||||||
function ProcessTemplate(template as string, data as object) as string
|
function ProcessTemplate(template as string, data as object) as string
|
||||||
@@ -130,4 +143,11 @@ class InvidiousService
|
|||||||
return template
|
return template
|
||||||
end function
|
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
|
end class
|
||||||
Reference in new issue
Block a user