mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-26 07:27:22 +00:00
add pageType
This commit is contained in:
parent
bf5175d1e9
commit
c162c7ff3f
@ -161,19 +161,19 @@ module Invidious::Routes::API::V1::Misc
|
|||||||
begin
|
begin
|
||||||
resolved_url = YoutubeAPI.resolve_url(url.as(String))
|
resolved_url = YoutubeAPI.resolve_url(url.as(String))
|
||||||
endpoint = resolved_url["endpoint"]
|
endpoint = resolved_url["endpoint"]
|
||||||
|
pageType = endpoint.dig?("commandMetadata", "webCommandMetadata", "webPageType").try &.as_s || ""
|
||||||
if resolved_ucid = endpoint.dig?("watchEndpoint", "videoId")
|
if resolved_ucid = endpoint.dig?("watchEndpoint", "videoId")
|
||||||
elsif resolved_ucid = endpoint.dig?("browseEndpoint", "browseId")
|
elsif resolved_ucid = endpoint.dig?("browseEndpoint", "browseId")
|
||||||
elsif pageType = endpoint.dig?("commandMetadata", "webCommandMetadata", "webPageType").try &.as_s || ""
|
elsif pageType == "WEB_PAGE_TYPE_UNKNOWN"
|
||||||
if pageType == "WEB_PAGE_TYPE_UNKNOWN"
|
|
||||||
return error_json(400, "Unknown url")
|
return error_json(400, "Unknown url")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
rescue ex
|
rescue ex
|
||||||
return error_json(500, ex)
|
return error_json(500, ex)
|
||||||
end
|
end
|
||||||
JSON.build do |json|
|
JSON.build do |json|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "ucid", resolved_ucid.try &.as_s || ""
|
json.field "ucid", resolved_ucid.try &.as_s || ""
|
||||||
|
json.field "pageType", pageType
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user