mirror of
https://github.com/iv-org/invidious.git
synced 2026-08-16 21:10:53 -05:00
Merge dcda5260d98c6660b570ed492c55f9d5326196b9 into d10f2a48021f1768f2d6ff3bd1b9f3de4e0b2d22
This commit is contained in:
commit
11ef49d375
@ -51,8 +51,8 @@
|
||||
"Import NewPipe subscriptions (.json)": "Import NewPipe subscriptions (.json)",
|
||||
"Import NewPipe data (.zip)": "Import NewPipe data (.zip)",
|
||||
"Export": "Export",
|
||||
"Export subscriptions as OPML": "Export subscriptions as OPML",
|
||||
"Export subscriptions as OPML (for NewPipe & FreeTube)": "Export subscriptions as OPML (for NewPipe & FreeTube)",
|
||||
"Export subscriptions as OPML (for FreeTube)": "Export subscriptions as OPML (for FreeTube)",
|
||||
"Export subscriptions as JSON (for NewPipe)": "Export subscriptions as JSON (for NewPipe)",
|
||||
"Export data as JSON": "Export Invidious data as JSON",
|
||||
"Delete account?": "Delete account?",
|
||||
"History": "History",
|
||||
|
||||
@ -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"
|
||||
|
||||
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
|
||||
|
||||
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.element("outline", text: channel.author, title: channel.author,
|
||||
"type": "rss", xmlUrl: xml_url)
|
||||
|
||||
@ -2,6 +2,30 @@ struct Invidious::User
|
||||
module Export
|
||||
extend self
|
||||
|
||||
NEWPIPE_APP_VERSION = "0.29.0"
|
||||
NEWPIPE_APP_VERSION_INT = 1014
|
||||
NEWPIPE_YT_SERVICE_ID = 0
|
||||
|
||||
def to_newpipe(subscriptions : Array(InvidiousChannel))
|
||||
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", NEWPIPE_YT_SERVICE_ID
|
||||
json.field "url", "https://www.youtube.com/channel/" + channel.id
|
||||
json.field "name", channel.author
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
json.field "app_version", NEWPIPE_APP_VERSION
|
||||
json.field "app_version_int", NEWPIPE_APP_VERSION_INT
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def to_invidious(user : User)
|
||||
playlists = Invidious::Database::Playlists.select_like_iv(user.email)
|
||||
|
||||
|
||||
@ -53,11 +53,11 @@
|
||||
<legend><%= I18n.translate(locale, "Export") %></legend>
|
||||
|
||||
<div class="pure-control-group">
|
||||
<a href="/subscription_manager?action_takeout=1"><%= I18n.translate(locale, "Export subscriptions as OPML") %></a>
|
||||
<a href="/subscription_manager?action_takeout=1&format=opml"><%= 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"><%= I18n.translate(locale, "Export subscriptions as OPML (for NewPipe & FreeTube)") %></a>
|
||||
<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