mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-04 12:47:04 +00:00
refactor(parser)!: Implement endpoint/command parsers (#812)
This commit is contained in:
49
src/parser/classes/endpoints/ReelWatchEndpoint.ts
Normal file
49
src/parser/classes/endpoints/ReelWatchEndpoint.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { IEndpoint, RawNode, ReelWatchRequest } from '../../index.js';
|
||||
|
||||
export default class ReelWatchEndpoint extends YTNode implements IEndpoint<ReelWatchRequest> {
|
||||
static type = 'ReelWatchEndpoint';
|
||||
|
||||
#API_PATH = 'reel/reel_item_watch';
|
||||
#data: RawNode;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.#data = data;
|
||||
}
|
||||
|
||||
public getApiPath(): string {
|
||||
return this.#API_PATH;
|
||||
}
|
||||
|
||||
public buildRequest(): ReelWatchRequest {
|
||||
const request: ReelWatchRequest = {};
|
||||
|
||||
if (this.#data.videoId) {
|
||||
request.playerRequest = {
|
||||
videoId: this.#data.videoId
|
||||
};
|
||||
}
|
||||
|
||||
if (request.playerRequest) {
|
||||
if (this.#data.playerParams)
|
||||
request.playerRequest.params = this.#data.playerParams;
|
||||
|
||||
if (this.#data.racyCheckOk)
|
||||
request.playerRequest.racyCheckOk = !!this.#data.racyCheckOk;
|
||||
|
||||
if (this.#data.contentCheckOk)
|
||||
request.playerRequest.contentCheckOk = !!this.#data.contentCheckOk;
|
||||
}
|
||||
|
||||
if (this.#data.params)
|
||||
request.params = this.#data.params;
|
||||
|
||||
if (this.#data.inputType)
|
||||
request.inputType = this.#data.inputType;
|
||||
|
||||
request.disablePlayerResponse = !!this.#data.disablePlayerResponse;
|
||||
|
||||
return request;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user