Propagate replacing yout.be links to /watch to RSS

This commit is contained in:
syeopite 2021-09-03 03:33:49 -07:00
parent fd6f03655e
commit a28945273d
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82

View file

@ -481,11 +481,15 @@ def replace_links(html)
url = URI.parse(anchor["href"]) url = URI.parse(anchor["href"])
if {"www.youtube.com", "m.youtube.com", "youtu.be"}.includes?(url.host) if {"www.youtube.com", "m.youtube.com", "youtu.be"}.includes?(url.host)
if url.path == "/redirect" if url.host == "youtu.be"
params = HTTP::Params.parse(url.query.not_nil!) url = "/watch?v=#{url.request_target.lstrip('/')}"
anchor["href"] = params["q"]?
else else
anchor["href"] = url.request_target if url.path == "/redirect"
params = HTTP::Params.parse(url.query.not_nil!)
anchor["href"] = params["q"]?
else
anchor["href"] = url.request_target
end
end end
elsif url.to_s == "#" elsif url.to_s == "#"
begin begin