UNPKG

@duell10111/youtubei.js

Version:

A JavaScript client for YouTube's private API, known as InnerTube.

52 lines 2.59 kB
var _PlaylistsFeed_page, _PlaylistsFeed_actions, _PlaylistsFeed_continuation; import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib"; import { GridContinuation, Parser } from '../index.js'; import { observe } from '../helpers.js'; import { InnertubeError } from '../../utils/Utils.js'; import Grid from '../classes/Grid.js'; class PlaylistsFeed { constructor(response, actions) { _PlaylistsFeed_page.set(this, void 0); _PlaylistsFeed_actions.set(this, void 0); _PlaylistsFeed_continuation.set(this, void 0); __classPrivateFieldSet(this, _PlaylistsFeed_actions, actions, "f"); __classPrivateFieldSet(this, _PlaylistsFeed_page, Parser.parseResponse(response.data), "f"); const grid = __classPrivateFieldGet(this, _PlaylistsFeed_page, "f").contents_memo?.getType(Grid)?.first(); if (grid) { this.contents = grid.contents; __classPrivateFieldSet(this, _PlaylistsFeed_continuation, grid.continuation ?? undefined, "f"); } if (__classPrivateFieldGet(this, _PlaylistsFeed_page, "f").continuation_contents) { const data = __classPrivateFieldGet(this, _PlaylistsFeed_page, "f").continuation_contents?.as(GridContinuation); if (!data.contents) { throw new InnertubeError('No contents found in the response'); } this.contents = data.contents; __classPrivateFieldSet(this, _PlaylistsFeed_continuation, data.continuation ?? undefined, "f"); } } /** * Retrieves playlist items continuation. */ async getContinuation() { if (!__classPrivateFieldGet(this, _PlaylistsFeed_continuation, "f")) throw new InnertubeError('Continuation not found.'); const response = await __classPrivateFieldGet(this, _PlaylistsFeed_actions, "f").execute('/browse', { client: 'TV', continuation: __classPrivateFieldGet(this, _PlaylistsFeed_continuation, "f") }); return new PlaylistsFeed(response, __classPrivateFieldGet(this, _PlaylistsFeed_actions, "f")); } get page() { return __classPrivateFieldGet(this, _PlaylistsFeed_page, "f"); } get items() { return this.contents || observe([]); } get has_continuation() { return !!__classPrivateFieldGet(this, _PlaylistsFeed_continuation, "f"); } } _PlaylistsFeed_page = new WeakMap(), _PlaylistsFeed_actions = new WeakMap(), _PlaylistsFeed_continuation = new WeakMap(); export default PlaylistsFeed; //# sourceMappingURL=PlaylistsFeed.js.map