diff --git a/src/core/endpoints/PlayerEndpoint.ts b/src/core/endpoints/PlayerEndpoint.ts index a25b3123e..1c4c5152b 100644 --- a/src/core/endpoints/PlayerEndpoint.ts +++ b/src/core/endpoints/PlayerEndpoint.ts @@ -8,7 +8,7 @@ export const PATH = '/player'; * @returns The payload. */ export function build(opts: PlayerEndpointOptions): IPlayerRequest { - return { + const payload: IPlayerRequest = { playbackContext: { contentPlaybackContext: { vis: 0, @@ -33,14 +33,22 @@ export function build(opts: PlayerEndpointOptions): IPlayerRequest { }, racyCheckOk: true, contentCheckOk: true, - videoId: opts.video_id, - ...{ - client: opts.client, - playlistId: opts.playlist_id, - params: opts.params, - serviceIntegrityDimensions: { - poToken: opts.po_token || '' - } - } + videoId: opts.video_id }; + + if (opts.client) + payload.client = opts.client; + + if (opts.playlist_id) + payload.playlistId = opts.playlist_id; + + if (opts.params) + payload.params = opts.params; + + if (opts.po_token) + payload.serviceIntegrityDimensions = { + poToken: opts.po_token + }; + + return payload; } \ No newline at end of file