aboutsummaryrefslogtreecommitdiff
path: root/cs.js
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2020-11-22 22:37:42 -0600
committerMark Powers <markppowers0@gmail.com>2020-11-22 22:37:42 -0600
commita0dad259a6c767487be08afc666dbf2c923a6e25 (patch)
tree90307b6bcd3e54a3035c1ba47bbd77bd1c6236a9 /cs.js
parent2be03e1935e0019fa5c03893dc12acf6ee546222 (diff)
Add feed link from youtube video
Diffstat (limited to 'cs.js')
-rw-r--r--cs.js10
1 files changed, 9 insertions, 1 deletions
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 []
}