init
This commit is contained in:
134
subsonic/podcasts.go
Normal file
134
subsonic/podcasts.go
Normal file
@@ -0,0 +1,134 @@
|
||||
package subsonic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Episode struct {
|
||||
XMLName xml.Name `xml:"episode" json:"-"`
|
||||
ID int `xml:"id,attr" json:"id"`
|
||||
StreamID int `xml:"streamId,attr" json:"streamId"`
|
||||
ChannelID int `xml:"channelId,attr" json:"channelId"`
|
||||
Title string `xml:"title,attr" json:"title"`
|
||||
Description string `xml:"description,attr" json:"description"`
|
||||
PublishDate time.Time `xml:"publishDate,attr" json:"publishDate"`
|
||||
Status string `xml:"status,attr" json:"status"`
|
||||
Parent int `xml:"parent,attr" json:"parent"`
|
||||
IsDir bool `xml:"isDir,attr" json:"isDir"`
|
||||
Year int `xml:"year,attr" json:"year"`
|
||||
Genre string `xml:"genre,attr" json:"genre"`
|
||||
CoverArt int `xml:"coverArt,attr" json:"coverArt"`
|
||||
Size int `xml:"size,attr" json:"size"`
|
||||
ContentType string `xml:"contentType,attr" json:"contentType"`
|
||||
Suffix string `xml:"suffix,attr" json:"suffix"`
|
||||
Duration int `xml:"duration,attr" json:"duration"`
|
||||
Bitrate int `xml:"bitrate,attr" json:"bitrate"`
|
||||
Path string `xml:"path,attr" json:"path"`
|
||||
}
|
||||
|
||||
type Podcast struct {
|
||||
XMLName xml.Name `xml:"channel" json:"-"`
|
||||
ID int `xml:"id,attr" json:"id"`
|
||||
URL string `xml:"url,attr" json:"url"`
|
||||
Title string `xml:"title,attr" json:"title"`
|
||||
Description string `xml:"description,attr" json:"description"`
|
||||
CoverArt string `xml:"coverArt,attr" json:"coverArt"`
|
||||
OriginalImageURL string `xml:"originalImageUrl,attr" json:"originalImageUrl"`
|
||||
Status string `xml:"status,attr" json:"status"`
|
||||
Episodes []Episode `xml:"episode" json:"episodes"`
|
||||
ErrorMessage string `xml:"errorMessage,attr,omitempty" json:"errorMessage,omitempty"`
|
||||
}
|
||||
|
||||
func (p Podcast) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
||||
if p.ErrorMessage != "" {
|
||||
return e.EncodeElement(struct {
|
||||
ID int `xml:"id,attr,omitempty"`
|
||||
URL string `xml:"url,attr,omitempty"`
|
||||
Status string `xml:"status,attr,omitempty"`
|
||||
ErrorMessage string `xml:"errorMessage,attr,omitempty"`
|
||||
}{
|
||||
ID: p.ID,
|
||||
URL: p.URL,
|
||||
Status: p.Status,
|
||||
ErrorMessage: p.ErrorMessage,
|
||||
}, start)
|
||||
}
|
||||
|
||||
type Alias Podcast
|
||||
return e.EncodeElement(Alias(p), start)
|
||||
}
|
||||
|
||||
func (p Podcast) MarshalJSON() ([]byte, error) {
|
||||
if p.ErrorMessage != "" {
|
||||
return json.Marshal(struct {
|
||||
ID int `xml:"id,attr,omitempty" json:"id,omitempty"`
|
||||
URL string `xml:"url,attr,omitempty" json:"url,omitempty"`
|
||||
Status string `xml:"status,attr,omitempty" json:"status,omitempty"`
|
||||
ErrorMessage string `xml:"errorMessage,attr,omitempty" json:"errorMessage,omitempty"`
|
||||
}{
|
||||
ID: p.ID,
|
||||
URL: p.URL,
|
||||
ErrorMessage: p.ErrorMessage,
|
||||
})
|
||||
}
|
||||
|
||||
type Alias Podcast
|
||||
return json.Marshal(Alias(p))
|
||||
}
|
||||
|
||||
type PodcastsResponse struct {
|
||||
Response
|
||||
Podcasts []Podcast `xml:"podcasts>channel" json:"podcasts"`
|
||||
}
|
||||
|
||||
type NewestEpisode struct {
|
||||
ID int `xml:"id,attr" json:"id"`
|
||||
Parent int `xml:"parent,attr" json:"parent"`
|
||||
IsDir bool `xml:"isDir,attr" json:"isDir"`
|
||||
Title string `xml:"title,attr" json:"title"`
|
||||
Album string `xml:"album,attr" json:"album"`
|
||||
Artist string `xml:"artist,attr" json:"artist"`
|
||||
Year int `xml:"year,attr" json:"year"`
|
||||
CoverArt int `xml:"coverArt,attr" json:"coverArt"`
|
||||
Size int `xml:"size,attr" json:"size"`
|
||||
ContentType string `xml:"contentType,attr" json:"contentType"`
|
||||
Suffix string `xml:"suffix,attr" json:"suffix"`
|
||||
Duration int `xml:"duration,attr" json:"duration"`
|
||||
Bitrate int `xml:"bitrate,attr" json:"bitrate"`
|
||||
IsVideo bool `xml:"isVideo,attr" json:"isVideo"`
|
||||
Created time.Time `xml:"created,attr" json:"created"`
|
||||
ArtistID int `xml:"artistId,attr" json:"artistId"`
|
||||
Type string `xml:"type,attr" json:"type"`
|
||||
StreamID int `xml:"streamId,attr" json:"streamId"`
|
||||
ChannelID int `xml:"channelId,attr" json:"channelId"`
|
||||
Description string `xml:"description,attr" json:"description"`
|
||||
Status string `xml:"status,attr" json:"status"`
|
||||
PublishDate time.Time `xml:"publishDate,attr" json:"publishDate"`
|
||||
}
|
||||
|
||||
type NewestPodcastsResponse struct {
|
||||
Response
|
||||
NewestPodcasts []NewestEpisode `xml:"newestPodcasts>episode" json:"newestPodcasts"`
|
||||
}
|
||||
|
||||
type RefreshPodcastsResponse struct {
|
||||
Response
|
||||
}
|
||||
|
||||
type CreatePodcastResponse struct {
|
||||
Response
|
||||
}
|
||||
|
||||
type DeletePodcastResponse struct {
|
||||
Response
|
||||
}
|
||||
|
||||
type DeleteEpisodeResponse struct {
|
||||
Response
|
||||
}
|
||||
|
||||
type DownloadEpisodeResponse struct {
|
||||
Response
|
||||
}
|
||||
Reference in New Issue
Block a user