ym-api
Version:
A Node.js wrapper for the Yandex.Music API (Unofficial) http://music.yandex.ru
476 lines (475 loc) • 12.7 kB
TypeScript
export declare type RequestHeaders = {
[key: string]: string;
};
export declare type RequestQuery = {
[key: string]: string;
};
export declare type RequestBodyData = {
[key: string]: string;
};
export declare type RequestConfig = {
scheme: string;
host: string;
port: number;
path?: string;
headers?: RequestHeaders;
query?: RequestQuery;
bodyData?: RequestBodyData;
};
export declare type Method = "get" | "post";
export declare type ObjectResponse = {
[key: string]: any;
};
export declare type StringResponse = string;
export declare type Response = ObjectResponse | StringResponse;
declare type PlusStatus = {
hasPlus: boolean;
isTutorialCompleted: boolean;
};
declare type Subscription = {
expires: string;
vendor: string;
vendorHelpUrl: string;
productId: string;
orderId: number;
finished: boolean;
};
declare type SubscriptionStatus = {
autoRenewable: Array<Subscription>;
nonAutoRenewableRemainder: {
[key: string]: any;
};
canStartTrial: boolean;
mcdonalds: boolean;
};
declare type Permissions = {
until: string;
values: Array<string>;
default: Array<string>;
};
declare type PassportPhone = {
phone: string;
};
declare type Account = {
now: string;
uid: number;
login: string;
region: number;
fullName: string;
secondName: string;
firstName: string;
displayName: string;
birthday: string;
serviceAvailable: boolean;
hostedUser: boolean;
"passport-phones": Array<PassportPhone>;
registeredAt: string;
};
export declare type GetAccountStatusResponse = {
account: Account;
permissions: Permissions;
subscription: SubscriptionStatus;
subeditor: boolean;
subeditorLevel: number;
plus: PlusStatus;
defaultEmail: string;
};
declare type GeneratedPlaylistType = "rewind20" | "playlistOfTheDay" | "missedLikes" | "origin" | "family" | "recentTracks" | "neverHeard" | "podcasts" | "kinopoisk" | string;
declare type GeneratedPlaylist = {
type: GeneratedPlaylistType;
ready: boolean;
notify: boolean;
data: Playlist;
};
declare type FeedDayEventTitle = {
type: string;
text: string;
};
declare type FeedDayEventAugmentedArtist = {
artist: Artist;
subscribed: true;
};
declare type FeedDayEventArtist = {
augmentedArtist: FeedDayEventAugmentedArtist;
playsDurationMillis: number;
};
declare type FeedDayEvent = {
id: string;
type: string;
typeForFrom: string;
title: Array<FeedDayEventTitle>;
artists?: Array<FeedDayEventArtist>;
likedTrack?: Track;
tracks?: Array<Track>;
radioIsAvailable?: boolean;
genre?: GenreId;
albums?: Array<Album>;
similarToGenre?: GenreId;
similarGenre?: GenreId;
similarToArtist?: Artist;
similarArtists?: Array<Artist>;
artist?: Artist;
socialTracks?: Array<Track>;
};
declare type FeedDayTrackToPlayWithAds = {
type: string;
track: Track;
};
declare type FeedDay = {
day: string;
events: Array<FeedDayEvent>;
tracksToPlay: Array<Track>;
tracksToPlayWithAds: Array<FeedDayTrackToPlayWithAds>;
};
export declare type GetFeedResponse = {
nextRevision: string;
canGetMoreEvents: boolean;
pumpkin: boolean;
isWizardPassed: boolean;
generatedPlaylists: Array<GeneratedPlaylist>;
headlines: Array<any>;
today: string;
days: Array<FeedDay>;
};
declare type Visibility = "public" | "private" | string;
declare type Sex = "male" | "female" | string;
declare type PlaylistOwner = {
uid: number;
login: string;
name: string;
verified: boolean;
sex: Sex;
};
declare type PlaylistTrack = {
id: number;
timestamp: string;
recent: boolean;
track: Track;
};
declare type PlaylistCoverType = "mosaic" | string;
declare type PlaylistCover = {
error?: string;
type?: PlaylistCoverType;
itemsUri?: Array<string>;
custom?: boolean;
};
export declare type Playlist = {
owner: PlaylistOwner;
playlistUuid: string;
available: boolean;
uid: number;
kind: number;
title: string;
revision: number;
snapshot: number;
trackCount: number;
visibility: Visibility;
collective: boolean;
created: string;
modified: string;
isBanner: boolean;
isPremiere: boolean;
durationMs: number;
cover: PlaylistCover;
ogImage: string;
tags: Array<any>;
prerolls: Array<any>;
lastOwnerPlaylists: Array<Playlist>;
tracks?: Array<PlaylistTrack>;
};
declare type GenreId = "all" | "pop" | "allrock" | "indie" | "metal" | "alternative" | "electronics" | "dance" | "rap" | "rnb" | "jazz" | "blues" | "reggae" | "ska" | "punk" | "folk" | "estrada" | "shanson" | "country" | "soundtrack" | "relax" | "children" | "naturesounds" | "bard" | "forchildren" | "fairytales" | "poemsforchildren" | "podcasts" | "classicalmusic" | "audiobooks" | "other" | string;
declare type RadioIcon = {
backgroundColor: string;
imageUrl: string;
};
declare type Genre = {
id: GenreId;
weight: number;
composerTop: boolean;
title: string;
fullTitle: string;
titles: {
[key: string]: {
title: string;
};
};
images: {
[key: string]: string;
};
showInMenu: boolean;
showInRegions?: Array<number>;
urlPart?: string;
color?: string;
radioIcon?: RadioIcon;
subGenres?: Array<Genre>;
};
export declare type GetGenresResponse = Array<Genre>;
export declare type SearchType = "artist" | "album" | "track" | "all";
export declare type ApiConfig = {
oauth: {
CLIENT_ID: string;
CLIENT_SECRET: string;
};
fake_device: {
DEVICE_ID: string;
UUID: string;
PACKAGE_NAME: string;
};
};
export declare type ApiInitConfig = {
access_token?: string;
uid?: number;
username?: string;
password?: string;
};
declare type ArtistCoverType = "from-artist-photos" | string;
declare type ArtistCover = {
type: ArtistCoverType;
prefix: string;
uri: string;
};
declare type ArtistCounts = {
tracks: number;
directAlbums: number;
alsoAlbums: number;
alsoTracks: number;
};
declare type Region = "RUSSIA_PREMIUM" | "RUSSIA" | string;
declare type AlbumType = "compilation" | string;
declare type TrackPosition = {
volume: number;
index: number;
};
declare type Label = {
id: number;
name: string;
} | string;
export declare type AlbumVolume = Array<Track>;
export declare type Album = {
id: number;
storageDir: string;
coverUri: string;
trackCount: number;
available: boolean;
availableForPremiumUsers: boolean;
title: string;
genre: GenreId;
type: AlbumType;
trackPosition: TrackPosition;
artists: Array<Artist>;
availableRegions: Array<Region>;
labels: Array<Label>;
volumes?: Array<AlbumVolume>;
year?: number;
originalReleaseYear: number;
likesCount?: number;
regions?: Array<Region>;
};
export declare type AlbumWithTracks = Required<Album>;
declare type TrackMajor = {
id: number;
name: string;
};
declare type TrackNormalization = {
gain: number;
peak: number;
};
export declare type Track = {
id: number;
available: boolean;
availableAsRbt: boolean;
availableForPremiumUsers: boolean;
availableFullWithoutPermission?: boolean;
lyricsAvailable: boolean;
rememberPosition: boolean;
coverUri: string;
durationMs: number;
explicit: boolean;
title: string;
albums: Array<Album>;
artists: Array<Artist>;
regions: Array<Region>;
major?: TrackMajor;
storageDir?: string;
fileSize?: number;
normalization?: TrackNormalization;
previewDurationMs?: number;
type?: string;
ogImage?: string;
};
export declare type Artist = {
id: number;
name: string;
composer: boolean;
various: boolean;
ticketsAvailable: boolean;
cover: ArtistCover;
counts: ArtistCounts;
genres: Array<Genre>;
popularTracks: Array<Track>;
regions: Array<Region>;
albums?: Array<Album>;
alsoAlbums?: Array<Album>;
similarArtists?: Array<Artist>;
};
export declare type FilledArtist = {
artist: Artist;
albums: Array<Album>;
alsoAlbums: Array<Album>;
similarArtists: Array<Artist>;
};
export declare type SearchResponse = {
type: string;
page: number;
perPage: number;
text: string;
searchRequestId: string;
artists?: {
total: number;
perPage: number;
order: number;
results: Array<Artist>;
};
albums?: {
total: number;
perPage: number;
order: number;
results: Array<Album>;
};
tracks?: {
total: number;
perPage: number;
order: number;
results: Array<Track>;
};
best?: {
type: 'track' | 'artist' | 'album' | 'playlist' | 'video';
results: Array<Track | Artist | Album | Playlist | Video>;
misspellCorrected: boolean;
nocorrect: boolean;
};
};
export declare type ArtistTracksResponse = {
pager: Pager;
tracks: Array<Track>;
};
export declare type SearchAllResponse = Required<SearchResponse>;
export declare type SearchArtistsResponse = Required<Omit<Omit<SearchResponse, "albums">, "tracks">>;
export declare type SearchTracksResponse = Required<Omit<Omit<SearchResponse, "artists">, "albums">>;
export declare type SearchAlbumsResponse = Required<Omit<Omit<SearchResponse, "artists">, "tracks">>;
export declare type GetTrackResponse = Array<Track>;
declare type Language = "en" | string;
declare type Lirics = {
id: number;
lyrics: string;
fullLyrics: string;
hasRights: boolean;
showTranslation: boolean;
textLanguage: Language;
};
declare type VideoProvider = "youtube" | string;
declare type Video = {
title: string;
cover: string;
url: string;
provider: VideoProvider;
providerVideoId: string;
embed: string;
};
export declare type GetTrackSupplementResponse = {
id: number;
lyrics: Lirics;
videos: Array<Video>;
};
declare type AudioCodec = "mp3" | "aac" | string;
export declare type DownloadInfo = {
codec: AudioCodec;
gain: boolean;
preview: boolean;
downloadInfoUrl: string;
direct: boolean;
bitrateInKbps: number;
};
export declare type GetTrackDownloadInfoResponse = Array<DownloadInfo>;
export declare type InitResponse = {
access_token: string;
uid: number;
};
export declare type ArtistId = number;
export declare type ArtistUrl = string;
export declare type AlbumId = number;
export declare type AlbumUrl = string;
export declare type TrackId = number;
export declare type TrackUrl = string;
export declare type PlaylistId = number;
export declare type PlaylistUrl = string;
export declare type UserId = number;
export declare type UserName = string;
export interface UrlExtractorInterface {
extractTrackId(url: string): number;
extractAlbumId(url: string): number;
extractArtistId(url: string): number;
extractPlaylistId(url: string): {
id: number;
user: string;
};
}
export interface RequestInterface {
setPath(path: string): RequestInterface;
getHeaders(): RequestHeaders;
setHeaders(headers: RequestHeaders): RequestInterface;
addHeaders(headers: RequestHeaders): RequestInterface;
getQuery(): RequestQuery;
setQuery(query: RequestQuery): RequestInterface;
addQuery(query: RequestQuery): RequestInterface;
getQueryAsString(): string;
getBodyData(): RequestBodyData;
getBodyDataString(): string;
setBodyData(bodyData: RequestBodyData): RequestInterface;
addBodyData(bodyData: RequestBodyData): RequestInterface;
getURI(): string;
getURL(): string;
}
export interface HttpClientInterface {
get(request: RequestInterface): Promise<Response>;
post(request: RequestInterface): Promise<Response>;
}
export declare type ApiUser = {
username: string;
password: string;
token: string;
uid: number;
};
export declare enum DownloadTrackQuality {
High = "high",
Low = "low"
}
export declare enum DownloadTrackCodec {
MP3 = "mp3",
AAC = "aac"
}
export declare type SearchOptions = {
type?: SearchType;
page?: number;
nococrrect?: boolean;
pageSize?: number;
};
export declare type ConcreteSearchOptions = Omit<SearchOptions, "type">;
export declare type Pager = {
page: number;
perPage: number;
total: number;
};
declare type TrackMeta = {
id: string;
albumId: string;
timestamp: string;
};
export declare type LikedTracks = {
library: {
revision: number;
uid: number;
tracks: TrackMeta[];
};
};
export {};