UNPKG

@duell10111/youtubei.js

Version:

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

58 lines 2.86 kB
var _Playlist_page, _Playlist_actions, _Playlist_continuation; import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib"; import { Parser, PlaylistVideoListContinuation } from '../index.js'; import { InnertubeError } from '../../utils/Utils.js'; import { observe } from '../helpers.js'; import TwoColumn from '../classes/TwoColumn.js'; class Playlist { // #last_fetched_suggestions: ObservedArray<MusicResponsiveListItem> | null; // #suggestions_continuation: string | null; constructor(response, actions) { _Playlist_page.set(this, void 0); _Playlist_actions.set(this, void 0); _Playlist_continuation.set(this, void 0); __classPrivateFieldSet(this, _Playlist_actions, actions, "f"); __classPrivateFieldSet(this, _Playlist_page, Parser.parseResponse(response.data), "f"); __classPrivateFieldSet(this, _Playlist_continuation, null, "f"); const two_col = __classPrivateFieldGet(this, _Playlist_page, "f").contents_memo?.getType(TwoColumn)?.first(); if (two_col) { this.header = two_col.left_column ?? undefined; if (two_col.right_column) { __classPrivateFieldSet(this, _Playlist_continuation, two_col.right_column.continuation ?? null, "f"); this.contents = two_col.right_column.videos ?? null; } } if (__classPrivateFieldGet(this, _Playlist_page, "f").continuation_contents) { const data = __classPrivateFieldGet(this, _Playlist_page, "f").continuation_contents?.as(PlaylistVideoListContinuation); if (!data.contents) { throw new InnertubeError('No contents found in the response'); } this.contents = data.contents; __classPrivateFieldSet(this, _Playlist_continuation, data.continuation ?? null, "f"); } } /** * Retrieves playlist items continuation. */ async getContinuation() { if (!__classPrivateFieldGet(this, _Playlist_continuation, "f")) throw new InnertubeError('Continuation not found.'); const response = await __classPrivateFieldGet(this, _Playlist_actions, "f").execute('/browse', { client: 'TV', continuation: __classPrivateFieldGet(this, _Playlist_continuation, "f") }); return new Playlist(response, __classPrivateFieldGet(this, _Playlist_actions, "f")); } get page() { return __classPrivateFieldGet(this, _Playlist_page, "f"); } get items() { return this.contents || observe([]); } get has_continuation() { return !!__classPrivateFieldGet(this, _Playlist_continuation, "f"); } } _Playlist_page = new WeakMap(), _Playlist_actions = new WeakMap(), _Playlist_continuation = new WeakMap(); export default Playlist; //# sourceMappingURL=Playlist.js.map