Skip to content

Instantly share code, notes, and snippets.

@nikhilCad
Created July 22, 2023 05:19
Show Gist options
  • Save nikhilCad/1e032196c0c83e3c74131d19ff0443ca to your computer and use it in GitHub Desktop.
Save nikhilCad/1e032196c0c83e3c74131d19ff0443ca to your computer and use it in GitHub Desktop.
Exporting JSON Newpipe Subscriptions to OPML for RSS Readers
import json
f = open('Your_Newpipe_subscription_export.json')
data = json.load(f)#dict
f.close()
formpre = """<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Newpipe Youtube OPML</title>
</head>
<body>
<outline title="Newpipe Youtube" text="Newpipe Youtube">
"""
formcontent = ""
for i in data['subscriptions']:
url = i['url'].replace('channel/','feeds/videos.xml?channel_id=')
temp = '<outline text="{name}" title="{name}" type="rss" xmlUrl="{url}"/>\n'.format(name = i['name'], url=url)
formcontent += temp
formpost = """</outline>
</body>
</opml>"""
# <outline text="Big News Finland" title="Big News Finland" type="rss" xmlUrl="http://www.bignewsnetwork.com/?rss=37e8860164ce009a"/>
content = formpre + formcontent + formpost
with open("test.opml", "w") as text_file:
text_file.write(content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment