summaryrefslogtreecommitdiffstats
path: root/src/invidious.cr
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-09-30 15:36:35 -0400
committerGitHub <noreply@github.com>2019-09-30 15:36:35 -0400
commiteef66de68ce1a998f5102dd62868109d20163a2b (patch)
treeb72a5698989df7cee67997a183a6121dcf34c922 /src/invidious.cr
parent553d52a45e018bbfc4948e8a61411d9449cbbab4 (diff)
parent4aa1180fce1eea8eea262be276660f5a8ca4b324 (diff)
downloadinvidious-eef66de68ce1a998f5102dd62868109d20163a2b.tar.gz
invidious-eef66de68ce1a998f5102dd62868109d20163a2b.tar.bz2
invidious-eef66de68ce1a998f5102dd62868109d20163a2b.zip
Merge pull request #743 from girst/rssparams
Forward query string parameters from Atom feeds
Diffstat (limited to 'src/invidious.cr')
-rw-r--r--src/invidious.cr18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 20a84625..c5101e4f 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -2642,6 +2642,8 @@ get "/feed/channel/:ucid" do |env|
ucid = env.params.url["ucid"]
+ params = HTTP::Params.parse(env.params.query["params"]? || "")
+
begin
channel = get_about_info(ucid, locale)
rescue ex : ChannelRedirect
@@ -2704,7 +2706,7 @@ get "/feed/channel/:ucid" do |env|
end
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
@@ -2735,6 +2737,8 @@ get "/feed/private" do |env|
page = env.params.query["page"]?.try &.to_i?
page ||= 1
+ params = HTTP::Params.parse(env.params.query["params"]? || "")
+
videos, notifications = get_subscription_feed(PG_DB, user, max_results, page)
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) }
(notifications + videos).each do |video|
- video.to_xml(locale, host_url, xml)
+ video.to_xml(locale, host_url, params, xml)
end
end
end
@@ -2761,6 +2765,8 @@ get "/feed/playlist/:plid" do |env|
plid = env.params.url["plid"]
+ params = HTTP::Params.parse(env.params.query["params"]? || "")
+
host_url = make_host_url(config, Kemal.config)
path = env.request.path
@@ -2771,10 +2777,10 @@ get "/feed/playlist/:plid" do |env|
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}"
+ when "url", "href"
+ full_path = URI.parse(node[attribute.name]).full_path
+ query_string_opt = full_path.starts_with?("/watch?v=") ? "&#{params}" : ""
+ node[attribute.name] = "#{host_url}#{full_path}#{query_string_opt}"
end
end
end