Permalink
Browse files

Expose /release/find-by-label and /artist-credit/expand

  • Loading branch information...
1 parent 675f547 commit 735008cf1fd3455f012b73b3a031e9bdd0bd349c @ocharles ocharles committed Feb 27, 2013
@@ -16,6 +16,7 @@ module MusicBrainz.API
-- ** Entity reference parsers
, edit
, editorRef
+ , ref
, revision, revisionRef
, coreRef, optionalCoreRef
@@ -0,0 +1,21 @@
+{-# LANGUAGE NoMonomorphismRestriction #-}
+{-# LANGUAGE OverloadedStrings #-}
+module MusicBrainz.API.ArtistCredit where
+
+import Control.Applicative
+import Data.Text
+import Text.Digestive
+
+import MusicBrainz hiding (coreRef, releaseLabel, partialDate)
+import MusicBrainz.API
+import qualified MusicBrainz.Data.ArtistCredit as MB
+
+import qualified Data.Map as Map
+import qualified Data.Set as Set
+
+--------------------------------------------------------------------------------
+expandCredits :: Form Text MusicBrainz
+ (Map.Map (Ref ArtistCredit) [ArtistCreditName])
+expandCredits =
+ runApi $ MB.expandCredits . Set.fromList <$>
+ listOf (const $ ref "Could not resolve artist credit") Nothing
@@ -70,6 +70,14 @@ instance ToJSON Artist where
--------------------------------------------------------------------------------
+instance ToJSON ArtistCreditName where
+ toJSON ArtistCreditName{..} = object [ "artist" .= acnArtist
+ , "name" .= acnName
+ , "join-phrase" .= acnJoinPhrase
+ ]
+
+
+--------------------------------------------------------------------------------
instance ToJSON ArtistType where
toJSON ArtistType{..} = object [ "name" .= artistTypeName ]
@@ -247,9 +255,10 @@ class ToJSON a => TopLevel a
instance (Referenceable a, ToJSON (RefSpec a)) => TopLevel (RefObject a)
instance (ToJSON (RefSpec a), ToJSON a, Referenceable a) => TopLevel (CoreEntity a)
instance (ToJSON (RefSpec a), ToJSON a, Referenceable a) => TopLevel (Entity a)
-instance (ToJSON v) => TopLevel (Set v)
instance (ToJSON v, ToJSON (RefSpec k), Referenceable k) => TopLevel (Map.Map (Ref k) v)
instance ToJSON a => TopLevel (MaybeObject a)
+instance ToJSON a => TopLevel (Set a)
instance TopLevel ()
instance TopLevel Annotation
instance TopLevel EligibleForCleanup
+instance TopLevel a => TopLevel [a]
@@ -14,6 +14,7 @@ import MusicBrainz.API
import qualified MusicBrainz.API.Common as Common
import MusicBrainz.API.JSON
import qualified MusicBrainz.Data as MB
+import qualified MusicBrainz.Data.Release as MB
--------------------------------------------------------------------------------
tree :: Form Text MusicBrainz (Tree Release)
@@ -114,3 +115,8 @@ getRevision = Common.getRevision
--------------------------------------------------------------------------------
create :: Form Text MusicBrainz (RefObject (Revision Release))
create = Common.create tree
+
+
+--------------------------------------------------------------------------------
+findByLabel :: Form Text MusicBrainz [CoreEntity Release]
+findByLabel = runApi $ MB.findByLabel <$> "label" .: coreRef
@@ -36,6 +36,7 @@ import qualified Data.Map as Map
import qualified Data.Text as T
import qualified Data.Text.Encoding as Encoding
import qualified MusicBrainz.API.Artist as Artist
+import qualified MusicBrainz.API.ArtistCredit as ArtistCredit
import qualified MusicBrainz.API.ArtistType as ArtistType
import qualified MusicBrainz.API.Edit as Edit
import qualified MusicBrainz.API.Gender as Gender
@@ -251,6 +252,8 @@ serviceInit connInfo sessionStore =
, ("/artist/view-relationships", expose Artist.viewRelationships)
, ("/artist/view-revision", expose Artist.viewRevision)
+ , ("/artist-credit/expand", expose ArtistCredit.expandCredits)
+
, ("/artist-type/add", expose ArtistType.add)
, ("/edit/add-note", expose Edit.addEditNote)
@@ -283,6 +286,7 @@ serviceInit connInfo sessionStore =
, ("/recording/view-revision", expose Recording.viewRevision)
, ("/release/create", expose Release.create)
+ , ("/release/find-by-label", expose Release.findByLabel)
, ("/release/find-latest", expose Release.findLatest)
, ("/release/get-revision", expose Release.getRevision)
, ("/release/merge", expose Release.merge)

0 comments on commit 735008c

Please sign in to comment.