mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
WIP: Search
This commit is contained in:
parent
87d4f33b09
commit
4af3e7aead
@ -51,35 +51,27 @@ extension MPDClient {
|
|||||||
|
|
||||||
func allAlbums(filter: String) {
|
func allAlbums(filter: String) {
|
||||||
var albums: [MPDAlbum] = []
|
var albums: [MPDAlbum] = []
|
||||||
var artist: String = ""
|
|
||||||
|
|
||||||
mpd_search_db_tags(self.connection, MPD_TAG_ALBUM)
|
mpd_search_db_songs(self.connection, false)
|
||||||
if filter != "" {
|
if filter != "" {
|
||||||
mpd_search_add_expression(
|
mpd_search_add_expression(
|
||||||
self.connection,
|
self.connection,
|
||||||
"(any =~ 'alanis')"
|
"(any contains '\(filter)')"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
mpd_search_add_group_tag(self.connection, MPD_TAG_ALBUM_ARTIST)
|
mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_TRACK, "1")
|
||||||
|
|
||||||
mpd_search_commit(self.connection)
|
mpd_search_commit(self.connection)
|
||||||
|
|
||||||
while let pair = mpd_recv_pair(self.connection) {
|
while let song = mpd_recv_song(self.connection) {
|
||||||
let pair = MPDPair(pair)
|
let mpdSong = MPDSong(song)
|
||||||
|
|
||||||
switch pair.name {
|
let mpdAlbum = MPDAlbum(title: mpdSong.album.title, artist: mpdSong.artist)
|
||||||
case "AlbumArtist":
|
if (mpdAlbum != albums.last) {
|
||||||
artist = pair.value
|
albums.append(mpdAlbum)
|
||||||
case "Album":
|
|
||||||
albums.append(MPDAlbum(title: pair.value, artist: artist))
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mpd_return_pair(self.connection, pair.pair)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print(getLastErrorMessage())
|
|
||||||
|
|
||||||
self.delegate?.didLoadAlbums(mpdClient: self, albums: albums)
|
self.delegate?.didLoadAlbums(mpdClient: self, albums: albums)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -93,7 +93,7 @@ extension MPDClient {
|
|||||||
|
|
||||||
// Album commands
|
// Album commands
|
||||||
case .fetchAllAlbums:
|
case .fetchAllAlbums:
|
||||||
allAlbums(filter: "Alanis")
|
allAlbums(filter: "")
|
||||||
case .playAlbum:
|
case .playAlbum:
|
||||||
guard let album = userData["album"] as? MPDAlbum else { return }
|
guard let album = userData["album"] as? MPDAlbum else { return }
|
||||||
sendPlayAlbum(album)
|
sendPlayAlbum(album)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user