Skip to content

Instantly share code, notes, and snippets.

@arkov
Last active March 1, 2022 23:07
Show Gist options
  • Save arkov/e8c0d463c9817d4b0b90462992589198 to your computer and use it in GitHub Desktop.
Save arkov/e8c0d463c9817d4b0b90462992589198 to your computer and use it in GitHub Desktop.
Youtube subscriptions to RSS & OPML
// I modified the code I found on Duc's site here:
// https://hoanganhduc.github.io/blog/2021/04/16/youtube-subscriptions-to-rss-feeds/
// This might and will break at the slightest touchup made by the devs @ Youtube
// instructions:
// 1. navigate to https://www.youtube.com/feed/channels
// 2. scroll all the way down
// 3. paste all the code into the console
// 4. copy the ouput and paste it at the following website
// in order to generate OPML https://opml-gen.ovh/
x = $$("#main-link.channel-link").map( el => {
ytb = "https://www.youtube.com/feeds/videos.xml?";
usr = "/user/";
chn = "/channel/";
i = el.pathname.indexOf(usr);
j = el.pathname.indexOf(chn);
// unexpected input
if (i < 0 && j < 0) return "broken: " + el.pathname;
// user
if (j < 0) return ytb + "user=" + el.pathname.substring(usr.length);
// channel
return ytb + "channel_id=" + el.pathname.substring(chn.length);
});
console.log(x.join("\n"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment