summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrahim Hadriche <brahim.hadriche@gmail.com>2023-10-26 17:48:58 -0400
committerBrahim Hadriche <brahim.hadriche@gmail.com>2023-10-26 17:48:58 -0400
commit7e267da5beef5981b6db40e7b20f23f5dbd81136 (patch)
tree21e86e9b44873b07d659d8ba89b9989a0c1e4597 /src
parentd7901c1e0d1e9b9d36cc35d35f43c91b88ebcce4 (diff)
downloadinvidious-7e267da5beef5981b6db40e7b20f23f5dbd81136.tar.gz
invidious-7e267da5beef5981b6db40e7b20f23f5dbd81136.tar.bz2
invidious-7e267da5beef5981b6db40e7b20f23f5dbd81136.zip
Make head request to resolve short urls
Diffstat (limited to 'src')
-rw-r--r--src/invidious/routes/api/v1/misc.cr5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr
index bad47709..47ec977e 100644
--- a/src/invidious/routes/api/v1/misc.cr
+++ b/src/invidious/routes/api/v1/misc.cr
@@ -159,6 +159,11 @@ module Invidious::Routes::API::V1::Misc
return error_json(400, "Missing URL to resolve") if !url
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))
endpoint = resolved_url["endpoint"]
pageType = endpoint.dig?("commandMetadata", "webCommandMetadata", "webPageType").try &.as_s || ""