forked from midou/invidious
Allow channel urls to be displayed in YT description
This commit is contained in:
parent
97e3938f5f
commit
d420741cc1
@ -6,14 +6,20 @@ def parse_command(command : JSON::Any?, string : String) : String?
|
|||||||
|
|
||||||
# 3rd party URL, extract original URL from YouTube tracking URL
|
# 3rd party URL, extract original URL from YouTube tracking URL
|
||||||
if url_endpoint = on_tap.try &.["urlEndpoint"]?
|
if url_endpoint = on_tap.try &.["urlEndpoint"]?
|
||||||
|
if url_endpoint["url"].as_s.includes? "youtube.com/redirect"
|
||||||
youtube_url = URI.parse url_endpoint["url"].as_s
|
youtube_url = URI.parse url_endpoint["url"].as_s
|
||||||
|
|
||||||
original_url = youtube_url.query_params["q"]?
|
original_url = youtube_url.query_params["q"]?
|
||||||
if original_url.nil?
|
if original_url.nil?
|
||||||
return ""
|
return ""
|
||||||
else
|
else
|
||||||
return "<a href=\"#{original_url}\">#{original_url}</a>"
|
return "<a href=\"#{original_url}\">#{original_url}</a>"
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
# not a redirect url, some first party url
|
||||||
|
# see https://github.com/iv-org/invidious/issues/3751
|
||||||
|
first_party_url = url_endpoint["url"].as_s
|
||||||
|
return "<a href=\"#{first_party_url.sub("https://www.youtube.com", "")}\">#{first_party_url}</a>"
|
||||||
|
end
|
||||||
# 1st party watch URL
|
# 1st party watch URL
|
||||||
elsif watch_endpoint = on_tap.try &.["watchEndpoint"]?
|
elsif watch_endpoint = on_tap.try &.["watchEndpoint"]?
|
||||||
video_id = watch_endpoint["videoId"].as_s
|
video_id = watch_endpoint["videoId"].as_s
|
||||||
|
Loading…
Reference in New Issue
Block a user