mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Fix alt_link for youtu.be
This commit is contained in:
parent
c6accd2706
commit
298af854fc
1 changed files with 11 additions and 3 deletions
|
@ -366,16 +366,24 @@ def add_alt_links(html)
|
||||||
anchor = anchor.xpath_node("//a").not_nil!
|
anchor = anchor.xpath_node("//a").not_nil!
|
||||||
url = URI.parse(HTML.unescape(anchor["href"]))
|
url = URI.parse(HTML.unescape(anchor["href"]))
|
||||||
|
|
||||||
if ["www.youtube.com", "m.youtube.com"].includes?(url.host) && url.path == "/watch" || url.host == "youtu.be"
|
if ["www.youtube.com", "m.youtube.com"].includes?(url.host) && url.path == "/watch"
|
||||||
alt_link = <<-END_HTML
|
alt_link = <<-END_HTML
|
||||||
<a href="#{url.full_path}">
|
<a href="#{url.full_path}">
|
||||||
<i class="fa fa-link" aria-hidden="true"></i>
|
<i class="fa fa-link" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
END_HTML
|
END_HTML
|
||||||
|
elsif url.host == "youtu.be"
|
||||||
|
alt_link = <<-END_HTML
|
||||||
|
<a href="/watch?v=#{url.full_path.lchop("/")}">
|
||||||
|
<i class="fa fa-link" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
END_HTML
|
||||||
|
else
|
||||||
|
alt_link = ""
|
||||||
|
end
|
||||||
|
|
||||||
alt_links << {match.end.not_nil!, alt_link}
|
alt_links << {match.end.not_nil!, alt_link}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
alt_links.reverse!
|
alt_links.reverse!
|
||||||
alt_links.each do |position, alt_link|
|
alt_links.each do |position, alt_link|
|
||||||
|
|
Loading…
Reference in a new issue