mirror of
https://github.com/iv-org/invidious.git
synced 2024-09-12 01:28:13 +02:00
Add playlist RSS
This commit is contained in:
parent
296771809a
commit
bd5ec2f2f3
@ -1618,6 +1618,38 @@ get "/feed/private" do |env|
|
|||||||
feed
|
feed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/feed/playlist/:plid" do |env|
|
||||||
|
plid = env.params.url["plid"]
|
||||||
|
|
||||||
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?)
|
||||||
|
path = env.request.path
|
||||||
|
|
||||||
|
client = make_client(YT_URL)
|
||||||
|
response = client.get("/feeds/videos.xml?playlist_id=#{plid}")
|
||||||
|
document = XML.parse(response.body)
|
||||||
|
|
||||||
|
document.xpath_nodes(%q(//*[@href]|//*[@url])).each do |node|
|
||||||
|
node.attributes.each do |attribute|
|
||||||
|
case attribute.name
|
||||||
|
when "url"
|
||||||
|
node["url"] = "#{host_url}#{URI.parse(node["url"]).full_path}"
|
||||||
|
when "href"
|
||||||
|
node["href"] = "#{host_url}#{URI.parse(node["href"]).full_path}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
document = document.to_xml(options: XML::SaveOptions::NO_DECL)
|
||||||
|
|
||||||
|
document.scan(/<uri>(?<url>[^<]+)<\/uri>/).each do |match|
|
||||||
|
content = "#{host_url}#{URI.parse(match["url"]).full_path}"
|
||||||
|
document = document.gsub(match[0], "<uri>#{content}</uri>")
|
||||||
|
end
|
||||||
|
|
||||||
|
env.response.content_type = "text/xml"
|
||||||
|
document
|
||||||
|
end
|
||||||
|
|
||||||
# Channels
|
# Channels
|
||||||
|
|
||||||
# YouTube appears to let users set a "brand" URL that
|
# YouTube appears to let users set a "brand" URL that
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
<div class="pure-u-2-3">
|
<div class="pure-u-2-3">
|
||||||
<h3><%= playlist.title %></h3>
|
<h3><%= playlist.title %></h3>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pure-u-1-3" style="text-align:right;">
|
||||||
|
<h3>
|
||||||
|
<a href="/feed/playlist/<%= plid %>"><i class="icon ion-logo-rss"></i></a>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-g h-box">
|
<div class="pure-g h-box">
|
||||||
<div class="pure-u-1 pure-u-md-1-4">
|
<div class="pure-u-1 pure-u-md-1-4">
|
||||||
|
Loading…
Reference in New Issue
Block a user