mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-17 11:32:27 +00:00
34 lines
945 B
TypeScript
34 lines
945 B
TypeScript
import { YTNode } from '../../helpers.js';
|
|
import type { AddToPlaylistServiceRequest, IEndpoint, RawNode } from '../../index.js';
|
|
|
|
export default class AddToPlaylistServiceEndpoint extends YTNode implements IEndpoint<AddToPlaylistServiceRequest> {
|
|
static type = 'AddToPlaylistServiceEndpoint';
|
|
|
|
#API_PATH = 'playlist/get_add_to_playlist';
|
|
#data: RawNode;
|
|
|
|
constructor(data: RawNode) {
|
|
super();
|
|
this.#data = data;
|
|
}
|
|
|
|
public getApiPath(): string {
|
|
return this.#API_PATH;
|
|
}
|
|
|
|
public buildRequest(): AddToPlaylistServiceRequest {
|
|
const request: AddToPlaylistServiceRequest = {};
|
|
|
|
request.videoIds = this.#data.videoIds ? this.#data.videoIds : [ this.#data.videoId ];
|
|
|
|
if (this.#data.playlistId)
|
|
request.playlistId = this.#data.playlistId;
|
|
|
|
if (this.#data.params)
|
|
request.params = this.#data.params;
|
|
|
|
request.excludeWatchLater = !!this.#data.excludeWatchLater;
|
|
|
|
return request;
|
|
}
|
|
} |