From a0dad259a6c767487be08afc666dbf2c923a6e25 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Sun, 22 Nov 2020 22:37:42 -0600 Subject: Add feed link from youtube video --- cs.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'cs.js') diff --git a/cs.js b/cs.js index c3dbedd..b6b35c6 100644 --- a/cs.js +++ b/cs.js @@ -74,6 +74,12 @@ function get_twitter(url) { } async function get_youtube(url) { + // use link to channel if given a video url + let patternVideo = /youtube.com\/watch\?v=\w+/ + if (url.match(patternVideo)) { + url = document.querySelector("#channel-name a")["href"] + } + let patternUser = /youtube.com\/user\/(\w+).*/ let matchUser = url.match(patternUser) @@ -82,6 +88,8 @@ async function get_youtube(url) { let patternPlaylist = /youtube.com\/playlist\?list=(\w+)/ let matchPlaylist = url.match(patternPlaylist) + + if (matchUser) { let user = matchUser[1]; let feed_url = `${base_url}/?action=display&bridge=Youtube&context=By+username&u=${user}&duration_min=&duration_max=&format=` @@ -96,7 +104,7 @@ async function get_youtube(url) { let feed_url = `${base_url}/?action=display&bridge=Youtube&context=By+playlist+Id&p=${playlistId}&duration_min=&duration_max=&format=` let rb_feeds = get_all_types(feed_url) return rb_feeds.concat([{ type: `native: Rss`, url: native_url }]) - } + } return [] } -- cgit v1.2.3