[skip-ci] small refactor
This commit is contained in:
1 parent
310d53dd61
commit
fa3921cd33
2 files changed
+47
-13
No files matched your search
+44
-13
@@ -12,8 +12,10 @@ namespace Http
|
|||||||
function AuthorizeToken(context as object) as boolean
|
function AuthorizeToken(context as object) as boolean
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
error = "Playlet built-in Invidious backend is not a real Invidious instance, and does not support accounts."
|
response.Json({
|
||||||
response.Default(400, error)
|
"error": "Playlet built-in Invidious backend is not a real Invidious instance, and does not support accounts."
|
||||||
|
})
|
||||||
|
response.http_code = 400
|
||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -21,8 +23,10 @@ namespace Http
|
|||||||
function GetStats(context as object) as boolean
|
function GetStats(context as object) as boolean
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
error = "Playlet built-in Invidious backend is not a real Invidious instance, and does not support stats."
|
response.Json({
|
||||||
response.Default(400, error)
|
"error": "Playlet built-in Invidious backend is not a real Invidious instance, and does not support stats."
|
||||||
|
})
|
||||||
|
response.http_code = 400
|
||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -33,7 +37,10 @@ namespace Http
|
|||||||
|
|
||||||
feeds = InnertubeService.GetTrending({ type: request.query.type })
|
feeds = InnertubeService.GetTrending({ type: request.query.type })
|
||||||
if not IsArray(feeds) or feeds.Count() = 0
|
if not IsArray(feeds) or feeds.Count() = 0
|
||||||
response.Default(500, "Failed to get trending feed")
|
response.Json({
|
||||||
|
"error": "Failed to get trending feed"
|
||||||
|
})
|
||||||
|
response.http_code = 500
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -99,7 +106,10 @@ namespace Http
|
|||||||
|
|
||||||
feeds = InnertubeService.Search(query, options)
|
feeds = InnertubeService.Search(query, options)
|
||||||
if not IsArray(feeds) or feeds.Count() = 0
|
if not IsArray(feeds) or feeds.Count() = 0
|
||||||
response.Default(500, "Failed to search")
|
response.Json({
|
||||||
|
"error": "Failed to search"
|
||||||
|
})
|
||||||
|
response.http_code = 500
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -114,20 +124,29 @@ namespace Http
|
|||||||
|
|
||||||
url = request.query.url
|
url = request.query.url
|
||||||
if StringUtils.IsNullOrEmpty(url)
|
if StringUtils.IsNullOrEmpty(url)
|
||||||
response.Default(400, "Missing 'url' query parameter")
|
response.Json({
|
||||||
|
"error": "Missing 'url' query parameter"
|
||||||
|
})
|
||||||
|
response.http_code = 400
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
json = InnertubeService.ResolveUrl(url, response)
|
json = InnertubeService.ResolveUrl(url, response)
|
||||||
if json = invalid
|
if json = invalid
|
||||||
response.Default(500, "Failed to resolve URL")
|
response.Json({
|
||||||
|
"error": "Failed to resolve URL"
|
||||||
|
})
|
||||||
|
response.http_code = 500
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
endpoint = json["endpoint"]
|
endpoint = json["endpoint"]
|
||||||
pageType = ValidString(ObjectUtils.Dig(endpoint, ["commandMetadata", "webCommandMetadata", "webPageType"]))
|
pageType = ValidString(ObjectUtils.Dig(endpoint, ["commandMetadata", "webCommandMetadata", "webPageType"]))
|
||||||
if pageType = "WEB_PAGE_TYPE_UNKNOWN" or pageType = ""
|
if pageType = "WEB_PAGE_TYPE_UNKNOWN" or pageType = ""
|
||||||
response.Default(400, "Unknown url")
|
response.Json({
|
||||||
|
"error": "Unknown page type"
|
||||||
|
})
|
||||||
|
response.http_code = 400
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -198,7 +217,10 @@ namespace Http
|
|||||||
|
|
||||||
playerResponse = InnertubeService.GetVideoMetadata(videoId)
|
playerResponse = InnertubeService.GetVideoMetadata(videoId)
|
||||||
if not playerResponse.IsSuccess()
|
if not playerResponse.IsSuccess()
|
||||||
response.Default(playerResponse.StatusCode(), playerResponse.ErrorMessage())
|
response.Json({
|
||||||
|
"error": playerResponse.ErrorMessage()
|
||||||
|
})
|
||||||
|
response.http_code = playerResponse.StatusCode()
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -221,7 +243,10 @@ namespace Http
|
|||||||
|
|
||||||
playlist = InnertubeService.GetPlaylist(playlistId, options)
|
playlist = InnertubeService.GetPlaylist(playlistId, options)
|
||||||
if playlist = invalid
|
if playlist = invalid
|
||||||
response.Default(500, "Failed to get playlist")
|
response.Json({
|
||||||
|
"error": "Failed to get playlist"
|
||||||
|
})
|
||||||
|
response.http_code = 500
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -257,7 +282,10 @@ namespace Http
|
|||||||
channelId = channelAndTab[0]
|
channelId = channelAndTab[0]
|
||||||
channel = InnertubeService.GetChannel(channelId, options)
|
channel = InnertubeService.GetChannel(channelId, options)
|
||||||
if channel = invalid
|
if channel = invalid
|
||||||
response.Default(500, "Failed to get channel")
|
response.Json({
|
||||||
|
"error": "Failed to get channel"
|
||||||
|
})
|
||||||
|
response.http_code = 500
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -274,7 +302,10 @@ namespace Http
|
|||||||
|
|
||||||
channel = InnertubeService.GetChannel(channelId, options)
|
channel = InnertubeService.GetChannel(channelId, options)
|
||||||
if channel = invalid
|
if channel = invalid
|
||||||
response.Default(500, "Failed to get channel")
|
response.Json({
|
||||||
|
"error": "Failed to get channel"
|
||||||
|
})
|
||||||
|
response.http_code = 500
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,9 @@
|
|||||||
try {
|
try {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
videoMetadata = await PlayletApi.getVideoInfo(videoId);
|
videoMetadata = await PlayletApi.getVideoInfo(videoId);
|
||||||
|
if (videoMetadata?.error) {
|
||||||
|
throw videoMetadata.error;
|
||||||
|
}
|
||||||
videoStartAtChecked = timestamp !== undefined;
|
videoStartAtChecked = timestamp !== undefined;
|
||||||
if (videoStartAtChecked) {
|
if (videoStartAtChecked) {
|
||||||
videoStartAtTimestamp = timestamp;
|
videoStartAtTimestamp = timestamp;
|
||||||
|
|||||||
Reference in new issue
Block a user