Documentation ¶
Index ¶
- type Album
- type Annotatable
- type Annotation
- type Artist
- type Author
- type Avatar
- type Client
- func (c *Client) GetAccount() (*Response, error)
- func (c *Client) GetAnnotation(id string, textFormat string) (*Response, error)
- func (c *Client) GetArtist(id int) (*Response, error)
- func (c *Client) GetArtistDom(id int) (*Response, error)
- func (c *Client) GetArtistHTML(id int) (*Response, error)
- func (c *Client) GetArtistPlain(id int) (*Response, error)
- func (c *Client) GetArtistSongs(id int, sort string, per_page int, page int) (*Response, error)
- func (c *Client) GetSong(id int, textFormat string) (*Response, error)
- func (c *Client) Search(q string) (*Response, error)
- type Contributor
- type DescriptionAnnotation
- type FactTrack
- type Hit
- type IQByAction
- type Image
- type Media
- type Primary
- type Response
- type Song
- type SongRelationship
- type Stats
- type User
- type UserMetadata
- type WebPage
- type WithBody
- type WithDescription
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Annotatable ¶
type Annotatable struct { ApiPath string `json:"api_path"` Context string `json:"context"` ID int `json:"id"` ImageURL string `json:"image_url"` LinkTitle string `json:"link_title"` Title string `json:"title"` Type string `json:"type"` URL string `json:"url"` ClientTimestamps struct { UpdatedByHumanAt time.Time `json:"updated_by_human_at"` LyricsUpdatedAt time.Time `json:"lyrics_updated_at"` } `json:"client_timestamps"` }
type Annotation ¶
type Annotation struct { WithBody ApiPath string `json:"api_path"` CommentCount int `json:"comment_count"` Community bool `json:"community"` CustomPreview string `json:"custom_preview"` HasVoters bool `json:"has_voters"` ID int `json:"id"` Pinned bool `json:"pinned"` Source string `json:"source"` State string `json:"state"` URL string `json:"url"` Verified bool `json:"verified"` VotesTotal int `json:"voters_total"` CurrentUserMetadata *UserMetadata `json:"current_user_metadata"` Authors []*Author `json:"authors"` CosignedBy []string `json:"cosigned_by"` VerifiedBy *User `json:"verified_by"` }
Annotation is annotation on Genius API
type Artist ¶
type Artist struct { WithDescription AlternateNames []string `json:"alternate_names"` ApiPath string `json:"api_path"` FacebookName string `json:"facebook_name"` FollowersCount int `json:"followers_count"` HeaderImageURL string `json:"header_image_url"` ID int `json:"id"` ImageURL string `json:"image_url"` InstagramName string `json:"instagram_name"` IsMemeVerified bool `json:"is_meme_verified"` IsVerified bool `json:"is_verified"` Name string `json:"name"` TwitterName string `json:"twitter_name"` URL string `json:"url"` CurrentUserMetadata *UserMetadata `json:"current_user_metadata"` IQ int `json:"iq"` DescriptionAnnotation *DescriptionAnnotation `json:"description_annotation"` User *User `json:"user"` }
Artist is artist on Genius API
type Client ¶
type Client struct { AccessToken string // contains filtered or unexported fields }
Client is a client for Genius API
func NewClient ¶
NewClient creates Client to work with Genius API You can pass http.Client or it will use http.DefaultClient by default
It requires a token for accessing Genius API
Example ¶
package main import ( "fmt" "github.com/gabyshev/genius-api/genius" ) func main() { accessToken := "token" client := genius.NewClient(nil, accessToken) response, err := client.GetArtistHTML(16775) if err != nil { panic(err) } fmt.Println(response.Response.Artist) }
Output:
func (*Client) GetAccount ¶
GetAccount returns current user account data
func (*Client) GetAnnotation ¶
GetAnnotation gets annotation object in response
func (*Client) GetArtist ¶
GetArtist returns Artist object in response
Uses "dom" as textFormat by default
func (*Client) GetArtistDom ¶
GetArtistDom returns Artist object in response With "dom" as textFormat
func (*Client) GetArtistHTML ¶
GetArtistHTML returns Artist object in response With "html" as textFormat
func (*Client) GetArtistPlain ¶
GetArtistPlain returns Artist object in response With "plain" as textFormat
func (*Client) GetArtistSongs ¶
GetArtistSongs returns array of songs objects in response
type Contributor ¶
type DescriptionAnnotation ¶
type DescriptionAnnotation struct { Type string `json:"_type"` AnnotatorID int `json:"annotator_id"` AnnotatorLogin string `json:"annotator_login"` ApiPath string `json:"api_path"` Classification string `json:"classification"` Fragment string `json:"fragment"` ID int `json:"id"` IsDescription bool `json:"is_description"` Path string `json:"path"` SongID int `json:"song_id"` URL string `json:"url"` VerifiedAnnotatorIDs []int `json:"verified_annotator_ids"` Annotatable *Annotatable `json:"annotatable"` Annotations []*Annotation `json:"annotations"` Range struct { Content string `json:"content"` } `json:"range"` }
type Hit ¶
type Hit struct { Highlights []string `json:"highlights"` Index string `json:"index"` Type string `json:"type"` Result *Song `json:"result"` }
Hit is a hit on Genius API Used in /search handler Includes song results only
type IQByAction ¶
type IQByAction struct { Accept struct { Primary *Primary `json:"primary"` } `json:"accept"` Reject struct { Primary *Primary `json:"primary"` } `json:"reject"` Delete struct { Primary *Primary `json:"primary"` } `json:"delete"` EditMetadata struct { Primary *Primary `json:"primary"` } `json:"edit_metadata"` }
type Response ¶
type Response struct { Meta struct { Status int `json:"status"` Message string `json:"message"` } `json:"meta"` Response struct { Artist *Artist `json:"artist"` Song *Song `json:"song"` Annotation *Annotation `json:"annotation"` User *User `json:"user"` Songs []*Song `json:"songs"` NextPage int `json:"next_page"` Hits []*Hit `json:"hits"` WebPage *WebPage `json:"web_page"` } `json:"response"` }
Response is an actual response object from Genius API Consist links to possible retrievavable objects: Artist, Song, etc
type Song ¶
type Song struct { WithDescription AnnotationCount int `json:"annotation_count"` ApiPath string `json:"api_path"` EmbedContent string `json:"embed_content"` FactTrack *FactTrack `json:"fact_track"` FeaturedVideo bool `json:"features_video"` FullTitle string `json:"full_title"` HeaderImageThumbnailURL string `json:"header_image_thumbnail_url"` HeaderImageURL string `json:"header_image_url"` ID int `json:"id"` LyricsOwnerID int `json:"lyrics_owner_id"` LyricsState string `json:"lyrics_state"` Path string `json:"path"` PyongsCount int `json:"pyong_count"` RecordingLocation string `json:"recording_location"` ReleaseDate string `json:"release_date"` SongArtImageThumbnailURL string `json:"song_art_image_thumbnail_url"` SongArtImageURL string `json:"song_art_image_url"` Stats *Stats `json:"stats"` Title string `json:"title"` TitleWithFeatured string `json:"title_with_featured"` URL string `json:"url"` CurrentUserMetadata *UserMetadata `json:"current_user_metadata"` Album *Album `json:"album"` CustomPerformances []string `json:"custom_performances"` DescriptionAnnotation *DescriptionAnnotation `json:"description_annotation"` FeaturedArtists []*Artist `json:"featured_artist"` Media []*Media `json:"media"` PrimaryArtist *Artist `json:"primary_artist"` ProducerArtists []*Artist `json:"producer_artists"` SongRelationships []*SongRelationship `json:"song_relationships"` VerifiedAnnotationsBy []*User `json:"verified_annotations_by"` VerifiedContributors []*Contributor `json:"verified_contributors"` VerifiedLyricsBy []*User `json:"verified_lyrics_by"` WriterArtists []*Artist `json:"writer_artists"` }
Song is song on Genius API
type SongRelationship ¶
type Stats ¶
type Stats struct { AcceptedAnnotations int `json:"accepted_annotations"` Contributors int `json:"contributors"` Hot bool `json:"hot"` IQEarners int `json:"iq_earners"` Transcribers int `json:"transcribers"` UnreviewedAnnotations int `json:"unreviewed_annotations"` VerifiedAnnotations int `json:"verified_annotations"` Concurrents int `json:"concurrents"` Pageviews int `json:"pageviews"` }
type User ¶
type User struct { ApiPath string `json:"api_path"` Avatar *Avatar `json:"avatar"` HeaderImageURL string `json:"header_image_url"` HumanReadableRoleForDisplay string `json:"human_readable_role_for_display"` ID int `json:"id"` IQ int `json:"iq"` Login string `json:"login"` Name string `json:"name"` RoleForDisplay string `json:"role_for_display"` URL string `json:"url"` CurrentUserMetadata *UserMetadata `json:"current_user_metadata"` }
User is user on Genius API
type UserMetadata ¶
type UserMetadata struct { Permissions []string `json:"permissions"` ExcludedPersmissions []string `json:"excluded_permissions"` Features []string `json:"features"` IQByAction *IQByAction `json:"iq_by_action"` Interactions struct { Following bool `json:"following"` Cosign bool `json:"cosign"` Pyong bool `json:"pyong"` Vote bool `json:"vote"` } `json:"interactions"` Relationships struct { PinnedRole string `json:"pinned_role"` } `json:"relationships"` }
type WebPage ¶
type WebPage struct { ApiPath string `json:"api_path"` Domain string `json:"domain"` ID int `json:"id"` NormalizedURL string `json:"normalized_url"` Title string `json:"title"` URL string `json:"url"` AnnotationCount int `json:"annotation_count"` }
WebPage is web_page on Genius API
type WithBody ¶
WithBody is a struct to take care of different formats of field "body" If "textFormat" was either "html" or "plain" Process method will put result string in Body field In case of "dom" use RawBody
type WithDescription ¶
type WithDescription struct { Description string `json:"-"` RawDescription map[string]interface{} `json:"description"` }
WithDescription is a struct to take care of different formats of field "description" If "textFormat" was either "html" or "plain" Process method will put result string in Description field In case of "dom" use RawDescription
func (*WithDescription) Process ¶
func (d *WithDescription) Process(textFormat string)
Process will check the textFormat and put result string in Description field if textFormat was "html" or "plain"