Skip to content

Add subscription JSON export for NewPipe - #5826

Open
unrealtournament wants to merge 2 commits into
iv-org:masterfrom
unrealtournament:feat/newpipe-json
Open

Add subscription JSON export for NewPipe#5826
unrealtournament wants to merge 2 commits into
iv-org:masterfrom
unrealtournament:feat/newpipe-json

Conversation

@unrealtournament

@unrealtournament unrealtournament commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Checklist

  • I have read the AI Policy and understand the disclosure requirements

AI Disclosure

  • AI was not used to create this pull request
  • AI was used to fully create this pull request
  • AI was used to partially create this pull request

Pull request description

The current option to export subscriptions for NewPipe (Export subscriptions as OPML (for NewPipe & FreeTube)) isn't accepted by NewPipe anymore. As far as I can tell, NewPipe only accepts importing from its own SQLite database, from Google Account CSV export and from its own JSON export format. This is mentioned in #5438.

This PR adds support to export subscriptions in the NewPipe compatible format. I'm looking for input on a few points:

  • I'm not a huge fan of hardcoding the NewPipe version in the export, but it is required by NewPipe to recognize it as a valid file. If someone has a better idea I'm all ears but I think it's the only way. In any case, NewPipe can import formats in a backwards compatible way in the future so it shouldn't be a huge deal.
  • I haven't checked if the OPML export option actually works for FreeTube. If it doesn't, it should probably be removed altogether, for now I just removed the (for NewPipe) part.
  • The translations would need to be updated, but I don't know how that is handled in this project so I need some help there.

The new format looks like this:

{
  "subscriptions": [
    {
      "service_id": 0,
      "url": "https://www.youtube.com/channel/UCHnyfMqiRRG1u-2MsSQLbXA",
      "name": "Veritasium"
    },
    {
      "service_id": 0,
      "url": "https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA",
      "name": "Vsauce"
    }
  ],
  "app_version": "0.29.0",
  "app_version_int": 1014
}

The new options in the frontend look like:

image

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a NewPipe-compatible subscription export option because NewPipe no longer accepts the existing OPML export format for subscriptions.

Changes:

  • Adds a NewPipe subscription JSON export generator (to_newpipe).
  • Updates the user data control page to expose separate export options for FreeTube (OPML) and NewPipe (JSON).
  • Adjusts /subscription_manager takeout routing to serve either Invidious JSON, NewPipe JSON, or OPML.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/invidious/views/user/data_control.ecr Adds new export links/options in the user data control UI.
src/invidious/user/exports.cr Implements NewPipe subscription JSON export generation.
src/invidious/routes/subscriptions.cr Routes takeout requests to the appropriate export format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to +23
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
Comment on lines +60 to +64
<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>
Comment on lines +95 to 102
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants