subsyt/internal/format/rss.go
Viktor Varland 6ff2d53c2d
Some checks are pending
build / build (push) Waiting to run
feat: use rss to fetch list of videos
This uses RSS to fetch a list of videos to avoid the vid being invisible
due to "restrictions", then downloads the videos one-by-one instead of
scraping and parsing the channel page using yt-dlp.

We lose metadata for the entire channel (show-level) so introducing a
hack to download just the metadata of a channel.
2025-09-08 22:30:57 +02:00

90 lines
1.9 KiB
Go

package format
import (
"encoding/xml"
)
type Feed struct {
XMLName xml.Name `xml:"feed"`
Id string `xml:"id"`
ChannelId string `xml:"yt:channelId"`
Title string `xml:"title"`
Published string `xml:"published"`
Links []Link `xml:"link"`
Author Author `xml:"author"`
Entries []Entry `xml:"entry"`
}
type Link struct {
Rel string `xml:"rel,attr"`
Href string `xml:"href,attr"`
}
type Author struct {
XMLName xml.Name `xml:"author"`
Name string `xml:"name"`
Uri string `xml:"uri"`
}
type MediaContent struct {
URL string `xml:"url,attr"`
Type string `xml:"type,attr"`
Width string `xml:"width,attr"`
Height string `xml:"height,attr"`
}
type MediaThumbnail struct {
URL string `xml:"url,attr"`
Width string `xml:"width,attr"`
Height string `xml:"height,attr"`
}
type MediaStarRating struct {
Count string `xml:"count,attr"`
Average string `xml:"average,attr"`
Min string `xml:"min,attr"`
Max string `xml:"max,attr"`
}
type MediaStatistics struct {
Views string `xml:"views,attr"`
}
type MediaCommunity struct {
StarRating MediaStarRating `xml:"starRating"`
Statistics MediaStatistics `xml:"statistics"`
}
type MediaGroup struct {
Title string `xml:"title"`
Content MediaContent `xml:"content"`
Thumbnail MediaThumbnail `xml:"thumbnail"`
Description string `xml:"description"`
Community MediaCommunity `xml:"community"`
}
type Entry struct {
XMLName xml.Name `xml:"entry"`
Title string `xml:"title"`
Id string `xml:"id"`
VideoId string `xml:"videoId"`
ChannelId string `xml:"channelId"`
Link Link `xml:"link"`
Author Author `xml:"author"`
Published string `xml:"published"`
Updated string `xml:"updated"`
MediaGroup MediaGroup `xml:"group"`
}
func RssLoad(data []byte) (Feed, error) {
feed := Feed{}
err := xml.Unmarshal(data, &feed)
if err != nil {
return Feed{}, err
}
return feed, nil
}