api

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROTOR_RADIO_STARTED  = "radioStarted"
	ROTOR_RADIO_FINISHED = "radioFinished"
	ROTOR_TRACK_STARTED  = "trackStarted"
	ROTOR_TRACK_FINISHED = "trackFinished"
	ROTOR_SKIP           = "skip"
)

Rotor feedback types

View Source
const (
	SEARCH_ARTIST = "artist"
	SEARCH_ALBUM  = "album"
	SEARCH_TRACK  = "track"
	SEARCH_ALL    = "all"
)
View Source
const (
	YaMusicServerURL = "https://api.music.yandex.net/"
)

Yandex Music service information

Variables

View Source
var (
	MyWaveId = StationId{
		Type: "user",
		Tag:  "onyourwave",
	}
)

Functions

func DownloadTrackCover

func DownloadTrackCover(dst io.Writer, track *Track, size int) (string, error)
func ShareTrackLink(track *Track) string

func Token deprecated

func Token(username, password string) (token string, err error)

Deprecated: doesn't work in most cases

func TrackCoverLink(track *Track, size int) string

Types

type Album

type Album struct {
	Id          uint64    `json:"id"`
	Title       string    `json:"title"`
	Available   bool      `json:"available"`
	Type        string    `json:"type"`
	MetaType    string    `json:"metaType"`
	Year        int       `json:"year"`
	ReleaseDate string    `json:"releaseDate"`
	CoverUri    string    `json:"coverUri"`
	OgImage     string    `json:"ogImage"`
	Genre       string    `json:"genre"`
	Recent      bool      `json:"recent"`
	TrackCount  int       `json:"trackCount"`
	Volumes     [][]Track `json:"volumes"`
	Artists     []Artist  `json:"artists"`
	Labels      []Label   `json:"labels"`
}

type Artist

type Artist struct {
	Id       uint64   `json:"id"`
	Name     string   `json:"name"`
	Various  bool     `json:"various"`
	Composer bool     `json:"composer"`
	Cover    Cover    `json:"cover"`
	Genres   []string `json:"genres"`
}

type ArtistTracks

type ArtistTracks struct {
	Artist Artist   `json:"artist"`
	Tracks []string `json:"tracks"`
}

type BadRequestError

type BadRequestError struct {
	Name    string `json:"name"`
	Message string `json:"message"`
}

func (BadRequestError) Error

func (e BadRequestError) Error() string

type Cover

type Cover struct {
	Type     string   `json:"type"`
	Uri      string   `json:"uri"`
	Dir      string   `json:"dir"`
	ItemsUri []string `json:"itemsUri"`
}

type InvocInfo

type InvocInfo struct {
	ExecDurationMillis int    `json:"exec-duration-millis"`
	Hostname           string `json:"hostname"`
	ReqId              string `json:"req-id"`
}

type Label

type Label struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type LikeTrackInfo

type LikeTrackInfo struct {
	Id        string `json:"id"`
	AlbumId   string `json:"albumId"`
	Timestamp string `json:"timestamp"`
}

type LikesDesc

type LikesDesc struct {
	Library struct {
		Uid       uint64          `json:"uid"`
		Revisions int             `json:"revisions"`
		Tracks    []LikeTrackInfo `json:"tracks"`
	} `json:"library"`
}

type LyricPair

type LyricPair struct {
	Timestamp int
	Line      string
}

type Owner

type Owner struct {
	Login    string `json:"login"`
	Name     string `json:"name"`
	Sex      string `json:"sex"`
	Uid      uint64 `json:"uid"`
	Verified bool   `json:"verified"`
}

type Playlist

type Playlist struct {
	Uid  uint64 `json:"uid"`
	Kind uint64 `json:"kind"`

	Title                string `json:"title"`
	Description          string `json:"description"`
	DescriptionFormatted string `json:"descriptionFormatted"`
	Available            bool   `json:"available"`
	Collective           bool   `json:"collective"`
	Created              string `json:"created"`
	Modified             string `json:"modified"`
	Visibility           string `json:"visibility"`
	LikesCount           int    `json:"likesCount"`
	Revision             int    `json:"revision"`

	Tags    []Tag  `json:"tags"`
	Owner   Owner  `json:"owner"`
	Cover   Cover  `json:"cover"`
	OgImage string `json:"ogImage"`

	BackgroundColor string `json:"backgroundColor"`
	TextColor       string `json:"textColor"`

	TrackCount int `json:"trackCount"`
	Tracks     []struct {
		Id        uint64 `json:"id"`
		PlayCount int    `json:"playCount"`
		Recent    bool   `json:"recent"`
		Timestamp string `json:"timestamp"`
		Track     Track  `json:"track"`
	} `json:"tracks"`
}

type SearchResult

type SearchResult struct {
	SearchResultId string `json:"searchResultId"`
	Text           string `json:"text"`
	Best           struct {
		Type   string `json:"type"`
		Text   string `json:"text"`
		Result Track  `json:"result"`
	} `json:"best"`

	Albums struct {
		Type    string  `json:"type"`
		Total   int     `json:"total"`
		PerPage int     `json:"perPage"`
		Order   int     `json:"order"`
		Results []Album `json:"results"`
	} `json:"albums"`

	Artists struct {
		Type    string   `json:"type"`
		Total   int      `json:"total"`
		PerPage int      `json:"perPage"`
		Order   int      `json:"order"`
		Results []Artist `json:"results"`
	} `json:"artists"`

	Playlists struct {
		Type    string     `json:"type"`
		Total   int        `json:"total"`
		PerPage int        `json:"perPage"`
		Order   int        `json:"order"`
		Results []Playlist `json:"results"`
	} `json:"playlists"`

	Tracks struct {
		Type    string  `json:"type"`
		Total   int     `json:"total"`
		PerPage int     `json:"perPage"`
		Order   int     `json:"order"`
		Results []Track `json:"results"`
	} `json:"tracks"`

	Type              string `json:"type"`
	Page              int    `json:"page"`
	PerPage           int    `json:"perPage"`
	MisspellCorrected bool   `json:"misspellCorrected"`
	MisspellOriginal  string `json:"misspellOriginal"`
	Nocorrect         bool   `json:"nocorrect"`
}

type SearchSuggest

type SearchSuggest struct {
	Best struct {
		Type   string `json:"type"`
		Text   string `json:"text"`
		Result Track  `json:"result"`
	} `json:"best"`
	Suggestions []string `json:"suggestions"`
}

type SearchType

type SearchType string

type Station

type Station struct {
	Id   StationId `json:"id"`
	Name string    `json:"name"`

	Icon struct {
		BackgroundColor string `json:"backgroundIcon"`
		ImageUrl        string `json:"imageUrl"`
	} `json:"icon"`
	FullImageUrl string `json:"fullImageUrl"`

	Restrictions struct {
		Language struct {
			Type           string `json:"type"`
			Name           string `json:"name"`
			PossibleValues struct {
				Name  string `json:"name"`
				Value string `json:"value"`
			} `json:"possibleValues"`
		} `json:"language"`

		Mood struct {
			Type string `json:"type"`
			Name string `json:"name"`
			Min  struct {
				Name  string  `json:"name"`
				Value float32 `json:"value"`
			} `json:"min"`
			Max struct {
				Name  string  `json:"name"`
				Value float32 `json:"value"`
			} `json:"max"`
		} `json:"mood"`

		Energy struct {
			Type string `json:"type"`
			Name string `json:"name"`
			Min  struct {
				Name  string  `json:"name"`
				Value float32 `json:"value"`
			} `json:"min"`
			Max struct {
				Name  string  `json:"name"`
				Value float32 `json:"value"`
			} `json:"max"`
		} `json:"energy"`

		Diversity struct {
			Type           string `json:"type"`
			Name           string `json:"name"`
			PossibleValues struct {
				Name  string `json:"name"`
				Value string `json:"value"`
			} `json:"possibleValues"`
		} `json:"diversity"`
	} `json:"restrictions"`
}

type StationDesc

type StationDesc struct {
	Station  Station `json:"station"`
	Settings struct {
		Language  string  `json:"language"`
		Diversity string  `json:"diversity"`
		Mood      float32 `json:"mood"`
		Energy    float32 `json:"energy"`
	} `json:"settings"`
	RupTitle       string `json:"rupTitle"`
	RupDescription string `json:"rupDescription"`
}

type StationId

type StationId struct {
	Type string `json:"type"`
	Tag  string `json:"tag"`
}

type StationTracks

type StationTracks struct {
	Id       StationId `json:"id"`
	Sequence []struct {
		Type  string `json:"type"`
		Track Track  `json:"track"`
		Liked bool   `json:"liked"`
	} `json:"sequence"`
	BatchId        string `json:"batchId"`
	RadioSessionId string `json:"radioSessionId"`
}

type Tag

type Tag struct {
	Id    string `json:"id"`
	Value string `json:"value"`
}

type TimeLimitedReader

type TimeLimitedReader struct {
	// contains filtered or unexported fields
}

func NewTimeLimitedReader

func NewTimeLimitedReader(r io.ReadCloser, ctx context.Context, ctxCancel context.CancelFunc, timeout time.Duration) *TimeLimitedReader

func (*TimeLimitedReader) Close

func (r *TimeLimitedReader) Close() error

func (*TimeLimitedReader) Read

func (r *TimeLimitedReader) Read(dest []byte) (int, error)

type Track

type Track struct {
	Id              string `json:"id"`
	RealId          string `json:"realId"`
	Title           string `json:"title"`
	Version         string `json:"version"`
	Available       bool   `json:"available"`
	Type            string `json:"type"`
	CoverUri        string `json:"coverUri"`
	OgImage         string `json:"ogImage"`
	LyricsAvailable bool   `json:"lyricsAvailable"`
	LyricsInfo      struct {
		HasAvailableSyncLyrics bool `json:"hasAvailableSyncLyrics"`
		HasAvailableTextLyrics bool `json:"hasAvailableTextLyrics"`
	} `json:"lyricsInfo"`
	Normalization struct {
		Gain float32 `json:"gain"`
		Peak float32 `json:"Peak"`
	} `json:"normalization"`

	Fade struct {
		InStart  float32 `json:"inStart"`
		InStop   float32 `json:"inStop"`
		OutStart float32 `json:"outStart"`
		OutStop  float32 `json:"outStop"`
	} `json:"fade"`

	Major struct {
		Id   int    `json:"id"`
		Name string `json:"name"`
	} `json:"major"`

	Artists []Artist `json:"artists"`

	Albums []Album `json:"albums"`

	FileSize         int    `json:"fileSize"`
	StorageDir       string `json:"storageDir"`
	DurationMs       int    `json:"durationMs"`
	RememberPosition bool   `json:"rememberPosition"`
}

type TrackDownloadInfo

type TrackDownloadInfo struct {
	Codec           string `json:"codec"`
	Gain            bool   `json:"gain"`
	Preview         bool   `json:"preview"`
	DownloadInfoUrl string `json:"downloadInfoUrl"`
	Direct          bool   `json:"direct"`
	BbitrateInKbps  int    `json:"bitrateInKbps"`
}

type TrackLyrics

type TrackLyrics struct {
	DownloadUrl     string   `json:"downloadUrl"`
	LyricId         string   `json:"lyricId"`
	ExternalLyricId string   `json:"externalLyricId"`
	Writers         []string `json:"writers"`
	Major           struct {
		Id         int    `json:"id"`
		Name       string `json:"name"`
		PrettyName string `json:"prettyName"`
	} `json:"major"`
}

type UnauthorizedError

type UnauthorizedError struct {
	Timestamp time.Time   `json:"timestamp"`
	Path      string      `json:"path"`
	Status    float64     `json:"status"`
	Name      string      `json:"error"`
	Message   interface{} `json:"message"`
	RequestId string      `json:"requestId"`
}

func (UnauthorizedError) Error

func (e UnauthorizedError) Error() string

type UserStatus

type UserStatus struct {
	Account struct {
		Uid              uint64 `json:"uid"`
		DisplayName      string `json:"displayName"`
		FirstName        string `json:"firstName"`
		SecondName       string `json:"secondName"`
		FullName         string `json:"fullName"`
		Login            string `json:"login"`
		ServiceAvailable bool   `json:"serviceAvailable"`
	} `json:"account"`

	Permissions struct {
		Until  string   `json:"until"`
		Values []string `json:"values"`
	} `json:"permissions"`

	Plus struct {
		HasPlus             bool `json:"hasPlus"`
		IsTutorialCompleted bool `json:"isTutorialCompleted"`
	} `json:"plus"`
}

type YaMusicClient

type YaMusicClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(name, token string) (*YaMusicClient, error)

func (*YaMusicClient) AddToPlaylist

func (client *YaMusicClient) AddToPlaylist(kind uint64, revision, pos int, trackId string) (playlist Playlist, err error)

func (*YaMusicClient) Album

func (client *YaMusicClient) Album(albumId uint64, withTracks bool) (album Album, err error)

func (*YaMusicClient) ArtistPopularTracks

func (client *YaMusicClient) ArtistPopularTracks(artistId uint64) (tracks ArtistTracks, err error)

func (*YaMusicClient) ArtistTracks

func (client *YaMusicClient) ArtistTracks(artistId uint64, page, pageSize int) (tracks ArtistTracks, err error)

func (*YaMusicClient) CreatePlaylist

func (client *YaMusicClient) CreatePlaylist(name string, public bool) (playlist Playlist, err error)

func (*YaMusicClient) DownloadTrack

func (client *YaMusicClient) DownloadTrack(dowInfo TrackDownloadInfo) (track io.ReadCloser, fileSize int64, err error)

func (*YaMusicClient) LikeTrack

func (client *YaMusicClient) LikeTrack(trackId string) (err error)

func (*YaMusicClient) LikedTracks

func (client *YaMusicClient) LikedTracks() (tracks []LikeTrackInfo, err error)

func (*YaMusicClient) ListPlaylists

func (client *YaMusicClient) ListPlaylists() (playlists []Playlist, err error)

func (*YaMusicClient) PlayTrack

func (client *YaMusicClient) PlayTrack(track *Track, fromCache bool) (err error)

func (*YaMusicClient) Playlist

func (client *YaMusicClient) Playlist(kind uint64) (playlist Playlist, err error)

func (*YaMusicClient) PlaylistTracks

func (client *YaMusicClient) PlaylistTracks(kind uint64, userId uint64, mixed bool) (tracks []Track, err error)

func (*YaMusicClient) RemoveFromPlaylist

func (client *YaMusicClient) RemoveFromPlaylist(kind uint64, revision, pos int) (playlist Playlist, err error)

func (*YaMusicClient) RemovePlaylist

func (client *YaMusicClient) RemovePlaylist(kind uint64) error

func (*YaMusicClient) RenamePlaylist

func (client *YaMusicClient) RenamePlaylist(kind uint64, newName string) (playlist Playlist, err error)

func (*YaMusicClient) Search

func (client *YaMusicClient) Search(request string, searchType SearchType) (results SearchResult, err error)

func (*YaMusicClient) SearchSuggest

func (client *YaMusicClient) SearchSuggest(part string) (suggestions SearchSuggest, err error)

func (*YaMusicClient) StationFeedback

func (client *YaMusicClient) StationFeedback(feedType string, stationId StationId, batchId, trackId string, playedSeconds int) (err error)

func (*YaMusicClient) StationTracks

func (client *YaMusicClient) StationTracks(id StationId, lastTrack *Track) (tracks StationTracks, err error)

func (*YaMusicClient) Stations

func (client *YaMusicClient) Stations(language string) (stations []StationDesc, err error)

func (*YaMusicClient) TrackDownloadInfo

func (client *YaMusicClient) TrackDownloadInfo(trackId string) (dowInfos []TrackDownloadInfo, err error)

func (*YaMusicClient) TrackLyricsRequest

func (client *YaMusicClient) TrackLyricsRequest(trackId string) (LRCLyrics []LyricPair, err error)

func (*YaMusicClient) Tracks

func (client *YaMusicClient) Tracks(trackIds []string) (tracks []Track, err error)

func (*YaMusicClient) UnlikeTrack

func (client *YaMusicClient) UnlikeTrack(trackId string) (err error)

Jump to

Keyboard shortcuts

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