Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add archived posts and stories feeds #1285

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ http://open.igpapi.com/

It uses OpenAPI specification, so you can generate SDK for any programming language in several minutes.

You can use it right in the browser without need to have a server.
You can use it right in the browser without need to have a server.

You can even use it in React Native. Yes, without bridges.

It's free for a while, until it's stable. The function set is poor now, because, to be honest i'm not sure if there's a demand for it.
So if you would like to use it, have feature-requests or bug reports - please [contact me](https://t.me/bowzee) - i'll implement things you need very fast.
So if you would like to use it, have feature-requests or bug reports - please [contact me](https://t.me/bowzee) - i'll implement things you need very fast.

# Table of Contents

Expand Down
42 changes: 26 additions & 16 deletions src/core/feed.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import {
AccountFollowersFeed,
AccountFollowingFeed,
BestiesFeed,
ArchivedStoriesFeed,
ArchivedPostsFeed,
BlockedUsersFeed,
DirectInboxFeed,
DirectPendingInboxFeed,
DirectThreadFeed,
DiscoverFeed,
PostsInsightsFeed,
IgtvBrowseFeed,
IgtvChannelFeed,
LikedFeed,
LocationFeed,
MediaCommentsFeed,
MusicGenreFeed,
Expand All @@ -17,6 +21,7 @@ import {
MusicTrendingFeed,
NewsFeed,
PendingFriendshipsFeed,
PostsInsightsFeed,
ReelsMediaFeed,
ReelsTrayFeed,
SavedFeed,
Expand All @@ -26,28 +31,25 @@ import {
TimelineFeed,
UserFeed,
UsertagsFeed,
IgtvBrowseFeed,
IgtvChannelFeed,
LikedFeed,
} from '../feeds';
import { DirectInboxFeedResponseThreadsItem } from '../responses';
import { plainToClassFromExist } from 'class-transformer';
import * as Chance from 'chance';
import { PostsInsightsFeedOptions, TimelineFeedReason, IgAppModule } from '../types';
import { UserStoryFeed } from '../feeds/user-story.feed';
import { ListReelMediaViewerFeed } from '../feeds/list-reel-media-viewer.feed';
import { MediaInlineChildCommentsFeed } from '../feeds/media.inline-child-comments.feed';
import { MediaStickerResponsesFeed } from '../feeds/media.sticker-responses.feed';
import {
StorySliderVotersFeedResponseResponseRootObject,
StorySliderVotersFeedResponseResponseVotersItem,
DirectInboxFeedResponseThreadsItem,
StoryPollVotersFeedResponseRootObject,
StoryPollVotersFeedResponseVotersItem,
StoryQuestionResponsesFeedResponseRespondersItem,
StoryQuestionResponsesFeedResponseRootObject,
StoryQuizParticipantsFeedResponseParticipantsItem,
StoryQuizParticipantsFeedResponseRootObject,
StoryPollVotersFeedResponseRootObject,
StoryPollVotersFeedResponseVotersItem,
StorySliderVotersFeedResponseResponseRootObject,
StorySliderVotersFeedResponseResponseVotersItem,
} from '../responses';
import { plainToClassFromExist } from 'class-transformer';
import * as Chance from 'chance';
import { IgAppModule, PostsInsightsFeedOptions, TimelineFeedReason } from '../types';
import { UserStoryFeed } from '../feeds/user-story.feed';
import { ListReelMediaViewerFeed } from '../feeds/list-reel-media-viewer.feed';
import { MediaInlineChildCommentsFeed } from '../feeds/media.inline-child-comments.feed';
import { MediaStickerResponsesFeed } from '../feeds/media.sticker-responses.feed';

export class FeedFactory {
constructor(private client: IgApiClient) {}
Expand Down Expand Up @@ -109,6 +111,14 @@ export class FeedFactory {
return feed;
}

public archivedStories(): any {
return new ArchivedStoriesFeed(this.client);
}

public archivedPosts(): any {
return new ArchivedPostsFeed(this.client);
}

public tag(tag: string): TagFeed {
const feed = new TagFeed(this.client);
feed.tag = tag;
Expand Down
1 change: 1 addition & 0 deletions src/core/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export class Request {
try {
return await retry(async () => request(options), this.attemptOptions);
} catch (err) {
this.error$.next(err);
throw new IgNetworkError(err);
}
}
Expand Down
30 changes: 30 additions & 0 deletions src/feeds/archived-posts.feed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Expose } from 'class-transformer';
import { Feed } from '../core/feed';
//import { ArchivedFeedResponseRootObject, ArchivedFeedResponseMedia } from '../responses'; // new
//import { SavedFeedResponseRootObject, SavedFeedResponseMedia } from '../responses';

export class ArchivedPostsFeed extends Feed<any, any> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Feed should have proper types, not <any, any>.

@Expose()
private nextMaxId: string;

set state(body: any) {
this.moreAvailable = body.more_available;
this.nextMaxId = body.next_max_id;
}

async request(): Promise<any> {
const { body } = await this.client.request.send({
url: '/api/v1/feed/only_me_feed/',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file should be named only-me.feed.ts and thus the class OnlyMeFeed.

qs: {
max_id: this.nextMaxId,
},
});
this.state = body;
return body;
}

async items(): Promise<any[]> {
const { items } = await this.request();
return items;
}
}
30 changes: 30 additions & 0 deletions src/feeds/archived-stories.feed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Expose } from 'class-transformer';
import { Feed } from '../core/feed';
//import { ArchivedFeedResponseRootObject, ArchivedFeedResponseMedia } from '../responses'; // new
//import { SavedFeedResponseRootObject, SavedFeedResponseMedia } from '../responses';

export class ArchivedStoriesFeed extends Feed<any, any> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add types (see comment above)

@Expose()
private nextMaxId: string;

set state(body: any) {
this.moreAvailable = body.more_available;
this.nextMaxId = body.next_max_id;
}

async request(): Promise<any> {
const { body } = await this.client.request.send({
url: '/api/v1/archive/reel/day_shells/',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename file to day-shells.feed.ts and class to DayShellsFeed.

qs: {
max_id: this.nextMaxId,
},
});
this.state = body;
return body;
}

async items(): Promise<any[]> {
const { items } = await this.request();
return items;
}
}
2 changes: 2 additions & 0 deletions src/feeds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ export * from './stories-insights.feed';
export * from './igtv.browse.feed';
export * from './igtv.channel.feed';
export * from './liked.feed';
export * from './archived-stories.feed';
export * from './archived-posts.feed';
202 changes: 202 additions & 0 deletions src/responses/archived.feed.response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
export interface ArchivedFeedResponseRootObject {
items: ArchivedFeedResponseItemsItem[];
num_results: number;
more_available: boolean;
auto_load_more_enabled: boolean;
status: string;
next_max_id: string;
}
export interface ArchivedFeedResponseItemsItem {
media: ArchivedFeedResponseMedia;
}
export interface ArchivedFeedResponseMedia {
taken_at: number;
pk: string;
id: string;
device_timestamp: string | number;
media_type: number;
code: string;
client_cache_key: string;
filter_type: number;
image_versions2?: ArchivedFeedResponseImage_versions2;
original_width?: number;
original_height?: number;
user: ArchivedFeedResponseUser;
can_viewer_reshare: boolean;
caption_is_edited: boolean;
is_external_share_disabled?: boolean;
comment_likes_enabled: boolean;
comment_threading_enabled: boolean;
has_more_comments: boolean;
next_max_id: string;
max_num_visible_preview_comments: number;
preview_comments: ArchivedFeedResponsePreviewCommentsItem[];
can_view_more_preview_comments: boolean;
comment_count: number;
inline_composer_display_condition: string;
inline_composer_imp_trigger_time: number;
like_count: number;
has_liked: boolean;
photo_of_you: boolean;
product_tags?: ArchivedFeedResponseProduct_tags;
can_see_insights_as_brand?: boolean;
caption: ArchivedFeedResponseCaption;
can_viewer_save: boolean;
has_viewer_saved: boolean;
saved_collection_ids: any[];
organic_tracking_token: string;
usertags?: ArchivedFeedResponseUsertags;
is_dash_eligible?: number;
video_dash_manifest?: string;
video_codec?: string;
number_of_qualities?: number;
video_versions?: ArchivedFeedResponseVideoVersionsItem[];
has_audio?: boolean;
video_duration?: number;
view_count?: number;
carousel_media_count?: number;
carousel_media?: ArchivedFeedResponseCarouselMediaItem[];
}
export interface ArchivedFeedResponseImage_versions2 {
candidates: ArchivedFeedResponseCandidatesItem[];
}
export interface ArchivedFeedResponseCandidatesItem {
width: number;
height: number;
url: string;
estimated_scans_sizes?: number[];
}
export interface ArchivedFeedResponseUser {
pk: number;
username: string;
full_name: string;
is_private: boolean;
profile_pic_url: string;
friendship_status?: ArchivedFeedResponseFriendship_status;
is_verified: boolean;
has_anonymous_profile_picture?: boolean;
is_unpublished?: boolean;
is_favorite?: boolean;
show_shoppable_feed?: boolean;
shoppable_posts_count?: number;
can_be_reported_as_fraud?: boolean;
latest_reel_media?: number;
profile_pic_id?: string;
}
export interface ArchivedFeedResponseFriendship_status {
following: boolean;
outgoing_request: boolean;
is_bestie: boolean;
is_restricted: boolean;
}
export interface ArchivedFeedResponsePreviewCommentsItem {
pk: string;
user_id: number;
text: string;
type: number;
created_at: number;
created_at_utc: number;
content_type: string;
status: string;
bit_flags: number;
user: ArchivedFeedResponseUser;
did_report_as_spam: boolean;
share_enabled: boolean;
media_id: string;
has_liked_comment: boolean;
comment_like_count: number;
has_translation?: boolean;
parent_comment_id?: string;
}
export interface ArchivedFeedResponseProduct_tags {
in: ArchivedFeedResponseInItem[];
}
export interface ArchivedFeedResponseInItem {
product?: ArchivedFeedResponseProduct;
position: string[] | number[];
user?: ArchivedFeedResponseUser;
start_time_in_video_in_sec?: null;
duration_in_video_in_sec?: null;
}
export interface ArchivedFeedResponseProduct {
name: string;
price: string;
current_price: string;
full_price: string;
product_id: string;
merchant: ArchivedFeedResponseMerchant;
description: string;
retailer_id: string;
has_viewer_saved: boolean;
main_image: ArchivedFeedResponseMain_image;
thumbnail_image: ArchivedFeedResponseThumbnail_image;
review_status: string;
external_url: string;
checkout_style: string;
can_share_to_story: boolean;
full_price_stripped: string;
current_price_stripped: string;
variant_values?: ArchivedFeedResponseVariantValuesItem[];
}
export interface ArchivedFeedResponseMerchant {
pk: number;
username: string;
profile_pic_url: string;
}
export interface ArchivedFeedResponseMain_image {
image_versions2: ArchivedFeedResponseImage_versions2;
preview: null;
}
export interface ArchivedFeedResponseThumbnail_image {
image_versions2: ArchivedFeedResponseImage_versions2;
preview: null;
}
export interface ArchivedFeedResponseVariantValuesItem {
id: string;
value: string;
name: string;
is_preselected: boolean;
visual_style: string;
}
export interface ArchivedFeedResponseCaption {
pk: string;
user_id: number;
text: string;
type: number;
created_at: number;
created_at_utc: number;
content_type: string;
status: string;
bit_flags: number;
user: ArchivedFeedResponseUser;
did_report_as_spam: boolean;
share_enabled: boolean;
media_id: string;
has_translation?: boolean;
}
export interface ArchivedFeedResponseUsertags {
in: ArchivedFeedResponseInItem[];
}
export interface ArchivedFeedResponseVideoVersionsItem {
type: number;
width: number;
height: number;
url: string;
id: string;
}
export interface ArchivedFeedResponseCarouselMediaItem {
id: string;
media_type: number;
image_versions2: ArchivedFeedResponseImage_versions2;
original_width: number;
original_height: number;
pk: string;
carousel_parent_id: string;
usertags: ArchivedFeedResponseUsertags;
video_versions?: ArchivedFeedResponseVideoVersionsItem[];
video_duration?: number;
is_dash_eligible?: number;
video_dash_manifest?: string;
video_codec?: string;
number_of_qualities?: number;
}
1 change: 1 addition & 0 deletions src/responses/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export * from './media.repository.configure.response';
export * from './media.repository.configure-sidecar.response';
export * from './media.repository.configure-video.response';
export * from './saved.feed.response';
export * from './archived.feed.response';
export * from './status.response';
export * from './reels-tray.feed.response';
export * from './music.repository.moods.response';
Expand Down