89 lines
2 KiB
Go
89 lines
2 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
|
|
}
|