Last active
January 23, 2024 07:13
-
-
Save aaronclimbs/091232147cca7c43349d3800695be21b to your computer and use it in GitHub Desktop.
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
// 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. | |
// After running it, just paste it into a file and save it with a '.ompl' extension. | |
function youTubeToOPML() { | |
output = '<?xml version="1.0" encoding="UTF-8"?>\n<opml version="1.0">\n<head>\n<title>Feed Subscriptions</title>\n</head>\n<body>\n<outline title="Youtube Subscriptions" text="Youtube Subscriptions">'; | |
arrOfATags = [...document.querySelectorAll('a#main-link')]; | |
rss = arrOfATags.forEach(item => { | |
const {href, innerText} = item; | |
const data = { | |
channelID: "", | |
title: "", | |
userID: "", | |
} | |
if (href.includes('channel')) { | |
data.channelID = href.replace("https://www.youtube.com/channel/","https://www.youtube.com/feeds/videos.xml?channel_id="); | |
} else if (href.includes('user')) { | |
data.userID = href.replace('https://www.youtube.com/user/',"https://www.youtube.com/feeds/videos.xml?user="); | |
} | |
data.title = innerText.split('\n')[0]; | |
OPMLLine = `<outline type="rss" xmlUrl="${data.channelID + data.userID}"/>\n`; | |
output += OPMLLine; | |
}) | |
output += '</outline>\n</body>\n</opml>' | |
return output; | |
} | |
copy(youTubeToOPML()); |
Author
aaronclimbs
commented
Nov 16, 2020
via email
No problem! I imagine there might be a field that can be added to the body
of the OPML file in order to automate that foldering, but I'd have to look
into it further. If you create the folder structure you want and then
export via OPML from your RSS reader, you may be able to figure out what
changes need to be made to the incoming OPML file. Does that make sense?
Aaron
…On Mon, Nov 16, 2020 at 5:24 PM asorel1942 ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Seems to work now--the only nitpick I'd have left is that the feeds aren't
sorted into a folder the way they were before. Thanks again for putting
this together!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/091232147cca7c43349d3800695be21b#gistcomment-3529719>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACN3B2QSFAH4KB5FEGI2RS3SQGRATANCNFSM4TXTZGDQ>
.
Yep, that's actually what I've been doing since my last comment. The HTML tag needed seems to be. <outline title="Youtube Subscriptions" text="Youtube Subscriptions"> </outline>,
wrapped around the feeds.
After some testing manually adding those tags to the output of your script does seem to work fine, so if you want to add that to your script feel free.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment