mirror of
https://github.com/iv-org/invidious.git
synced 2026-07-27 16:06:47 -05:00
Merge 33cf701333ac9cf8f4b4756bb187b8e405a2fe0a into 59bb97cdc3011b37cbcd9e85f2f708f009978893
This commit is contained in:
commit
cdd4eed818
@ -80,30 +80,23 @@ module Invidious::Routes::Subscriptions
|
||||
subscriptions.sort_by!(&.author.downcase)
|
||||
|
||||
if action_takeout
|
||||
if format == "json"
|
||||
env.response.content_type = "application/json"
|
||||
env.response.headers["content-disposition"] = "attachment"
|
||||
env.response.content_type = "application/json"
|
||||
env.response.headers["content-disposition"] = "attachment"
|
||||
|
||||
if format == "json"
|
||||
return Invidious::User::Export.to_invidious(user)
|
||||
elsif format == "newpipe_json"
|
||||
return Invidious::User::Export.to_newpipe(subscriptions)
|
||||
else
|
||||
env.response.content_type = "application/xml"
|
||||
env.response.headers["content-disposition"] = "attachment"
|
||||
export = XML.build do |xml|
|
||||
xml.element("opml", version: "1.1") do
|
||||
xml.element("body") do
|
||||
if format == "newpipe"
|
||||
title = "YouTube Subscriptions"
|
||||
else
|
||||
title = "Invidious Subscriptions"
|
||||
end
|
||||
title = "Invidious Subscriptions"
|
||||
|
||||
xml.element("outline", text: title, title: title) do
|
||||
subscriptions.each do |channel|
|
||||
if format == "newpipe"
|
||||
xml_url = "https://www.youtube.com/feeds/videos.xml?channel_id=#{channel.id}"
|
||||
else
|
||||
xml_url = "#{HOST_URL}/feed/channel/#{channel.id}"
|
||||
end
|
||||
xml_url = "#{HOST_URL}/feed/channel/#{channel.id}"
|
||||
|
||||
xml.element("outline", text: channel.author, title: channel.author,
|
||||
"type": "rss", xmlUrl: xml_url)
|
||||
|
||||
@ -2,6 +2,26 @@ struct Invidious::User
|
||||
module Export
|
||||
extend self
|
||||
|
||||
def to_newpipe(subscriptions)
|
||||
return JSON.build do |json|
|
||||
json.object do
|
||||
json.field "subscriptions" do
|
||||
json.array do
|
||||
subscriptions.each do |channel|
|
||||
json.object do
|
||||
json.field "service_id", 0
|
||||
json.field "url", "https://www.youtube.com/channel/" + channel.id
|
||||
json.field "name", channel.author
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
json.field "app_version", "0.29.0"
|
||||
json.field "app_version_int", 1014
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def to_invidious(user : User)
|
||||
playlists = Invidious::Database::Playlists.select_like_iv(user.email)
|
||||
|
||||
|
||||
@ -57,7 +57,11 @@
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group">
|
||||
<a href="/subscription_manager?action_takeout=1&format=newpipe"><%= I18n.translate(locale, "Export subscriptions as OPML (for NewPipe & FreeTube)") %></a>
|
||||
<a href="/subscription_manager?action_takeout=1&format=opml_freetube"><%= I18n.translate(locale, "Export subscriptions as OPML (for FreeTube)") %></a>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group">
|
||||
<a href="/subscription_manager?action_takeout=1&format=newpipe_json"><%= I18n.translate(locale, "Export subscriptions as JSON (for NewPipe)") %></a>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user