refactoring continued - compiles now
This commit is contained in:
@@ -395,7 +395,7 @@ func toTrack(ch *jellyfin.Song) *mediaprovider.Track {
|
||||
ID: ch.Id,
|
||||
CoverArtID: coverArtID,
|
||||
ParentID: ch.AlbumID,
|
||||
Name: ch.Name,
|
||||
Title: ch.Name,
|
||||
Duration: int(ch.RunTimeTicks / runTimeTicksPerSecond),
|
||||
TrackNumber: ch.IndexNumber,
|
||||
DiscNumber: ch.DiscNumber,
|
||||
|
||||
@@ -86,7 +86,7 @@ type Track struct {
|
||||
ID string
|
||||
CoverArtID string
|
||||
ParentID string
|
||||
Name string
|
||||
Title string
|
||||
Duration int
|
||||
TrackNumber int
|
||||
DiscNumber int
|
||||
@@ -146,21 +146,56 @@ type RadioStation struct {
|
||||
StreamURL string
|
||||
}
|
||||
|
||||
type MediaItemType int
|
||||
|
||||
const (
|
||||
MediaItemTypeTrack MediaItemType = iota
|
||||
MediaItemTypeRadioStation
|
||||
)
|
||||
|
||||
type MediaItemMetadata struct {
|
||||
Type MediaItemType
|
||||
ID string
|
||||
Name string
|
||||
Artists []string
|
||||
ArtistIDs []string
|
||||
Album string
|
||||
AlbumID string
|
||||
CoverArtID string
|
||||
Duration int
|
||||
}
|
||||
|
||||
type MediaItem interface {
|
||||
MediaItemName() string
|
||||
MediaItemID() string
|
||||
Metadata() MediaItemMetadata
|
||||
Copy() MediaItem
|
||||
}
|
||||
|
||||
func (t Track) MediaItemName() string { return t.Name }
|
||||
func (t Track) MediaItemID() string { return t.ID }
|
||||
func (t Track) Metadata() MediaItemMetadata {
|
||||
return MediaItemMetadata{
|
||||
Type: MediaItemTypeTrack,
|
||||
ID: t.ID,
|
||||
Name: t.Title,
|
||||
Artists: t.ArtistNames,
|
||||
ArtistIDs: t.ArtistIDs,
|
||||
Album: t.Album,
|
||||
AlbumID: t.AlbumID,
|
||||
CoverArtID: t.CoverArtID,
|
||||
Duration: t.Duration,
|
||||
}
|
||||
}
|
||||
func (t *Track) Copy() MediaItem {
|
||||
new := *t
|
||||
return &new
|
||||
}
|
||||
|
||||
func (r RadioStation) MediaItemName() string { return r.Name }
|
||||
func (r RadioStation) MediaItemID() string { return r.ID }
|
||||
func (r RadioStation) Metadata() MediaItemMetadata {
|
||||
return MediaItemMetadata{
|
||||
Type: MediaItemTypeRadioStation,
|
||||
ID: r.ID,
|
||||
Name: r.Name,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RadioStation) Copy() MediaItem {
|
||||
return r // no need to copy since RadioStations are immutable
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ func (s *subsonicMediaProvider) GetLyrics(track *mediaprovider.Track) (*mediapro
|
||||
return mpLyrics, nil
|
||||
}
|
||||
// fallback to legacy getLyrics endpoint
|
||||
lyrics, err := s.client.GetLyrics(track.Name, track.ArtistNames[0])
|
||||
lyrics, err := s.client.GetLyrics(track.Title, track.ArtistNames[0])
|
||||
if err != nil || lyrics == nil || lyrics.Text == "" {
|
||||
return nil, err
|
||||
}
|
||||
@@ -433,7 +433,7 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
||||
ID: ch.ID,
|
||||
CoverArtID: ch.CoverArt,
|
||||
ParentID: ch.Parent,
|
||||
Name: ch.Title,
|
||||
Title: ch.Title,
|
||||
Duration: ch.Duration,
|
||||
TrackNumber: ch.Track,
|
||||
DiscNumber: ch.DiscNumber,
|
||||
|
||||
Reference in New Issue
Block a user