Go to youtube.com/feed/channels
The page should display a list of your YouTube subscriptions. Run the following JavaScript in the console. Your YouTube subscriptions will be displayed on screen for you to copy-paste.
This CSV response can be saved and imported into other apps which can load Google Takeout subscription files, such as NewPipe.
function getLast() {
return ytInitialData.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.slice(-1)[0]
}
function canContinue() { return getLast().continuationItemRenderer != null }
(async () => {
while (canContinue()) {
let current = getLast().continuationItemRenderer.continuationEndpoint.continuationCommand.token;
scrollTo(0, document.getElementById('primary').scrollHeight);
while (canContinue() && current == getLast().continuationItemRenderer.continuationEndpoint.continuationCommand.token) {
await new Promise(r => setTimeout(r, 100));
}
}
scrollTo(0, 0);
let floatDiv = document.createElement('div');
let preText = document.createElement('pre');
floatDiv.setAttribute('style', `position: fixed;
background: #0f0f0f;
z-index: 100000;
inset: 2rem;
overflow: auto;
font-size: 2rem;
white-space: pre;
color: white;
padding: 1rem;`);
let csvText = "Channel Id,Channel Url,Channel Title\n" + ytInitialData.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.map(e => {
if (!e.itemSectionRenderer) return;
return e.itemSectionRenderer.contents[0].shelfRenderer.content.expandedShelfContentsRenderer.items
}).flat().map(e => {
if (e && e.channelRenderer) return `${e.channelRenderer.channelId},http://www.youtube.com/channel/${e.channelRenderer.channelId},${e.channelRenderer.title.simpleText}`;
return '';
}).join('\n');
preText.innerText = csvText;
let downloadLink = document.createElement('a');
downloadLink.innerText = 'Download CSV';
downloadLink.setAttribute('target', '_blank');
downloadLink.setAttribute('style', `color: #bf3838;
font-weight: bold;
margin-bottom: 1rem;
display: block;
padding: 1rem;
border-radius: 0.5rem;
border: 2px solid #bf3838;
width: fit-content;
text-decoration: none;`);
var t = new Blob([csvText], { type: "text/plain" });
downloadLink.href = window.URL.createObjectURL(t)
floatDiv.appendChild(downloadLink);
floatDiv.appendChild(preText);
document.body.appendChild(floatDiv);
})()
For convenience, you can make a bookmarklet. Just make a new bookmark and set the URL to the following:
javascript:(()=>{function getLast(){return ytInitialData.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.slice(-1)[0]}function canContinue(){return getLast().continuationItemRenderer!=null}(async()=>{while(canContinue()){let current=getLast().continuationItemRenderer.continuationEndpoint.continuationCommand.token;scrollTo(0,document.getElementById('primary').scrollHeight);while(canContinue()&¤t==getLast().continuationItemRenderer.continuationEndpoint.continuationCommand.token){await new Promise(r=>setTimeout(r,100))}}scrollTo(0,0);let floatDiv=document.createElement('div');let preText=document.createElement('pre');floatDiv.setAttribute('style',`position: fixed; background: #0f0f0f;%20z-index:%20100000;%20inset:%202rem;%20overflow:%20auto;%20font-size:%202rem;%20white-space:%20pre;%20color:%20white;%20padding:%201rem;`);let%20csvText="Channel%20Id,Channel%20Url,Channel%20Title\n"+ytInitialData.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.map(e=>{if(!e.itemSectionRenderer){return}return%20e.itemSectionRenderer.contents[0].shelfRenderer.content.expandedShelfContentsRenderer.items}).flat().map(e=>{if(e&&e.channelRenderer){return%20`${e.channelRenderer.channelId%20},http://www.youtube.com/channel/${e.channelRenderer.channelId%20},${e.channelRenderer.title.simpleText%20}`}return%20''}).join('\n');preText.innerText=csvText;let%20downloadLink=document.createElement('a');downloadLink.innerText='Download%20CSV';downloadLink.setAttribute('target','_blank');downloadLink.setAttribute('style',`color:%20#bf3838;%20font-weight:%20bold;%20margin-bottom:%201rem;%20display:%20block;%20padding:%201rem;%20border-radius:%200.5rem;%20border:%202px%20solid%20#bf3838;%20width:%20fit-content;%20text-decoration:%20none;`);var%20t=new%20Blob([csvText],{type:"text/plain"});downloadLink.href=window.URL.createObjectURL(t);floatDiv.appendChild(downloadLink);floatDiv.appendChild(preText);document.body.appendChild(floatDiv)})();})();
Then, you can click on the bookmark while at youtube.com/feed/channels to see your subscriptions in CSV format.
Thank you for your code, and I'd love to use it when export my youtube channels.
But there's some Channel Title encode issue and I've fixed using Claude.
https://gist.github.com/hoony0203/2007684ccf30c2075c25d457014fad9f
If you mind upload this changed gist on my Gist, please feedback to me, I'll delete it.