Backend can return raw response
This commit is contained in:
1 parent
951a13be1f
commit
975980a3b5
3 files changed
+131
-16
No files matched your search
@@ -18,6 +18,7 @@ namespace InnertubeService
|
||||
cancellation = invalid
|
||||
fetchNext = true
|
||||
ctt = ""
|
||||
raw = false
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
@@ -29,6 +30,9 @@ namespace InnertubeService
|
||||
if options.DoesExist("ctt")
|
||||
ctt = options.ctt
|
||||
end if
|
||||
if options.DoesExist("raw")
|
||||
raw = options.raw
|
||||
end if
|
||||
end if
|
||||
|
||||
playerRequest = Innertube.CreatePlayerRequest(videoId, ctt)
|
||||
@@ -60,6 +64,16 @@ namespace InnertubeService
|
||||
nextResponse = nextRequest.Await()
|
||||
end if
|
||||
|
||||
if raw
|
||||
rawResponse = {
|
||||
"playerResponse": playerResponse.Json()
|
||||
}
|
||||
if fetchNext
|
||||
rawResponse["nextResponse"] = nextResponse.Json()
|
||||
end if
|
||||
return rawResponse
|
||||
end if
|
||||
|
||||
parsedResponse = Innertube.ParseInnertubePlayerResponse(playerResponse.Json())
|
||||
if parsedResponse.error <> invalid
|
||||
return parsedResponse
|
||||
@@ -158,6 +172,7 @@ namespace InnertubeService
|
||||
searchFilters = invalid
|
||||
continuation = ""
|
||||
cancellation = invalid
|
||||
raw = false
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("searchFilters")
|
||||
@@ -169,14 +184,18 @@ namespace InnertubeService
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("raw")
|
||||
raw = options.raw
|
||||
end if
|
||||
end if
|
||||
|
||||
return Innertube.Search(query, searchFilters, continuation, cancellation)
|
||||
return Innertube.Search(query, searchFilters, continuation, cancellation, raw)
|
||||
end function
|
||||
|
||||
function GetTrending(options = invalid as object) as object
|
||||
cancellation = invalid
|
||||
params = ""
|
||||
raw = false
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("cancellation")
|
||||
@@ -193,6 +212,9 @@ namespace InnertubeService
|
||||
params = "4gIKGgh0cmFpbGVycw%3D%3D"
|
||||
end if
|
||||
end if
|
||||
if options.DoesExist("raw")
|
||||
raw = options.raw
|
||||
end if
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest("FEtrending", Innertube.ClientType.WEB, params)
|
||||
@@ -203,8 +225,11 @@ namespace InnertubeService
|
||||
return invalid
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
feeds = Innertube.ParseResponseDataForFeeds(json, { skipCreatorOnTheRise: true })
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { skipCreatorOnTheRise: true })
|
||||
|
||||
result = {
|
||||
feeds: feeds
|
||||
@@ -270,6 +295,7 @@ namespace InnertubeService
|
||||
continuation = ""
|
||||
params = ""
|
||||
cancellation = invalid
|
||||
raw = false
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("continuation")
|
||||
@@ -281,6 +307,9 @@ namespace InnertubeService
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("raw")
|
||||
raw = options.raw
|
||||
end if
|
||||
end if
|
||||
|
||||
request = Innertube.CreateBrowseRequest(channelId, Innertube.ClientType.Web, params, continuation)
|
||||
@@ -293,8 +322,11 @@ namespace InnertubeService
|
||||
}
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
result = Innertube.ParseChannelPageResponseData(json)
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
result = Innertube.ParseChannelPageResponseData(response.Json())
|
||||
if result.authorId = invalid and result.error = invalid
|
||||
result["authorId"] = channelId
|
||||
end if
|
||||
@@ -310,6 +342,7 @@ namespace InnertubeService
|
||||
function GetPlaylist(playlistId as string, options = invalid as object) as object
|
||||
continuation = ""
|
||||
cancellation = invalid
|
||||
raw = false
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("continuation")
|
||||
@@ -318,6 +351,9 @@ namespace InnertubeService
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("raw")
|
||||
raw = options.raw
|
||||
end if
|
||||
end if
|
||||
|
||||
if not playlistId.StartsWith("VL")
|
||||
@@ -334,8 +370,11 @@ namespace InnertubeService
|
||||
}
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
result = Innertube.ParsePlaylistPageResponseData(json)
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
result = Innertube.ParsePlaylistPageResponseData(response.Json())
|
||||
|
||||
cacheControl = Innertube.ParseResponseForCacheControl(response)
|
||||
if cacheControl <> invalid
|
||||
@@ -348,6 +387,7 @@ namespace InnertubeService
|
||||
function GetMix(mixId as string, options = invalid as object) as object
|
||||
videoId = ""
|
||||
cancellation = invalid
|
||||
raw = false
|
||||
|
||||
if options <> invalid
|
||||
if options.DoesExist("videoId")
|
||||
@@ -356,6 +396,9 @@ namespace InnertubeService
|
||||
if options.DoesExist("cancellation")
|
||||
cancellation = options.cancellation
|
||||
end if
|
||||
if options.DoesExist("raw")
|
||||
raw = options.raw
|
||||
end if
|
||||
end if
|
||||
|
||||
args = { "playlistId": mixId }
|
||||
@@ -372,8 +415,11 @@ namespace InnertubeService
|
||||
}
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
return Innertube.ParseMixPageResponseData(json)
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
return Innertube.ParseMixPageResponseData(response.Json())
|
||||
end function
|
||||
|
||||
function ResolveUrl(url as string, options = invalid as object) as object
|
||||
|
||||
@@ -6,7 +6,7 @@ import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Innertube
|
||||
|
||||
function Search(query as string, searchFilters as object, continuation = "" as string, cancellation = invalid as object) as object
|
||||
function Search(query as string, searchFilters as object, continuation = "" as string, cancellation = invalid as object, raw = false as boolean) as object
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
|
||||
payload = {
|
||||
@@ -43,6 +43,10 @@ namespace Innertube
|
||||
}
|
||||
end if
|
||||
|
||||
if raw
|
||||
return response.Json()
|
||||
end if
|
||||
|
||||
feeds = ParseResponseDataForFeeds(response.Json())
|
||||
|
||||
result = {
|
||||
|
||||
+71
-6
@@ -185,7 +185,19 @@ namespace Http
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
result = InnertubeService.GetTrending({ type: request.query.type })
|
||||
raw = request.query.raw <> invalid
|
||||
|
||||
options = {
|
||||
raw: raw
|
||||
type: request.query.type
|
||||
}
|
||||
|
||||
result = InnertubeService.GetTrending(options)
|
||||
if raw
|
||||
response.Json(result)
|
||||
return true
|
||||
end if
|
||||
|
||||
if result.error <> invalid
|
||||
response.Json(result)
|
||||
response.http_code = 500
|
||||
@@ -239,6 +251,11 @@ namespace Http
|
||||
|
||||
query = request.query.q
|
||||
continuation = request.query.continuation
|
||||
raw = request.query.raw <> invalid
|
||||
|
||||
options = {
|
||||
raw: raw
|
||||
}
|
||||
|
||||
searchFilters = {}
|
||||
sort = request.query.sort
|
||||
@@ -262,7 +279,6 @@ namespace Http
|
||||
searchFilters.features = features.Split(",")
|
||||
end if
|
||||
|
||||
options = {}
|
||||
if searchFilters.Count() > 0
|
||||
options.searchFilters = searchFilters
|
||||
end if
|
||||
@@ -277,6 +293,11 @@ namespace Http
|
||||
return true
|
||||
end if
|
||||
|
||||
if raw
|
||||
response.Json(result)
|
||||
return true
|
||||
end if
|
||||
|
||||
if not IsArray(result.feeds) or result.feeds.Count() = 0
|
||||
response.Json({
|
||||
"error": "Failed to search"
|
||||
@@ -299,6 +320,8 @@ namespace Http
|
||||
response = context.response
|
||||
|
||||
url = request.query.url
|
||||
raw = request.query.raw <> invalid
|
||||
|
||||
if StringUtils.IsNullOrEmpty(url)
|
||||
response.Json({
|
||||
"error": "Missing 'url' query parameter"
|
||||
@@ -307,7 +330,7 @@ namespace Http
|
||||
return true
|
||||
end if
|
||||
|
||||
json = InnertubeService.ResolveUrl(url, response)
|
||||
json = InnertubeService.ResolveUrl(url)
|
||||
if json = invalid
|
||||
response.Json({
|
||||
"error": "Failed to resolve URL"
|
||||
@@ -316,6 +339,11 @@ namespace Http
|
||||
return true
|
||||
end if
|
||||
|
||||
if raw
|
||||
response.Json(json)
|
||||
return true
|
||||
end if
|
||||
|
||||
endpoint = json["endpoint"]
|
||||
pageType = ValidString(ObjectUtils.Dig(endpoint, ["commandMetadata", "webCommandMetadata", "webPageType"]))
|
||||
if pageType = "WEB_PAGE_TYPE_UNKNOWN" or pageType = ""
|
||||
@@ -392,8 +420,16 @@ namespace Http
|
||||
route = request.route
|
||||
|
||||
videoId = route.Mid("/playlet-invidious-backend/api/v1/videos/".Len())
|
||||
if videoId.InStr("?") > 0
|
||||
videoId = videoId.Left(videoId.InStr("?"))
|
||||
end if
|
||||
raw = request.query.raw <> invalid
|
||||
|
||||
metadata = InnertubeService.GetVideoMetadata(videoId)
|
||||
options = {
|
||||
raw: raw
|
||||
}
|
||||
|
||||
metadata = InnertubeService.GetVideoMetadata(videoId, options)
|
||||
response.Json(metadata)
|
||||
|
||||
if metadata.error <> invalid
|
||||
@@ -409,9 +445,16 @@ namespace Http
|
||||
route = request.route
|
||||
|
||||
playlistId = route.Mid("/playlet-invidious-backend/api/v1/playlists/".Len())
|
||||
if playlistId.InStr("?") > 0
|
||||
playlistId = playlistId.Left(playlistId.InStr("?"))
|
||||
end if
|
||||
continuation = request.query.continuation
|
||||
raw = request.query.raw <> invalid
|
||||
|
||||
options = {
|
||||
raw: raw
|
||||
}
|
||||
|
||||
options = {}
|
||||
if playlistId.StartsWith("RD")
|
||||
if not StringUtils.IsNullOrEmpty(continuation)
|
||||
options.videoId = continuation
|
||||
@@ -431,6 +474,11 @@ namespace Http
|
||||
playlist = InnertubeService.GetPlaylist(playlistId, options)
|
||||
end if
|
||||
|
||||
if raw
|
||||
response.Json(playlist)
|
||||
return true
|
||||
end if
|
||||
|
||||
if playlist.error <> invalid
|
||||
response.Json(playlist)
|
||||
response.http_code = 500
|
||||
@@ -456,10 +504,17 @@ namespace Http
|
||||
route = request.route
|
||||
|
||||
channelAndTab = route.Mid("/playlet-invidious-backend/api/v1/channels/".Len())
|
||||
if channelAndTab.InStr("?") > 0
|
||||
channelAndTab = channelAndTab.Left(channelAndTab.InStr("?"))
|
||||
end if
|
||||
channelAndTab = channelAndTab.Split("/")
|
||||
|
||||
options = {}
|
||||
continuation = request.query.continuation
|
||||
raw = request.query.raw <> invalid
|
||||
|
||||
options = {
|
||||
raw: raw
|
||||
}
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(continuation)
|
||||
options.continuation = continuation
|
||||
@@ -468,6 +523,11 @@ namespace Http
|
||||
if channelAndTab.Count() = 1
|
||||
channelId = channelAndTab[0]
|
||||
channel = InnertubeService.GetChannel(channelId, options)
|
||||
if raw
|
||||
response.Json(channel)
|
||||
return true
|
||||
end if
|
||||
|
||||
if channel.error <> invalid
|
||||
response.Json(channel)
|
||||
response.http_code = 500
|
||||
@@ -490,6 +550,11 @@ namespace Http
|
||||
end if
|
||||
|
||||
channel = InnertubeService.GetChannel(channelId, options)
|
||||
if raw
|
||||
response.Json(channel)
|
||||
return true
|
||||
end if
|
||||
|
||||
if channel.error <> invalid
|
||||
response.Json(channel)
|
||||
response.http_code = 500
|
||||
|
||||
Reference in new issue
Block a user