chore: move FreeTube OPML export to Invidious::User::Export module (#6107)

This commit is contained in:
Fijxu
2026-10-31 18:37:47 -03:00
committed by GitHub
parent 867f06398b
commit fcec088154
2 changed files with 22 additions and 19 deletions

View File

@@ -96,25 +96,7 @@ module Invidious::Routes::Subscriptions
else
env.response.content_type = "application/xml"
env.response.headers["Content-Disposition"] = "attachment; filename=\"invidious_subscriptions_#{export_time}.opml\""
export = XML.build do |xml|
xml.element("opml", version: "1.1") do
xml.element("body") do
title = "Invidious Subscriptions"
xml.element("outline", text: title, title: title) do
subscriptions.each do |channel|
xml_url = "#{HOST_URL}/feed/channel/#{channel.id}"
xml.element("outline", text: channel.author, title: channel.author,
"type": "rss", xmlUrl: xml_url)
end
end
end
end
end
return export.gsub(%(<?xml version="1.0"?>\n), "")
return Invidious::User::Export.to_freetube_opml(subscriptions)
end
end

View File

@@ -76,5 +76,26 @@ struct Invidious::User
def to_invidious(user : User)
Invidious.new(user).to_json
end
def to_freetube_opml(subscriptions : Array(InvidiousChannel))
export = XML.build do |xml|
xml.element("opml", version: "1.1") do
xml.element("body") do
title = "Invidious Subscriptions"
xml.element("outline", text: title, title: title) do
subscriptions.each do |channel|
xml_url = "#{HOST_URL}/feed/channel/#{channel.id}"
xml.element("outline", text: channel.author, title: channel.author,
"type": "rss", xmlUrl: xml_url)
end
end
end
end
end
export.gsub(%(<?xml version="1.0"?>\n), "")
end
end # module
end