Skip to content

Instantly share code, notes, and snippets.

@aaronclimbs
Last active January 20, 2021 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronclimbs/60f53b5c738d3b8a7a71a8874083bf3d to your computer and use it in GitHub Desktop.
Save aaronclimbs/60f53b5c738d3b8a7a71a8874083bf3d to your computer and use it in GitHub Desktop.
hacky way to get properly formatted and tagged (for my newsboat workflow) RSS feeds from youtube
// Apologies for the hacky nature of the below - it was just bothering me so I threw this together for myself.
// I used this in firefox, just go to the manage subscriptions page in youtube and run it in the developer console. It should work in chrome as well, I forget if there is a different browser function to copy to the clipboard.
function getNewsboatRSS() {
arrOfATags = document.querySelectorAll('a#main-link');
rss = arrOfATags.map(item => {
const output = {
channelID: "",
title: "",
userID: "",
newsBoatStr: ""
}
const {href, innerText} = item;
if (href.includes('channel')) {
output.channelID = href.replace("https://www.youtube.com/channel/","https://www.youtube.com/feeds/videos.xml?channel_id=");
} else if (href.includes('user')) {
output.userID = href.replace('https://www.youtube.com/user/',"https://www.youtube.com/feeds/videos.xml?user=");
}
output.title = innerText.split('\n')[0];
output.newsBoatStr = `${output.channelID + output.userID} "!YouTube" "~${output.title}"`;
return output.newsBoatStr;
})
return rss;
}
copy(getNewsboatRSS(a).join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment