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