diff --git a/backend/mediaprovider/model.go b/backend/mediaprovider/model.go index 2c1aa81..ac4201a 100644 --- a/backend/mediaprovider/model.go +++ b/backend/mediaprovider/model.go @@ -101,6 +101,7 @@ type Track struct { PlayCount int FilePath string BitRate int + Comment string } type Playlist struct { diff --git a/backend/mediaprovider/subsonic/subsonicmediaprovider.go b/backend/mediaprovider/subsonic/subsonicmediaprovider.go index c43a058..9809a28 100644 --- a/backend/mediaprovider/subsonic/subsonicmediaprovider.go +++ b/backend/mediaprovider/subsonic/subsonicmediaprovider.go @@ -360,6 +360,7 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track { FilePath: ch.Path, Size: ch.Size, BitRate: ch.BitRate, + Comment: ch.Comment, } } diff --git a/go.mod b/go.mod index 0f7f008..15a09b8 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1 github.com/dweymouth/go-jellyfin v0.0.0-20231116161116-e800860bdacc github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee - github.com/dweymouth/go-subsonic v0.0.0-20231216190641-c537a36d520c + github.com/dweymouth/go-subsonic v0.0.0-20231216234924-3f62122dc53a github.com/fsnotify/fsnotify v1.6.0 github.com/godbus/dbus/v5 v5.1.0 github.com/google/uuid v1.3.0 diff --git a/go.sum b/go.sum index 35e169d..97ad075 100644 --- a/go.sum +++ b/go.sum @@ -75,8 +75,8 @@ github.com/dweymouth/go-jellyfin v0.0.0-20231116161116-e800860bdacc h1:wJy4U12Ys github.com/dweymouth/go-jellyfin v0.0.0-20231116161116-e800860bdacc/go.mod h1:BMwS4vdjEYf1gmjPGSKCzWP/I6YlI6fkefJ9nsjBjaU= github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee h1:ZGyJ6wp7CAfT31BugypcF/TPKEy2RrGR9JFq1JOjOpY= github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee/go.mod h1:Ov0ieN90M7i+0k3OxhA/g1dozGs+UcPHDsMKqPgRDk0= -github.com/dweymouth/go-subsonic v0.0.0-20231216190641-c537a36d520c h1:48xbtXN53Rrru1Y3Ywd/FIVohH4NoRMzvxEY4aY1s0M= -github.com/dweymouth/go-subsonic v0.0.0-20231216190641-c537a36d520c/go.mod h1:OWtcumdQsan8uM6wmx6PqKhldaCthH10CQ+vb+94kzo= +github.com/dweymouth/go-subsonic v0.0.0-20231216234924-3f62122dc53a h1:UJcwloSIzRpUOIwRE207JF2SHoTmOg7vJWzfQWpztSk= +github.com/dweymouth/go-subsonic v0.0.0-20231216234924-3f62122dc53a/go.mod h1:OWtcumdQsan8uM6wmx6PqKhldaCthH10CQ+vb+94kzo= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= diff --git a/ui/widgets/tracklist.go b/ui/widgets/tracklist.go index 8f7d9d8..e5a2a34 100644 --- a/ui/widgets/tracklist.go +++ b/ui/widgets/tracklist.go @@ -32,14 +32,17 @@ const ( ColumnFavorite = "Favorite" ColumnRating = "Rating" ColumnPlays = "Plays" + ColumnComment = "Comment" ColumnBitrate = "Bitrate" ColumnSize = "Size" ColumnPath = "Path" + + numColumns = 13 ) var columns = []string{ - ColumnNum, ColumnTitle, ColumnArtist, ColumnAlbum, ColumnTime, ColumnYear, - ColumnFavorite, ColumnRating, ColumnPlays, ColumnBitrate, ColumnSize, ColumnPath, + ColumnNum, ColumnTitle, ColumnArtist, ColumnAlbum, ColumnTime, ColumnYear, ColumnFavorite, + ColumnRating, ColumnPlays, ColumnComment, ColumnBitrate, ColumnSize, ColumnPath, } type TracklistSort struct { @@ -114,15 +117,15 @@ type trackModel struct { } func NewTracklist(tracks []*mediaprovider.Track) *Tracklist { - t := &Tracklist{visibleColumns: make([]bool, 12)} + t := &Tracklist{visibleColumns: make([]bool, numColumns)} t.ExtendBaseWidget(t) if len(tracks) > 0 { t._setTracks(tracks) } - // #, Title, Artist, Album, Time, Year, Favorite, Rating, Plays, Bitrate, Size, Path - t.colLayout = layouts.NewColumnsLayout([]float32{40, -1, -1, -1, 60, 60, 55, 100, 65, 75, 75, -1}) + // #, Title, Artist, Album, Time, Year, Favorite, Rating, Plays, Comment, Bitrate, Size, Path + t.colLayout = layouts.NewColumnsLayout([]float32{40, -1, -1, -1, 60, 60, 55, 100, 65, -1, 75, 75, -1}) t.buildHeader() t.hdr.OnColumnSortChanged = t.onSorted t.hdr.OnColumnVisibilityChanged = t.setColumnVisible @@ -190,6 +193,7 @@ func (t *Tracklist) buildHeader() { {Text: " Fav.", Alignment: fyne.TextAlignCenter, CanToggleVisible: true}, {Text: "Rating", Alignment: fyne.TextAlignLeading, CanToggleVisible: true}, {Text: "Plays", Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}, + {Text: "Comment", Alignment: fyne.TextAlignLeading, CanToggleVisible: true}, {Text: "Bitrate", Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}, {Text: "Size", Alignment: fyne.TextAlignTrailing, CanToggleVisible: true}, {Text: "File Path", Alignment: fyne.TextAlignLeading, CanToggleVisible: true}}, @@ -440,6 +444,8 @@ func (t *Tracklist) doSortTracks() { t.intSort(func(tr *trackModel) int64 { return tr.track.Size }) case ColumnPlays: t.intSort(func(tr *trackModel) int64 { return int64(tr.track.PlayCount) }) + case ColumnComment: + t.stringSort(func(tr *trackModel) string { return tr.track.Comment }) case ColumnBitrate: t.intSort(func(tr *trackModel) int64 { return int64(tr.track.BitRate) }) case ColumnFavorite: @@ -713,6 +719,7 @@ type TrackRow struct { rating *StarRating bitrate *widget.Label plays *widget.Label + comment *widget.Label size *widget.Label path *widget.Label @@ -741,12 +748,13 @@ func NewTrackRow(tracklist *Tracklist, playingIcon fyne.CanvasObject) *TrackRow t.rating.StarSize = 16 t.rating.OnRatingChanged = t.setTrackRating t.plays = newTrailingAlignLabel() + t.comment = newTruncatingLabel() t.bitrate = newTrailingAlignLabel() t.size = newTrailingAlignLabel() t.path = newTruncatingLabel() t.Content = container.New(tracklist.colLayout, - t.num, t.name, t.artist, t.album, t.dur, t.year, t.favorite, t.rating, t.plays, t.bitrate, t.size, t.path) + t.num, t.name, t.artist, t.album, t.dur, t.year, t.favorite, t.rating, t.plays, t.comment, t.bitrate, t.size, t.path) return t } @@ -788,6 +796,7 @@ func (t *TrackRow) Update(tm *trackModel, rowNum int) { t.dur.Text = util.SecondsToTimeString(float64(tr.Duration)) t.year.Text = strconv.Itoa(tr.Year) t.plays.Text = strconv.Itoa(int(tr.PlayCount)) + t.comment.Text = tr.Comment t.bitrate.Text = strconv.Itoa(tr.BitRate) t.size.Text = util.BytesToSizeString(tr.Size) t.path.Text = tr.FilePath @@ -851,6 +860,7 @@ func (t *TrackRow) Update(tm *trackModel, rowNum int) { t.rating.IsDisabled = t.tracklist.Options.DisableRating t.rating.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnRating)] t.plays.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnPlays)] + t.comment.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnComment)] t.bitrate.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnBitrate)] t.size.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnSize)] t.path.Hidden = !t.tracklist.visibleColumns[ColNumber(ColumnPath)]