- Get your YouTube subscribed channels by Google API
- Save it locally as
youtube.json
- Run
export_opml.py
to generateoutput.opml
- Import generated OPML file in your RSS client
Last active
January 27, 2021 05:45
-
-
Save DearRude/8a753b5634338ebd635b3ada9a851ccb to your computer and use it in GitHub Desktop.
Make RSS OPML out of YouTube Subscriptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from lxml import etree | |
BRIDGE = "https://sebsauvage.net/rss-bridge/?action=display&bridge=Youtube&context=By+channel+id&c=CHANNELID&format=Mrss" | |
with open("youtube.json", "r") as p: | |
page = json.load(p) | |
opml = etree.Element("opml", version="1.0") | |
head = etree.SubElement(opml, "head") | |
etree.SubElement(head, "title").text = "YouTube Sub" | |
body = etree.SubElement(opml, "body") | |
parent = etree.SubElement(body, "outline", title="YouTube", text="YouTube") | |
for item in page["items"]: | |
channel_id = item["snippet"]["resourceId"]["channelId"] | |
title = item["snippet"]["title"] | |
url = BRIDGE.replace("CHANNELID", channel_id) | |
etree.SubElement(parent, "outline", title=title, text=title, type="rss", xmlUrl=url) | |
et = etree.ElementTree(opml) | |
et.write('output.opml', pretty_print=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment