Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat 52 search by genre #80

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,16 @@ In any of the columns:
- `Enter` / `a`: Adds the selected item recursively to the queue.
- Left/right arrow keys (`←`, `→`) navigate between the columns
- Up/down arrow keys (`↓`, `↑`) navigate the selected column list
- `g`: toggle genre search

In the search field:

- `Enter`: Perform the query.
- `Escape`: Escapes into the columns, where the global key bindings work.

Note that the Search page is *not* a browser like the Browser page: it displays the search results returned by the server. Selecting a different artist will not change the album or song search results. OpenSubsonic servers implement the search function differently; in gonic, if you search for "black", you will get artists with "black" in their names in the artists column; albums with "black" in their titles in the albums column; and songs with "black" in their titles in the songs column. Navidrome appears to include all results with "black" anywhere in their IDv3 metadata. Since the API search results filteres these matches into sections -- artists, albums, and songs -- this means that, with Navidrome, you may see albums that don't have "black" in their names; maybe "black" is in their artist title.
Note that the Search page is *not* a browser like the Browser page: it displays the search results returned by the server. Selecting a different artist will not change the album or song search results.

In Genre Search mode, the genres known by the server are displayed in the middle column. Pressing `Enter` on one of these will load all of the songs with that genre in the third column. Searching with the search field will fill the third column with songs whose genres match the search. Searching for a genre by typing it in should return the same songs as selecting it in the middle column. Note that genre searches may (depending on your Subsonic server's search implementation) be case sensitive.

## Advanced Configuration and Features

Expand Down
4 changes: 3 additions & 1 deletion gui_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (ui *Ui) addSongToQueue(entity *subsonic.SubsonicEntity) {
TrackNumber: entity.Track,
CoverArtId: entity.CoverArtId,
DiscNumber: entity.DiscNumber,
Year: entity.Year,
}
ui.player.AddToQueue(queueItem)
}
Expand All @@ -206,6 +207,7 @@ func makeSongHandler(entity *subsonic.SubsonicEntity, ui *Ui, fallbackArtist str
track := entity.Track
coverArtId := entity.CoverArtId
disc := entity.DiscNumber
year := entity.Year

response, err := ui.connection.GetAlbum(entity.Parent)
album := ""
Expand All @@ -223,7 +225,7 @@ func makeSongHandler(entity *subsonic.SubsonicEntity, ui *Ui, fallbackArtist str
}

return func() {
if err := ui.player.PlayUri(id, uri, title, artist, album, duration, track, disc, coverArtId); err != nil {
if err := ui.player.PlayUri(id, uri, title, artist, album, duration, track, disc, coverArtId, year); err != nil {
ui.logger.PrintError("SongHandler Play", err)
return
}
Expand Down
7 changes: 6 additions & 1 deletion help_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ a add playlist or song to queue
`

const helpSearchPage = `
artist, album, or song column
artist, album/genre, or song column
Down/Up navigate within the column
Left previous column
Right next column
Enter/a recursively add item to quue
g toggle genre search
/ start search
In album tab
Enter recursively add item to quue
In genre tab
Enter shows songs with genre
search field
Enter search for text
Esc cancel search
Expand Down
4 changes: 2 additions & 2 deletions mpvplayer/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func (p *Player) PlayNextTrack() error {
return nil
}

func (p *Player) PlayUri(id, uri, title, artist, album string, duration, track, disc int, coverArtId string) error {
p.queue = []QueueItem{{id, uri, title, artist, duration, album, track, coverArtId, disc}}
func (p *Player) PlayUri(id, uri, title, artist, album string, duration, track, disc int, coverArtId string, year int) error {
p.queue = []QueueItem{{id, uri, title, artist, duration, album, track, coverArtId, disc, year}}
p.replaceInProgress = true
if ip, e := p.IsPaused(); ip && e == nil {
if err := p.Pause(); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions mpvplayer/queue_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type QueueItem struct {
TrackNumber int
CoverArtId string
DiscNumber int
Year int
}

var _ remote.TrackInterface = (*QueueItem)(nil)
Expand Down Expand Up @@ -60,3 +61,7 @@ func (q QueueItem) GetTrackNumber() int {
func (q QueueItem) GetDiscNumber() int {
return q.DiscNumber
}

func (q QueueItem) GetYear() int {
return q.Year
}
5 changes: 0 additions & 5 deletions page_playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,6 @@ func (p *PlaylistPage) UpdatePlaylists() {
stop <- true
return
}
if response == nil {
p.logger.Printf("no error from GetPlaylists, but also no response!")
stop <- true
return
}
p.updatingMutex.Lock()
defer p.updatingMutex.Unlock()
p.ui.playlists = response.Playlists.Playlists
Expand Down
1 change: 1 addition & 0 deletions page_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func (q *QueuePage) updateQueue() {
q.queueList.ScrollToBeginning()
}

q.queueList.Box.SetTitle(fmt.Sprintf(" queue (%d) ", q.queueList.GetRowCount()))
r, c := q.queueList.GetSelection()
q.changeSelection(r, c)
}
Expand Down
Loading
Loading