@duell10111/youtubei.js
Version:
A JavaScript client for YouTube's private API, known as InnerTube.
43 lines • 2.34 kB
JavaScript
var _HomeFeed_page, _HomeFeed_actions, _HomeFeed_continuation;
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
import SectionList from '../classes/SectionList.js';
import { InnertubeError } from '../../utils/Utils.js';
import { Parser, SectionListContinuation } from '../index.js';
class HomeFeed {
constructor(response, actions) {
_HomeFeed_page.set(this, void 0);
_HomeFeed_actions.set(this, void 0);
_HomeFeed_continuation.set(this, void 0);
__classPrivateFieldSet(this, _HomeFeed_actions, actions, "f");
__classPrivateFieldSet(this, _HomeFeed_page, Parser.parseResponse(response.data), "f");
const sectionList = __classPrivateFieldGet(this, _HomeFeed_page, "f").contents_memo?.getType(SectionList).firstOfType(SectionList);
this.sections = sectionList?.contents;
__classPrivateFieldSet(this, _HomeFeed_continuation, sectionList?.continuation, "f");
if (!sectionList) {
if (!__classPrivateFieldGet(this, _HomeFeed_page, "f").continuation_contents) {
throw new InnertubeError('Continuation did not have any content.');
}
const sectionListContinuation = __classPrivateFieldGet(this, _HomeFeed_page, "f").continuation_contents.as(SectionListContinuation);
__classPrivateFieldSet(this, _HomeFeed_continuation, sectionListContinuation.continuation, "f");
this.sections = sectionListContinuation.contents ?? undefined;
}
}
/**
* Retrieves home feed continuation.
*/
async getContinuation() {
if (!__classPrivateFieldGet(this, _HomeFeed_continuation, "f"))
throw new InnertubeError('Continuation not found.');
const response = await __classPrivateFieldGet(this, _HomeFeed_actions, "f").execute('/browse', {
client: 'TV',
continuation: __classPrivateFieldGet(this, _HomeFeed_continuation, "f")
});
return new HomeFeed(response, __classPrivateFieldGet(this, _HomeFeed_actions, "f"));
}
get has_continuation() {
return !!__classPrivateFieldGet(this, _HomeFeed_continuation, "f");
}
}
_HomeFeed_page = new WeakMap(), _HomeFeed_actions = new WeakMap(), _HomeFeed_continuation = new WeakMap();
export default HomeFeed;
//# sourceMappingURL=HomeFeed.js.map