summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Ultramarine/Controller.pm648
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/Ultramarine/Controller.pm6 b/lib/Ultramarine/Controller.pm6
index c66e839..0167dd0 100644
--- a/lib/Ultramarine/Controller.pm6
+++ b/lib/Ultramarine/Controller.pm6
@@ -78,6 +78,54 @@ class Ultramarine::Controller {
],
}
get $getMusicFolders;
+
+ post my $getIndexes = -> 'getIndexes', :$musicFolderId is query, :$ifModifiedSince is query {
+ await $.collection.is-ready;
+
+ # when musicFolderId is not passed, we get a Mu, which
+ # breaks the call (it wants an Any)
+ my $indexes = $.collection.dir-children-of(id=>$musicFolderId)
+ .classify( *.name.substr(0,1).uc ).pairs.map: -> (:key($initial),:value($dirs)) {
+ index => [
+ name => $initial,
+ |($dirs.map: { artist => [ id => $^d.id, name => $^d.name ] })
+ ]
+ };
+ my $songs = $.collection.songs-children-of(id=>$musicFolderId)
+ .map: -> $song {
+ my $c = [
+ id => $song.id,
+ path => $song.path,
+ isDir => 'false',
+ isVideo => 'false',
+ type => 'music',
+ contentType => 'audio/mpeg', # faking it
+ |($song.metadata<tags><album artist genre track title>:p),
+ year => $song.metadata<tags><date>,
+ bitRate => $song.metadata<bit_rate>.Int,
+ duration => ($song.metadata<duration>*60).Int,
+ suffix => $song.metadata<format_name>, # I'm guessing
+ albumId => $song.album_id,
+ artistId => 1, # real artistId to be fetched
+ size => 10000, # we don't event store this
+ created => Instant.from-posix($song.mtime).DateTime.Str,
+ ];
+ warn $c.perl;
+ child => $c;
+ }
+
+ respond [
+ :status<ok>,
+ indexes => [
+ lastModified => now.to-posix[0].Int,
+ ignoredArticles => '',
+ |$indexes,
+ |$songs,
+ ],
+ ];
+ }
+ get $getIndexes;
+
# this is clearly not a Subsonic method
get -> 'dakkarList' {
await $.collection.is-ready;