Permalink
Browse files

Expose /recording/find-by-isrc and /recording/view-isrcs

  • Loading branch information...
ocharles committed Mar 4, 2013
1 parent 00fb270 commit 1bfc07a8ccd957af4b73e4f10ab9041f1c2b70ec
Showing with 27 additions and 3 deletions.
  1. +1 −1 musicbrainz-data
  2. +6 −1 src/MusicBrainz/API/JSON.hs
  3. +16 −1 src/MusicBrainz/API/Recording.hs
  4. +2 −0 src/MusicBrainz/Service.hs
  5. +2 −0 test/suite/Handlers.hs
@@ -26,7 +26,7 @@ import MusicBrainz.Data.Recording (RecordingUse(..))
--------------------------------------------------------------------------------
instance ToJSON (MBID a) where
- toJSON = toJSON . view (re mbid)
+ toJSON = toJSON . review mbid
--------------------------------------------------------------------------------
@@ -107,6 +107,11 @@ instance ToJSON Gender where
toJSON Gender{..} = object [ "name" .= genderName ]
+--------------------------------------------------------------------------------
+instance ToJSON ISRC where
+ toJSON = toJSON . review isrc
+
+
--------------------------------------------------------------------------------
instance ToJSON Label where
toJSON Label{..} = object [ "name" .= labelName
@@ -29,7 +29,6 @@ tree = RecordingTree <$> "recording" .: recording
<*> comment
<*> artistCreditRef
<*> duration
- isrcF = validate (maybe (Error "Could not parse ISRC") Success . preview isrc) $ text Nothing
puidF = validate (maybe (Error "Could not parse PUID") Success . preview puid) $ string Nothing
@@ -87,3 +86,19 @@ findRecordingTracks = runApi $ MB.findRecordingTracks <$> "recording" .: coreRef
--------------------------------------------------------------------------------
findByArtist :: Form Text MusicBrainz [CoreEntity Recording]
findByArtist = runApi $ MB.findByArtist <$> "artist" .: coreRef
+
+
+--------------------------------------------------------------------------------
+findByIsrc :: Form Text MusicBrainz [CoreEntity Recording]
+findByIsrc = runApi $ MB.findByIsrc <$> "isrc" .: isrcF
+
+
+--------------------------------------------------------------------------------
+viewIsrcs :: Form Text MusicBrainz (Set.Set ISRC)
+viewIsrcs = runApi $ MB.viewIsrcs <$> recordingRevision
+
+
+--------------------------------------------------------------------------------
+isrcF :: Monad m => Form Text m ISRC
+isrcF = validate (maybe (Error "Could not parse ISRC") Success . preview isrc) $
+ text Nothing
@@ -277,12 +277,14 @@ serviceInit connInfo sessionStore =
, ("/recording/create", expose Recording.create)
, ("/recording/find-by-artist", expose Recording.findByArtist)
+ , ("/recording/find-by-isrc", expose Recording.findByIsrc)
, ("/recording/find-latest", expose Recording.findLatest)
, ("/recording/find-recording-tracks", expose Recording.findRecordingTracks)
, ("/recording/get-revision", expose Recording.getRevision)
, ("/recording/merge", expose Recording.merge)
, ("/recording/update", expose Recording.update)
, ("/recording/view-annotation", expose Recording.viewAnnotation)
+ , ("/recording/view-isrcs", expose Recording.viewIsrcs)
, ("/recording/view-relationships", expose Recording.viewRelationships)
, ("/recording/view-revision", expose Recording.viewRevision)
View
@@ -51,12 +51,14 @@ tests = map testHandlerExists
, "/label/view-revision"
, "/recording/create"
, "/recording/find-by-artist"
+ , "/recording/find-by-isrc"
, "/recording/find-latest"
, "/recording/find-recording-tracks"
, "/recording/get-revision"
, "/recording/merge"
, "/recording/update"
, "/recording/view-annotation"
+ , "/recording/view-isrcs"
, "/recording/view-relationships"
, "/recording/view-revision"
, "/release/create"

0 comments on commit 1bfc07a

Please sign in to comment.