genius

package
v0.0.0-...-0b47a9d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2017 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Album

type Album struct {
	ApiPath     string  `json:api_path`
	CoverArtURL string  `json:"cover_art_url"`
	FullTitle   string  `json:full_title`
	ID          int     `json:"id"`
	Name        string  `json:"name"`
	URL         string  `json:"url"`
	Artist      *Artist `json:"artist"`
}

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"`
	ShareURL            string        `json:"share_url"`
	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 Author

type Author struct {
	Attribution float64 `json:"attribution"`
	PinnedRole  string  `json:"pinned_role"`
	User        *User   `json:"user"`
}

type Avatar

type Avatar struct {
	Tiny   *Image `json:"tiny"`
	Thumb  *Image `json:"thumb"`
	Small  *Image `json:"small"`
	Medium *Image `json:"medium"`
}

type Client

type Client struct {
	AccessToken string
	// contains filtered or unexported fields
}

Client is a client for Genius API

func NewClient

func NewClient(httpClient *http.Client, token string) *Client

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

func (c *Client) GetAccount() (*Response, error)

GetAccount returns current user account data

func (*Client) GetAnnotation

func (c *Client) GetAnnotation(id string, textFormat string) (*Response, error)

GetAnnotation gets annotation object in response

func (*Client) GetArtist

func (c *Client) GetArtist(id int) (*Response, error)

GetArtist returns Artist object in response

Uses "dom" as textFormat by default

func (*Client) GetArtistDom

func (c *Client) GetArtistDom(id int) (*Response, error)

GetArtistDom returns Artist object in response With "dom" as textFormat

func (*Client) GetArtistHTML

func (c *Client) GetArtistHTML(id int) (*Response, error)

GetArtistHTML returns Artist object in response With "html" as textFormat

func (*Client) GetArtistPlain

func (c *Client) GetArtistPlain(id int) (*Response, error)

GetArtistPlain returns Artist object in response With "plain" as textFormat

func (*Client) GetArtistSongs

func (c *Client) GetArtistSongs(id int, sort string, per_page int, page int) (*Response, error)

GetArtistSongs returns array of songs objects in response

func (*Client) GetSong

func (c *Client) GetSong(id int, textFormat string) (*Response, error)

GetSong returns Song object in response

func (*Client) Search

func (c *Client) Search(q string) (*Response, error)

Search returns array of Hit objects in response

Currently only songs are searchable by this handler

type Contributor

type Contributor struct {
	Contributions []string `json:"contributions"`
	Artist        *Artist  `json:"artist"`
	User          *User    `json:"user"`
}

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 FactTrack

type FactTrack struct {
	Provider     string `json:"provider"`
	ExternalURL  string `json:"external_url"`
	ButtonText   string `json:"button_text"`
	HelpLinkText string `json:"help_link_text"`
	HelpLinkURL  string `json:"help_link_url"`
}

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 Image

type Image struct {
	URL         string `json:"url"`
	BoundingBox struct {
		Width  int `json:"width"`
		Height int `json:"height"`
	} `json:"bounding_box"`
}

type Media

type Media struct {
	Provider   string `json:"provider"`
	ProviderID string `json:"provider_id"`
	NativeURI  string `json:"native_uri"`
	Start      int    `json:"start"`
	Type       string `json:"type"`
	URL        string `json:"url"`
}

type Primary

type Primary struct {
	Multiplier int     `json:"multiplier"`
	Base       float64 `json:"base"`
	Applicable bool    `json:"applicable"`
}

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 SongRelationship struct {
	Type  string  `json:"type"`
	Songs []*Song `json:"songs"`
}

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"`
	ShareURL        string `json:"share_url"`
	Title           string `json:"title"`
	URL             string `json:"url"`
	AnnotationCount int    `json:"annotation_count"`
}

WebPage is web_page on Genius API

type WithBody

type WithBody struct {
	Body    string                 `json:"-"`
	RawBody map[string]interface{} `json:"body"`
}

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

func (*WithBody) Process

func (b *WithBody) Process(textFormat string)

Process will check the textFormat and put result string in Body field if textFormat was "html" or "plain"

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"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL