@@ -15,7 +15,7 @@ use output::Output;
15
15
use playlist:: Playlist ;
16
16
use plugin:: Plugin ;
17
17
use proto:: * ;
18
- use search:: { Query , Window } ;
18
+ use search:: { Query , Window , Term } ;
19
19
use song:: { Id , Song } ;
20
20
use stats:: Stats ;
21
21
use status:: { ReplayGain , Status } ;
@@ -238,15 +238,15 @@ impl<S: Read + Write> Client<S> {
238
238
}
239
239
240
240
/// Append a song into a queue
241
- pub fn push < P : AsRef < str > > ( & mut self , path : P ) -> Result < Id > {
242
- self . run_command ( "addid" , path. as_ref ( ) )
241
+ pub fn push < P : ToSongPath > ( & mut self , path : P ) -> Result < Id > {
242
+ self . run_command ( "addid" , path)
243
243
. and_then ( |_| self . read_field ( "Id" ) )
244
244
. map ( Id )
245
245
}
246
246
247
247
/// Insert a song into a given position in a queue
248
- pub fn insert < P : AsRef < str > > ( & mut self , path : P , pos : usize ) -> Result < usize > {
249
- self . run_command ( "addid" , ( path. as_ref ( ) , pos) )
248
+ pub fn insert < P : ToSongPath > ( & mut self , path : P , pos : usize ) -> Result < usize > {
249
+ self . run_command ( "addid" , ( path, pos) )
250
250
. and_then ( |_| self . read_field ( "Id" ) )
251
251
}
252
252
@@ -377,8 +377,8 @@ impl<S: Read + Write> Client<S> {
377
377
}
378
378
379
379
/// Add new songs to a playlist
380
- pub fn pl_push < N : ToPlaylistName , P : AsRef < str > > ( & mut self , name : N , path : P ) -> Result < ( ) > {
381
- self . run_command ( "playlistadd" , ( name. to_name ( ) , path. as_ref ( ) ) )
380
+ pub fn pl_push < N : ToPlaylistName , P : ToSongPath > ( & mut self , name : N , path : P ) -> Result < ( ) > {
381
+ self . run_command ( "playlistadd" , ( name. to_name ( ) , path) )
382
382
. and_then ( |_| self . expect_ok ( ) )
383
383
}
384
384
@@ -413,7 +413,7 @@ impl<S: Read + Write> Client<S> {
413
413
// Database search {{{
414
414
// TODO: count tag needle [...] [group] [grouptag], find type what [...] [window start:end]
415
415
// TODO: search type what [...] [window start:end], searchadd type what [...]
416
- // TODO: findadd type what [...], listallinfo [uri], listfiles [uri], lsinfo [uri]
416
+ // TODO: listallinfo [uri], listfiles [uri]
417
417
// TODO: list type [filtertype] [filterwhat] [...] [group] [grouptype] [...]
418
418
// TODO: searchaddpl name type what [...], readcomments
419
419
@@ -436,6 +436,26 @@ impl<S: Read + Write> Client<S> {
436
436
. and_then ( |_| self . read_structs ( "file" ) )
437
437
}
438
438
439
+ /// Lists unique tags values of the specified type for songs matching the given query.
440
+ // TODO: list type [filtertype] [filterwhat] [...] [group] [grouptype] [...]
441
+ // It isn't clear if or how `group` works
442
+ pub fn list ( & mut self , term : & Term , query : & Query ) -> Result < Vec < String > > {
443
+ self . run_command ( "list" , ( term, query) )
444
+ . and_then ( |_| self . read_pairs ( ) . map ( |p| p. map ( |p| p. 1 ) ) . collect ( ) )
445
+ }
446
+
447
+ /// Find all songs in the db that match query and adds them to current playlist.
448
+ pub fn findadd ( & mut self , query : & Query ) -> Result < ( ) > {
449
+ self . run_command ( "findadd" , query)
450
+ . and_then ( |_| self . expect_ok ( ) )
451
+ }
452
+
453
+ /// Lists the contents of a directory.
454
+ pub fn lsinfo < P : ToSongPath > ( & mut self , path : P ) -> Result < Song > {
455
+ self . run_command ( "lsinfo" , path)
456
+ . and_then ( |_| self . read_struct ( ) )
457
+ }
458
+
439
459
// }}}
440
460
441
461
// Output methods {{{
0 commit comments