mirror of
https://github.com/iv-org/invidious.git
synced 2024-10-01 01:35:38 -04:00
Merge pull request #743 from girst/rssparams
Forward query string parameters from Atom feeds
This commit is contained in:
commit
eef66de68c
@ -2642,6 +2642,8 @@ get "/feed/channel/:ucid" do |env|
|
|||||||
|
|
||||||
ucid = env.params.url["ucid"]
|
ucid = env.params.url["ucid"]
|
||||||
|
|
||||||
|
params = HTTP::Params.parse(env.params.query["params"]? || "")
|
||||||
|
|
||||||
begin
|
begin
|
||||||
channel = get_about_info(ucid, locale)
|
channel = get_about_info(ucid, locale)
|
||||||
rescue ex : ChannelRedirect
|
rescue ex : ChannelRedirect
|
||||||
@ -2704,7 +2706,7 @@ get "/feed/channel/:ucid" do |env|
|
|||||||
end
|
end
|
||||||
|
|
||||||
videos.each do |video|
|
videos.each do |video|
|
||||||
video.to_xml(host_url, channel.auto_generated, xml)
|
video.to_xml(host_url, channel.auto_generated, params, xml)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2735,6 +2737,8 @@ get "/feed/private" do |env|
|
|||||||
page = env.params.query["page"]?.try &.to_i?
|
page = env.params.query["page"]?.try &.to_i?
|
||||||
page ||= 1
|
page ||= 1
|
||||||
|
|
||||||
|
params = HTTP::Params.parse(env.params.query["params"]? || "")
|
||||||
|
|
||||||
videos, notifications = get_subscription_feed(PG_DB, user, max_results, page)
|
videos, notifications = get_subscription_feed(PG_DB, user, max_results, page)
|
||||||
host_url = make_host_url(config, Kemal.config)
|
host_url = make_host_url(config, Kemal.config)
|
||||||
|
|
||||||
@ -2748,7 +2752,7 @@ get "/feed/private" do |env|
|
|||||||
xml.element("title") { xml.text translate(locale, "Invidious Private Feed for `x`", user.email) }
|
xml.element("title") { xml.text translate(locale, "Invidious Private Feed for `x`", user.email) }
|
||||||
|
|
||||||
(notifications + videos).each do |video|
|
(notifications + videos).each do |video|
|
||||||
video.to_xml(locale, host_url, xml)
|
video.to_xml(locale, host_url, params, xml)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2761,6 +2765,8 @@ get "/feed/playlist/:plid" do |env|
|
|||||||
|
|
||||||
plid = env.params.url["plid"]
|
plid = env.params.url["plid"]
|
||||||
|
|
||||||
|
params = HTTP::Params.parse(env.params.query["params"]? || "")
|
||||||
|
|
||||||
host_url = make_host_url(config, Kemal.config)
|
host_url = make_host_url(config, Kemal.config)
|
||||||
path = env.request.path
|
path = env.request.path
|
||||||
|
|
||||||
@ -2771,10 +2777,10 @@ get "/feed/playlist/:plid" do |env|
|
|||||||
document.xpath_nodes(%q(//*[@href]|//*[@url])).each do |node|
|
document.xpath_nodes(%q(//*[@href]|//*[@url])).each do |node|
|
||||||
node.attributes.each do |attribute|
|
node.attributes.each do |attribute|
|
||||||
case attribute.name
|
case attribute.name
|
||||||
when "url"
|
when "url", "href"
|
||||||
node["url"] = "#{host_url}#{URI.parse(node["url"]).full_path}"
|
full_path = URI.parse(node[attribute.name]).full_path
|
||||||
when "href"
|
query_string_opt = full_path.starts_with?("/watch?v=") ? "&#{params}" : ""
|
||||||
node["href"] = "#{host_url}#{URI.parse(node["href"]).full_path}"
|
node[attribute.name] = "#{host_url}#{full_path}#{query_string_opt}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -41,13 +41,15 @@ struct ChannelVideo
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_xml(locale, host_url, xml : XML::Builder)
|
def to_xml(locale, host_url, query_params, xml : XML::Builder)
|
||||||
|
query_params["v"] = self.id
|
||||||
|
|
||||||
xml.element("entry") do
|
xml.element("entry") do
|
||||||
xml.element("id") { xml.text "yt:video:#{self.id}" }
|
xml.element("id") { xml.text "yt:video:#{self.id}" }
|
||||||
xml.element("yt:videoId") { xml.text self.id }
|
xml.element("yt:videoId") { xml.text self.id }
|
||||||
xml.element("yt:channelId") { xml.text self.ucid }
|
xml.element("yt:channelId") { xml.text self.ucid }
|
||||||
xml.element("title") { xml.text self.title }
|
xml.element("title") { xml.text self.title }
|
||||||
xml.element("link", rel: "alternate", href: "#{host_url}/watch?v=#{self.id}")
|
xml.element("link", rel: "alternate", href: "#{host_url}/watch?#{query_params}")
|
||||||
|
|
||||||
xml.element("author") do
|
xml.element("author") do
|
||||||
xml.element("name") { xml.text self.author }
|
xml.element("name") { xml.text self.author }
|
||||||
@ -56,7 +58,7 @@ struct ChannelVideo
|
|||||||
|
|
||||||
xml.element("content", type: "xhtml") do
|
xml.element("content", type: "xhtml") do
|
||||||
xml.element("div", xmlns: "http://www.w3.org/1999/xhtml") do
|
xml.element("div", xmlns: "http://www.w3.org/1999/xhtml") do
|
||||||
xml.element("a", href: "#{host_url}/watch?v=#{self.id}") do
|
xml.element("a", href: "#{host_url}/watch?#{query_params}") do
|
||||||
xml.element("img", src: "#{host_url}/vi/#{self.id}/mqdefault.jpg")
|
xml.element("img", src: "#{host_url}/vi/#{self.id}/mqdefault.jpg")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
struct SearchVideo
|
struct SearchVideo
|
||||||
def to_xml(host_url, auto_generated, xml : XML::Builder)
|
def to_xml(host_url, auto_generated, query_params, xml : XML::Builder)
|
||||||
|
query_params["v"] = self.id
|
||||||
|
|
||||||
xml.element("entry") do
|
xml.element("entry") do
|
||||||
xml.element("id") { xml.text "yt:video:#{self.id}" }
|
xml.element("id") { xml.text "yt:video:#{self.id}" }
|
||||||
xml.element("yt:videoId") { xml.text self.id }
|
xml.element("yt:videoId") { xml.text self.id }
|
||||||
xml.element("yt:channelId") { xml.text self.ucid }
|
xml.element("yt:channelId") { xml.text self.ucid }
|
||||||
xml.element("title") { xml.text self.title }
|
xml.element("title") { xml.text self.title }
|
||||||
xml.element("link", rel: "alternate", href: "#{host_url}/watch?v=#{self.id}")
|
xml.element("link", rel: "alternate", href: "#{host_url}/watch?#{query_params}")
|
||||||
|
|
||||||
xml.element("author") do
|
xml.element("author") do
|
||||||
if auto_generated
|
if auto_generated
|
||||||
@ -19,7 +21,7 @@ struct SearchVideo
|
|||||||
|
|
||||||
xml.element("content", type: "xhtml") do
|
xml.element("content", type: "xhtml") do
|
||||||
xml.element("div", xmlns: "http://www.w3.org/1999/xhtml") do
|
xml.element("div", xmlns: "http://www.w3.org/1999/xhtml") do
|
||||||
xml.element("a", href: "#{host_url}/watch?v=#{self.id}") do
|
xml.element("a", href: "#{host_url}/watch?#{query_params}") do
|
||||||
xml.element("img", src: "#{host_url}/vi/#{self.id}/mqdefault.jpg")
|
xml.element("img", src: "#{host_url}/vi/#{self.id}/mqdefault.jpg")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -40,12 +42,12 @@ struct SearchVideo
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_xml(host_url, auto_generated, xml : XML::Builder | Nil = nil)
|
def to_xml(host_url, auto_generated, query_params, xml : XML::Builder | Nil = nil)
|
||||||
if xml
|
if xml
|
||||||
to_xml(host_url, auto_generated, xml)
|
to_xml(host_url, auto_generated, query_params, xml)
|
||||||
else
|
else
|
||||||
XML.build do |json|
|
XML.build do |json|
|
||||||
to_xml(host_url, auto_generated, xml)
|
to_xml(host_url, auto_generated, query_params, xml)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user