Skip to content

Commit

Permalink
there is no search request for tags Oo
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wendland committed Nov 23, 2014
1 parent a5d210a commit 359a5cd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 115 deletions.
48 changes: 0 additions & 48 deletions tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,51 +30,3 @@ type Tag struct {
Count int `xml:"count,attr"`
Name string `xml:"name"`
}

// SearchTag queries MusicBrainz' Search Server for Tags.
// searchTerm only contains the tag field. For more information visit
// https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2/Search#Tag
func (c *WS2Client) SearchTag(searchTerm string, limit, offset int) (*TagSearchResponse, error) {

result := tagListResult{}
err := c.searchRequest("/tag", &result, searchTerm, limit, offset)

rsp := TagSearchResponse{}
rsp.WS2ListResponse = result.TagList.WS2ListResponse
rsp.Scores = make(ScoreMap)

for i, v := range result.TagList.Tags {
rsp.Tags = append(rsp.Tags, v.Tag)
rsp.Scores[rsp.Tags[i]] = v.Score
}

return &rsp, err
}

// TagSearchResponse is the response type returned by the SearchTag method.
type TagSearchResponse struct {
WS2ListResponse
Tags []*Tag
Scores ScoreMap
}

// ResultsWithScore returns a slice of Tags with a specific score.
func (r *TagSearchResponse) ResultsWithScore(score int) []*Tag {
var res []*Tag
for k, v := range r.Scores {
if v == score {
res = append(res, k.(*Tag))
}
}
return res
}

type tagListResult struct {
TagList struct {
WS2ListResponse
Tags []struct {
*Tag
Score int `xml:"http://musicbrainz.org/ns/ext#-2.0 score,attr"`
} `xml:"tag"`
} `xml:"tag-list"`
}
67 changes: 0 additions & 67 deletions tag_test.go

This file was deleted.

0 comments on commit 359a5cd

Please sign in to comment.