forked from dilame/instagram-private-api
-
Notifications
You must be signed in to change notification settings - Fork 9
/
igtv.browse.feed.ts
31 lines (26 loc) · 999 Bytes
/
igtv.browse.feed.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Feed } from '../core/feed';
import { Expose } from 'class-transformer';
import { IgtvBrowseFeedResponseBrowseItemsItem, IgtvBrowseFeedResponseRootObject } from '../responses';
export class IgtvBrowseFeed extends Feed<IgtvBrowseFeedResponseRootObject, IgtvBrowseFeedResponseBrowseItemsItem> {
isPrefetch: boolean = false;
@Expose()
private maxId: string;
async items(): Promise<IgtvBrowseFeedResponseBrowseItemsItem[]> {
const req = await this.request();
return req.browse_items;
}
async request(): Promise<IgtvBrowseFeedResponseRootObject> {
const { body } = await this.client.request.send({
url: `/api/v1/igtv/${this.isPrefetch ? 'browse_feed' : 'non_prefetch_browse_feed'}/`,
qs: {
...(this.isPrefetch ? { prefetch: 1 } : { max_id: this.maxId }),
},
});
this.state = body;
return body;
}
protected set state(response: any) {
this.maxId = response.max_id;
this.moreAvailable = !!response.more_available;
}
}