offer common youtube playlists as feed

This commit is contained in:
Andre Heider 2025-01-24 09:33:49 +01:00 committed by nkanaev
parent d785fe4c5a
commit 7ef97ee6db

View File

@ -1,6 +1,7 @@
package scraper package scraper
import ( import (
"net/url"
"strings" "strings"
"github.com/nkanaev/yarr/src/content/htmlutil" "github.com/nkanaev/yarr/src/content/htmlutil"
@ -35,6 +36,18 @@ func FindFeeds(body string, base string) map[string]string {
link := htmlutil.AbsoluteUrl(href, base) link := htmlutil.AbsoluteUrl(href, base)
if link != "" { if link != "" {
candidates[link] = name candidates[link] = name
l, err := url.Parse(link)
if err == nil && l.Host == "www.youtube.com" && l.Path == "/feeds/videos.xml" {
// https://wiki.archiveteam.org/index.php/YouTube/Technical_details#Playlists
channelID, found := strings.CutPrefix(l.Query().Get("channel_id"), "UC")
if found {
const url string = "https://www.youtube.com/feeds/videos.xml?playlist_id="
candidates[url + "UULF" + channelID] = name + " - Videos"
candidates[url + "UULV" + channelID] = name + " - Live Streams"
candidates[url + "UUSH" + channelID] = name + " - Short videos"
}
}
} }
} }