yandex-music
Version:
Creative and progressive Node.js framework for applications that interact with yandex music
68 lines (67 loc) • 2.9 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Artist = void 0;
const log_decorator_1 = require("../decorators/log.decorator");
const utils_1 = require("../utils");
class Artist {
constructor(client) {
this.client = client;
}
/**
* Getting the artist/artists.
* @param {List} ids The unique identifier of the artist or artists.
* @returns Artist or Artists.
*/
async get(ids) {
const [url, params] = (0, utils_1.list)("artist", ids);
return await this.client.request.get(url, params);
}
/**
* Getting information about the artist.
* @param {Union} id The unique identifier of the artist.
* @returns Information about the artist.
*/
async info(id) {
return await this.client.request.get(`/artists/${id}/brief-info`);
}
/**
* Getting artist albums.
* @param {Union} id The unique identifier of the artist.
* @param {number} page Page number.
* @param {number} page_size The number of albums per page.
* @param {string} sort_by Parameter for sorting.
* @returns Artist's Album list page.
*/
async albums(id, page = 0, page_size = 0, sort_by = "year") {
const params = { page, page_size, sort_by };
return await this.client.request.get(`/artists/${id}/direct-albums`, params);
}
}
__decorate([
(0, log_decorator_1.log)(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", Promise)
], Artist.prototype, "get", null);
__decorate([
(0, log_decorator_1.log)(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], Artist.prototype, "info", null);
__decorate([
(0, log_decorator_1.log)(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Number, Number, String]),
__metadata("design:returntype", Promise)
], Artist.prototype, "albums", null);
exports.Artist = Artist;