jeb5 / youtube-subscriptions-rss Goto Github PK
View Code? Open in Web Editor NEWGenerate an OPML file of RSS feeds for your YouTube subscriptions
Generate an OPML file of RSS feeds for your YouTube subscriptions
Just wanted to say thanks for this, saved me writing a whole bunch of stuff on my own to try and get an RSS feed of my sub feed! Still have to deal with those damn Shorts showing up in feeds, but thankfully I can just unfollow that one channel and get their stuff through other means.
Thank you for creating and sharing this project, it's really helpful!
I'd love it if you could export channel URL in addition to RSS URL.
Here is my patch for it.
@@ -16,13 +16,14 @@
label.innerText = `Fetching URLS... (${progress.value}/${progress.max})`;
try {
const channelName = e.querySelector("yt-formatted-string.ytd-channel-name").innerText;
+ const channelUrl = e.href;
const channelReq = await fetch(e.href);
if (!channelReq.ok) { console.error(`Couldn't fetch channel page for ${channelName}`); continue; }
const channelPageDoc = new DOMParser().parseFromString(await channelReq.text(), "text/html");
const links = channelPageDoc.querySelectorAll("body > link[rel=alternate], body > link[rel=canonical]");
const channelIdMatch = [...links].map(e => e.href.match("/channel/([a-zA-Z0-9_\-]+?)$")).find(e => e != null);
if (channelIdMatch == null) { console.error(`Couldn't find channel id for ${channelName}`); continue; }
- channels.push([`https://www.youtube.com/feeds/videos.xml?channel_id=${channelIdMatch[1]}`, channelName]);
+ channels.push([`https://www.youtube.com/feeds/videos.xml?channel_id=${channelIdMatch[1]}`, channelName, channelUrl]);
} finally {
progress.value++;
progress.replaceWith(progress);
@@ -35,8 +36,8 @@
console.log(channels.map(([feed, _]) => feed).join("\n"));
let opmlText = `<opml version="1.0">\n\t<head>\n\t\t<title>YouTube Subscriptions as RSS</title>\n\t</head>\n\t<body>\n\t\t<outline text="YouTube Subscriptions">${channels
.map(
- ([feed, channelName]) =>
- `\n\t\t\t<outline type="rss" text="${channelName}" xmlUrl="${feed}"/>`
+ ([feed, channelName, channelUrl]) =>
+ `\n\t\t\t<outline type="rss" text="${channelName}" xmlUrl="${feed}" htmlUrl="${channelUrl}"/>`
)
.join("")}\n\t\t</outline>\n\t</body>\n</opml>`;
const url = window.URL.createObjectURL(new Blob([opmlText], { type: "text/plain" }));
Tried importing them in Thunderbird and Akregator and it doesn't work. I think it has something to do with the feed putting everything in a single line. I tried fixing that with a simple beautify method but that didn't fix the issue. I have 1500 subscriptions so maybe that might be why.
Great script, thank you!
Just please put a disclaimer or automate scrolling down to the very bottom so all channels are loaded otherwise only first 100 will be saved and the user may not know if they have 102 channels
It seems that if the channel name contains an ampersand the resulting XML is malformed. It might happen with some other characters as well.
Example channel for testing: https://www.youtube.com/@KeyAndPeele
It can be easily fixed by hand afterwards so it's not a big issue, though.
First of all, thank you for the great script! It helped me a lot.
When you follow an artist on YouTube Music who doesn't have his own YouTube channel, YT automatically creates a topic channel for the artist. Here is an example:
https://www.youtube.com/channel/UCZLrcCdfVC6gCQvADhSSWuQ
I've noticed that the script fails with the following error when it encounters one of these channels: TypeError: Cannot read properties of null (reading '1')
I assume that topic channels don't have their own RSS feed. Would it be possible to skip them in the script?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.