mirror of
https://github.com/iv-org/invidious.git
synced 2024-10-01 01:35:38 -04:00
Make head request to resolve short urls
This commit is contained in:
parent
d7901c1e0d
commit
7e267da5be
@ -159,6 +159,11 @@ module Invidious::Routes::API::V1::Misc
|
|||||||
return error_json(400, "Missing URL to resolve") if !url
|
return error_json(400, "Missing URL to resolve") if !url
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
head_response = HTTP::Client.head url.as(String)
|
||||||
|
if head_response.headers["location"]?
|
||||||
|
url = head_response.headers["location"]
|
||||||
|
end
|
||||||
|
|
||||||
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 || ""
|
pageType = endpoint.dig?("commandMetadata", "webCommandMetadata", "webPageType").try &.as_s || ""
|
||||||
|
Loading…
Reference in New Issue
Block a user