From f1b416f002512fe9b46a38745d2fa703f2cfeec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Tue, 28 Feb 2023 13:20:26 +0000 Subject: [PATCH 01/11] added saved collections --- src/core/feed.factory.ts | 5 ++ src/feeds/index.ts | 1 + src/feeds/saved-collections.feed.ts | 31 +++++++++ src/responses/index.ts | 1 + .../saved-collections.feed.response.ts | 64 +++++++++++++++++++ 5 files changed, 102 insertions(+) create mode 100644 src/feeds/saved-collections.feed.ts create mode 100644 src/responses/saved-collections.feed.response.ts diff --git a/src/core/feed.factory.ts b/src/core/feed.factory.ts index 0ac26f779..6eda513d9 100644 --- a/src/core/feed.factory.ts +++ b/src/core/feed.factory.ts @@ -20,6 +20,7 @@ import { ReelsMediaFeed, ReelsTrayFeed, SavedFeed, + SavedCollectionsFeed, StoriesInsightsFeed, TagFeed, TagsFeed, @@ -219,6 +220,10 @@ export class FeedFactory { return new SavedFeed(this.client); } + public savedCollections(): SavedCollectionsFeed { + return new SavedCollectionsFeed(this.client); + } + public listReelMediaViewers(mediaId: string): ListReelMediaViewerFeed { return plainToClassFromExist(new ListReelMediaViewerFeed(this.client), { mediaId }); } diff --git a/src/feeds/index.ts b/src/feeds/index.ts index e70782366..f6d9f5881 100644 --- a/src/feeds/index.ts +++ b/src/feeds/index.ts @@ -11,6 +11,7 @@ export * from './media-comments.feed'; export * from './news.feed'; export * from './reels-media.feed'; export * from './saved.feed'; +export * from './saved-collections.feed'; export * from './tag.feed'; export * from './tags.feed'; export * from './timeline.feed'; diff --git a/src/feeds/saved-collections.feed.ts b/src/feeds/saved-collections.feed.ts new file mode 100644 index 000000000..225bed4f5 --- /dev/null +++ b/src/feeds/saved-collections.feed.ts @@ -0,0 +1,31 @@ +import { Expose } from 'class-transformer'; +import { Feed } from '../core/feed'; +import { SavedCollectionsFeedResponseRootObject, SavedCollectionsFeedResponse } from '../responses'; + +export class SavedCollectionsFeed extends Feed { + @Expose() + private nextMaxId: string; + + set state(body: SavedCollectionsFeedResponseRootObject) { + this.moreAvailable = body.more_available; + this.nextMaxId = body.next_max_id; + } + + async request(): Promise { + const { body } = await this.client.request.send({ + url: + 'api/v1/collections/list/?collection_types=%5B%22ALL_MEDIA_AUTO_COLLECTION%22%2C%22MEDIA%22%2C%22AUDIO_AUTO_COLLECTION%22%5D&include_public_only=0&get_cover_media_lists=true&max_id=QVFDV004M2FjcVQ0blNVVnp1dmZmM1JCMmZIb3REUnVyd0xsdGd0WVY5R25ILVBQMmRvWXV1Qk5DcF84cENNWGx1UThyb1NrVzZqeENVY2w1VXkwZlFhbg%3D%3D', + qs: { + max_id: this.nextMaxId, + include_igtv_preview: false, + }, + }); + this.state = body; + return body; + } + + async items(): Promise { + const { items } = await this.request(); + return items.map(i => i); + } +} diff --git a/src/responses/index.ts b/src/responses/index.ts index 1b43b076b..83098d2d7 100644 --- a/src/responses/index.ts +++ b/src/responses/index.ts @@ -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 './saved-collections.feed.response'; export * from './status.response'; export * from './reels-tray.feed.response'; export * from './music.repository.moods.response'; diff --git a/src/responses/saved-collections.feed.response.ts b/src/responses/saved-collections.feed.response.ts new file mode 100644 index 000000000..12f9721bb --- /dev/null +++ b/src/responses/saved-collections.feed.response.ts @@ -0,0 +1,64 @@ +export interface SavedCollectionsFeedResponseRootObject { + items: SavedCollectionsFeedResponse[]; + num_results: number; + more_available: boolean; + auto_load_more_enabled: boolean; + status: string; + next_max_id: string; +} + +export interface SavedCollectionsFeedResponse { + collection_id: string; + collection_name: string; + collection_type: string; + cover_media: CoverMedia; + cover_media_list: CoverMediaList[]; + collection_media_count: number; + viewer_access_level: string; +} + +export interface CoverMedia { + id: string; + media_type: number; + image_versions2: CoverMediaImageVersions2; + original_width: number; + original_height: number; +} + +export interface CoverMediaImageVersions2 { + candidates: Candidate[]; +} + +export interface Candidate { + width: number; + height: number; + url: string; + scans_profile: ScansProfile; + estimated_scans_sizes?: number[]; +} + +export enum ScansProfile { + E15 = 'e15', + E35 = 'e35', + Empty = '', +} + +export interface CoverMediaList { + id: string; + media_type: number; + image_versions2: CoverMediaListImageVersions2; + original_width: number; + original_height: number; +} + +export interface CoverMediaListImageVersions2 { + candidates: Candidate[]; + additional_candidates?: AdditionalCandidates; + smart_thumbnail_enabled?: boolean; +} + +export interface AdditionalCandidates { + igtv_first_frame: Candidate; + first_frame: Candidate; + smart_frame: null; +} From 1ca116baf98a0b4bf9c69b09b989ec3f0b16f2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Tue, 28 Feb 2023 13:27:23 +0000 Subject: [PATCH 02/11] formatted --- src/core/state.ts | 2 +- src/feeds/topical-explore.feed.ts | 5 +- src/repositories/account.repository.ts | 23 +- src/repositories/media.repository.ts | 17 +- src/responses/saved.feed.response.ts | 2 +- .../topical-explore.feed.response.ts | 606 +++++++++--------- 6 files changed, 329 insertions(+), 326 deletions(-) diff --git a/src/core/state.ts b/src/core/state.ts index a2daf9f9a..7f3fd0368 100644 --- a/src/core/state.ts +++ b/src/core/state.ts @@ -226,7 +226,7 @@ export class State { const obj = typeof state === 'string' ? JSON.parse(state) : state; if (typeof obj !== 'object') { State.stateDebug(`State deserialization failed, obj is of type ${typeof obj} (object expected)`); - throw new TypeError('State isn\'t an object or serialized JSON'); + throw new TypeError("State isn't an object or serialized JSON"); } State.stateDebug(`Deserializing ${Object.keys(obj).join(', ')}`); if (obj.constants) { diff --git a/src/feeds/topical-explore.feed.ts b/src/feeds/topical-explore.feed.ts index da23245fc..dccf3c05b 100644 --- a/src/feeds/topical-explore.feed.ts +++ b/src/feeds/topical-explore.feed.ts @@ -5,7 +5,10 @@ import * as Chance from 'chance'; import { TopicalExploreFeedResponseRootObject, TopicalExploreFeedResponseSectionalItemsItem } from '../responses'; const chance = new Chance(); -export class TopicalExploreFeed extends Feed { +export class TopicalExploreFeed extends Feed< + TopicalExploreFeedResponseRootObject, + TopicalExploreFeedResponseSectionalItemsItem +> { module: IgAppModule = 'explore_popular'; lat?: string | number; lng?: string | number; diff --git a/src/repositories/account.repository.ts b/src/repositories/account.repository.ts index 35e017f51..82a067aa5 100644 --- a/src/repositories/account.repository.ts +++ b/src/repositories/account.repository.ts @@ -26,7 +26,7 @@ export class AccountRepository extends Repository { if (!this.client.state.passwordEncryptionPubKey) { await this.client.qe.syncLoginExperiments(); } - const {encrypted, time} = this.encryptPassword(password); + const { encrypted, time } = this.encryptPassword(password); const response = await Bluebird.try(() => this.client.request.send({ method: 'POST', @@ -76,14 +76,17 @@ export class AccountRepository extends Repository { return `2${sum}`; } - public encryptPassword(password: string): { time: string, encrypted: string } { + public encryptPassword(password: string): { time: string; encrypted: string } { const randKey = crypto.randomBytes(32); const iv = crypto.randomBytes(12); - const rsaEncrypted = crypto.publicEncrypt({ - key: Buffer.from(this.client.state.passwordEncryptionPubKey, 'base64').toString(), - // @ts-ignore - padding: crypto.constants.RSA_PKCS1_PADDING, - }, randKey); + const rsaEncrypted = crypto.publicEncrypt( + { + key: Buffer.from(this.client.state.passwordEncryptionPubKey, 'base64').toString(), + // @ts-ignore + padding: crypto.constants.RSA_PKCS1_PADDING, + }, + randKey, + ); const cipher = crypto.createCipheriv('aes-256-gcm', randKey, iv); const time = Math.floor(Date.now() / 1000).toString(); cipher.setAAD(Buffer.from(time)); @@ -97,8 +100,10 @@ export class AccountRepository extends Repository { Buffer.from([1, this.client.state.passwordEncryptionKeyId]), iv, sizeBuffer, - rsaEncrypted, authTag, aesEncrypted]) - .toString('base64'), + rsaEncrypted, + authTag, + aesEncrypted, + ]).toString('base64'), }; } diff --git a/src/repositories/media.repository.ts b/src/repositories/media.repository.ts index 46ee8dc95..abcfd0afe 100644 --- a/src/repositories/media.repository.ts +++ b/src/repositories/media.repository.ts @@ -682,10 +682,10 @@ export class MediaRepository extends Repository { * save a media, or save it to collection if you pass the collection ids in array * @param {string} mediaId - The mediaId of the post * @param {string[]} [collection_ids] - Optional, The array of collection ids if you want to save the media to a specific collection - * Example: + * Example: * save("2524149952724070925_1829855275") save media * save("2524149952724070925_1829855275", ["17865977635619975"]) save media to 1 collection - * save("2524149952724070925_1829855275", ["17865977635619975", "17845997638619928"]) save media to 2 collection + * save("2524149952724070925_1829855275", ["17865977635619975", "17845997638619928"]) save media to 2 collection */ public async save(mediaId: string, collection_ids?: string[]) { const { body } = await this.client.request.send({ @@ -795,27 +795,24 @@ export class MediaRepository extends Repository { }); return body; } - - private async storyCountdownAction( - countdownId: string | number, - action: string, - ): Promise { + + private async storyCountdownAction(countdownId: string | number, action: string): Promise { const { body } = await this.client.request.send({ url: `/api/v1/media/${countdownId}/${action}/`, method: 'POST', form: this.client.request.sign({ _csrftoken: this.client.state.cookieCsrfToken, _uid: this.client.state.cookieUserId, - _uuid: this.client.state.uuid + _uuid: this.client.state.uuid, }), }); return body; } - + public async storyCountdownFollow(countdownId: string | number) { return this.storyCountdownAction(countdownId, 'follow_story_countdown'); } - + public async storyCountdownUnfollow(countdownId: string | number) { return this.storyCountdownAction(countdownId, 'unfollow_story_countdown'); } diff --git a/src/responses/saved.feed.response.ts b/src/responses/saved.feed.response.ts index d9fca8d97..d6a212888 100644 --- a/src/responses/saved.feed.response.ts +++ b/src/responses/saved.feed.response.ts @@ -211,4 +211,4 @@ export interface SavedFeedResponseLocation { lat: number; external_source: string; facebook_places_id: number; -} \ No newline at end of file +} diff --git a/src/responses/topical-explore.feed.response.ts b/src/responses/topical-explore.feed.response.ts index 1ec0c5f3b..1a5745538 100644 --- a/src/responses/topical-explore.feed.response.ts +++ b/src/responses/topical-explore.feed.response.ts @@ -1,379 +1,377 @@ export interface TopicalExploreFeedResponseRootObject { - sectional_items: TopicalExploreFeedResponseSectionalItemsItem[]; - rank_token: string; - auto_load_more_enabled: boolean; - more_available: boolean; - next_max_id: string; - max_id: string; - status: string; + sectional_items: TopicalExploreFeedResponseSectionalItemsItem[]; + rank_token: string; + auto_load_more_enabled: boolean; + more_available: boolean; + next_max_id: string; + max_id: string; + status: string; } export interface TopicalExploreFeedResponseSectionalItemsItem { - layout_type: string; - layout_content: TopicalExploreFeedResponseLayout_content; - feed_type: string; - explore_item_info: TopicalExploreFeedResponseExplore_item_info; + layout_type: string; + layout_content: TopicalExploreFeedResponseLayout_content; + feed_type: string; + explore_item_info: TopicalExploreFeedResponseExplore_item_info; } export interface TopicalExploreFeedResponseLayout_content { - two_by_two_item?: TopicalExploreFeedResponseTwo_by_two_item; - fill_items?: TopicalExploreFeedResponseFillItemsItem[]; - medias?: TopicalExploreFeedResponseMediasItem[]; + two_by_two_item?: TopicalExploreFeedResponseTwo_by_two_item; + fill_items?: TopicalExploreFeedResponseFillItemsItem[]; + medias?: TopicalExploreFeedResponseMediasItem[]; } export interface TopicalExploreFeedResponseTwo_by_two_item { - channel?: TopicalExploreFeedResponseChannel; - igtv?: TopicalExploreFeedResponseIgtv; + channel?: TopicalExploreFeedResponseChannel; + igtv?: TopicalExploreFeedResponseIgtv; } export interface TopicalExploreFeedResponseChannel { - title: string; - channel_id: string; - channel_type: string; - header: string; - context: string; - media: TopicalExploreFeedResponseMedia; - media_count: number; + title: string; + channel_id: string; + channel_type: string; + header: string; + context: string; + media: TopicalExploreFeedResponseMedia; + media_count: number; } export interface TopicalExploreFeedResponseMedia { - taken_at: number; - pk: string; - id: string; - device_timestamp: number | string; - media_type: number; - code: string; - client_cache_key: string; - filter_type: number; - location?: TopicalExploreFeedResponseLocation; - lat?: number; - lng?: number; - user: TopicalExploreFeedResponseUser; - can_viewer_reshare: boolean; - caption_is_edited: boolean; - comment_likes_enabled: boolean; - comment_threading_enabled: boolean; - has_more_comments: boolean; - max_num_visible_preview_comments: number; - preview_comments: any[]; - can_view_more_preview_comments: boolean; - comment_count: number; - image_versions2?: TopicalExploreFeedResponseImage_versions2; - original_width?: number; - original_height?: number; - like_count?: number; - has_liked?: boolean; - top_likers?: string[]; - photo_of_you: boolean; - can_see_insights_as_brand: boolean; - is_dash_eligible?: number; - video_dash_manifest?: string; - video_codec?: string; - number_of_qualities?: number; - video_versions?: TopicalExploreFeedResponseVideoVersionsItem[]; - has_audio?: boolean; - video_duration?: number; - view_count?: number; - caption: TopicalExploreFeedResponseCaption; - can_viewer_save: boolean; - organic_tracking_token: string; - sharing_friction_info: TopicalExploreFeedResponseSharing_friction_info; - is_in_profile_grid: boolean; - profile_grid_control_enabled: boolean; - is_shop_the_look_eligible: boolean; - deleted_reason: number; - explore_hide_comments?: boolean; - algorithm?: string; - connection_id?: string; - mezql_token: string; - explore_context?: string; - explore_source_token?: string; - explore: TopicalExploreFeedResponseExplore; - impression_token?: string; - product_tags?: TopicalExploreFeedResponseProduct_tags; - usertags?: TopicalExploreFeedResponseUsertags; - carousel_media_count?: number; - carousel_media?: TopicalExploreFeedResponseCarouselMediaItem[]; - title?: string; - product_type?: string; - nearly_complete_copyright_match?: boolean; - media_cropping_info?: TopicalExploreFeedResponseMedia_cropping_info; - thumbnails?: TopicalExploreFeedResponseThumbnails; - is_post_live?: boolean; + taken_at: number; + pk: string; + id: string; + device_timestamp: number | string; + media_type: number; + code: string; + client_cache_key: string; + filter_type: number; + location?: TopicalExploreFeedResponseLocation; + lat?: number; + lng?: number; + user: TopicalExploreFeedResponseUser; + can_viewer_reshare: boolean; + caption_is_edited: boolean; + comment_likes_enabled: boolean; + comment_threading_enabled: boolean; + has_more_comments: boolean; + max_num_visible_preview_comments: number; + preview_comments: any[]; + can_view_more_preview_comments: boolean; + comment_count: number; + image_versions2?: TopicalExploreFeedResponseImage_versions2; + original_width?: number; + original_height?: number; + like_count?: number; + has_liked?: boolean; + top_likers?: string[]; + photo_of_you: boolean; + can_see_insights_as_brand: boolean; + is_dash_eligible?: number; + video_dash_manifest?: string; + video_codec?: string; + number_of_qualities?: number; + video_versions?: TopicalExploreFeedResponseVideoVersionsItem[]; + has_audio?: boolean; + video_duration?: number; + view_count?: number; + caption: TopicalExploreFeedResponseCaption; + can_viewer_save: boolean; + organic_tracking_token: string; + sharing_friction_info: TopicalExploreFeedResponseSharing_friction_info; + is_in_profile_grid: boolean; + profile_grid_control_enabled: boolean; + is_shop_the_look_eligible: boolean; + deleted_reason: number; + explore_hide_comments?: boolean; + algorithm?: string; + connection_id?: string; + mezql_token: string; + explore_context?: string; + explore_source_token?: string; + explore: TopicalExploreFeedResponseExplore; + impression_token?: string; + product_tags?: TopicalExploreFeedResponseProduct_tags; + usertags?: TopicalExploreFeedResponseUsertags; + carousel_media_count?: number; + carousel_media?: TopicalExploreFeedResponseCarouselMediaItem[]; + title?: string; + product_type?: string; + nearly_complete_copyright_match?: boolean; + media_cropping_info?: TopicalExploreFeedResponseMedia_cropping_info; + thumbnails?: TopicalExploreFeedResponseThumbnails; + is_post_live?: boolean; } export interface TopicalExploreFeedResponseLocation { - pk: number; - name: string; - address: string; - city: string; - short_name: string; - lng: number; - lat: number; - external_source: string; - facebook_places_id: number; + pk: number; + name: string; + address: string; + city: string; + short_name: string; + lng: number; + lat: number; + external_source: string; + facebook_places_id: number; } export interface TopicalExploreFeedResponseUser { - pk: number; - username: string; - full_name: string; - is_private: boolean; - profile_pic_url: string; - profile_pic_id?: string; - friendship_status?: TopicalExploreFeedResponseFriendship_status; - is_verified: boolean; - has_anonymous_profile_picture?: boolean; - is_unpublished?: boolean; - is_favorite?: boolean; - latest_reel_media?: number; - account_badges?: any[]; - show_shoppable_feed?: boolean; - shoppable_posts_count?: number; - can_be_reported_as_fraud?: boolean; - merchant_checkout_style?: string; - seller_shoppable_feed_type?: string; + pk: number; + username: string; + full_name: string; + is_private: boolean; + profile_pic_url: string; + profile_pic_id?: string; + friendship_status?: TopicalExploreFeedResponseFriendship_status; + is_verified: boolean; + has_anonymous_profile_picture?: boolean; + is_unpublished?: boolean; + is_favorite?: boolean; + latest_reel_media?: number; + account_badges?: any[]; + show_shoppable_feed?: boolean; + shoppable_posts_count?: number; + can_be_reported_as_fraud?: boolean; + merchant_checkout_style?: string; + seller_shoppable_feed_type?: string; } export interface TopicalExploreFeedResponseFriendship_status { - following: boolean; - outgoing_request: boolean; - is_bestie: boolean; - is_restricted: boolean; + following: boolean; + outgoing_request: boolean; + is_bestie: boolean; + is_restricted: boolean; } export interface TopicalExploreFeedResponseImage_versions2 { - candidates: TopicalExploreFeedResponseCandidatesItem[]; - additional_candidates?: TopicalExploreFeedResponseAdditional_candidates; + candidates: TopicalExploreFeedResponseCandidatesItem[]; + additional_candidates?: TopicalExploreFeedResponseAdditional_candidates; } export interface TopicalExploreFeedResponseCandidatesItem { - width: number; - height: number; - url: string; - scans_profile?: string; - estimated_scans_sizes?: number[]; + width: number; + height: number; + url: string; + scans_profile?: string; + estimated_scans_sizes?: number[]; } export interface TopicalExploreFeedResponseVideoVersionsItem { - type: number; - width: number; - height: number; - url: string; - id: string; + type: number; + width: number; + height: number; + url: string; + id: string; } export interface TopicalExploreFeedResponseCaption { - pk: string; - user_id: number; - text: string; - type: number; - created_at: number; - created_at_utc: number; - content_type: string; - status: string; - bit_flags: number; - did_report_as_spam: boolean; - share_enabled: boolean; - user: TopicalExploreFeedResponseUser; - is_covered: boolean; - media_id: string; - private_reply_status: number; - has_translation?: boolean; + pk: string; + user_id: number; + text: string; + type: number; + created_at: number; + created_at_utc: number; + content_type: string; + status: string; + bit_flags: number; + did_report_as_spam: boolean; + share_enabled: boolean; + user: TopicalExploreFeedResponseUser; + is_covered: boolean; + media_id: string; + private_reply_status: number; + has_translation?: boolean; } export interface TopicalExploreFeedResponseSharing_friction_info { - should_have_sharing_friction: boolean; - bloks_app_url: null; + should_have_sharing_friction: boolean; + bloks_app_url: null; } export interface TopicalExploreFeedResponseExplore { - explanation: string; - actor_id?: number; - source_token?: string; + explanation: string; + actor_id?: number; + source_token?: string; } export interface TopicalExploreFeedResponseFillItemsItem { - media: TopicalExploreFeedResponseMedia; + media: TopicalExploreFeedResponseMedia; } export interface TopicalExploreFeedResponseProduct_tags { - 'in': TopicalExploreFeedResponseInItem[]; + in: TopicalExploreFeedResponseInItem[]; } export interface TopicalExploreFeedResponseInItem { - product?: TopicalExploreFeedResponseProduct; - position: string[] | number[]; - user?: TopicalExploreFeedResponseUser; - start_time_in_video_in_sec?: null; - duration_in_video_in_sec?: null; + product?: TopicalExploreFeedResponseProduct; + position: string[] | number[]; + user?: TopicalExploreFeedResponseUser; + start_time_in_video_in_sec?: null; + duration_in_video_in_sec?: null; } export interface TopicalExploreFeedResponseProduct { - name: string; - price: string; - current_price: string; - full_price: string; - product_id: string; - merchant: TopicalExploreFeedResponseMerchant; - compound_product_id: string; - description: string; - retailer_id: string; - has_viewer_saved: boolean; - main_image: TopicalExploreFeedResponseMain_image; - thumbnail_image: TopicalExploreFeedResponseThumbnail_image; - review_status: string; - external_url: string; - checkout_style: string; - can_share_to_story: boolean; - can_see_insights_for_viewer: boolean; - full_price_stripped: string; - current_price_stripped: string; - launch_information?: TopicalExploreFeedResponseLaunch_information; - rich_text_description?: TopicalExploreFeedResponseRichTextDescriptionItem[]; + name: string; + price: string; + current_price: string; + full_price: string; + product_id: string; + merchant: TopicalExploreFeedResponseMerchant; + compound_product_id: string; + description: string; + retailer_id: string; + has_viewer_saved: boolean; + main_image: TopicalExploreFeedResponseMain_image; + thumbnail_image: TopicalExploreFeedResponseThumbnail_image; + review_status: string; + external_url: string; + checkout_style: string; + can_share_to_story: boolean; + can_see_insights_for_viewer: boolean; + full_price_stripped: string; + current_price_stripped: string; + launch_information?: TopicalExploreFeedResponseLaunch_information; + rich_text_description?: TopicalExploreFeedResponseRichTextDescriptionItem[]; } export interface TopicalExploreFeedResponseMerchant { - pk: number; - username: string; - profile_pic_url: string; + pk: number; + username: string; + profile_pic_url: string; } export interface TopicalExploreFeedResponseMain_image { - image_versions2: TopicalExploreFeedResponseImage_versions2; - preview: string; + image_versions2: TopicalExploreFeedResponseImage_versions2; + preview: string; } export interface TopicalExploreFeedResponseThumbnail_image { - image_versions2: TopicalExploreFeedResponseImage_versions2; - preview: string; + image_versions2: TopicalExploreFeedResponseImage_versions2; + preview: string; } export interface TopicalExploreFeedResponseLaunch_information { - launch_date: number; - has_launched: boolean; - is_ig_exclusive: boolean; - drops_campaign_id: string; + launch_date: number; + has_launched: boolean; + is_ig_exclusive: boolean; + drops_campaign_id: string; } export interface TopicalExploreFeedResponseRichTextDescriptionItem { - block_type: string; - depth: number; - text_with_entities: TopicalExploreFeedResponseText_with_entities; + block_type: string; + depth: number; + text_with_entities: TopicalExploreFeedResponseText_with_entities; } export interface TopicalExploreFeedResponseText_with_entities { - text: string; - inline_style_ranges: TopicalExploreFeedResponseInlineStyleRangesItem[]; + text: string; + inline_style_ranges: TopicalExploreFeedResponseInlineStyleRangesItem[]; } export interface TopicalExploreFeedResponseInlineStyleRangesItem { - inline_style: number; - length: number; - offset: number; + inline_style: number; + length: number; + offset: number; } export interface TopicalExploreFeedResponseExplore_item_info { - num_columns: number; - total_num_columns: number; - aspect_ratio: number; - autoplay: boolean; + num_columns: number; + total_num_columns: number; + aspect_ratio: number; + autoplay: boolean; } export interface TopicalExploreFeedResponseMediasItem { - media: TopicalExploreFeedResponseMedia; + media: TopicalExploreFeedResponseMedia; } export interface TopicalExploreFeedResponseUsertags { - 'in': TopicalExploreFeedResponseInItem[]; + in: TopicalExploreFeedResponseInItem[]; } export interface TopicalExploreFeedResponseCarouselMediaItem { - id: string; - media_type: number; - image_versions2: TopicalExploreFeedResponseImage_versions2; - original_width: number; - original_height: number; - pk: string; - carousel_parent_id: string; - can_see_insights_as_brand: boolean; - sharing_friction_info: TopicalExploreFeedResponseSharing_friction_info; - usertags?: TopicalExploreFeedResponseUsertags; - product_tags?: TopicalExploreFeedResponseProduct_tags; + id: string; + media_type: number; + image_versions2: TopicalExploreFeedResponseImage_versions2; + original_width: number; + original_height: number; + pk: string; + carousel_parent_id: string; + can_see_insights_as_brand: boolean; + sharing_friction_info: TopicalExploreFeedResponseSharing_friction_info; + usertags?: TopicalExploreFeedResponseUsertags; + product_tags?: TopicalExploreFeedResponseProduct_tags; } export interface TopicalExploreFeedResponseIgtv { - media: TopicalExploreFeedResponseMedia; - tv_guide: TopicalExploreFeedResponseTv_guide; - display_content_metadata: boolean; -} -export interface TopicalExploreFeedResponseMedia_cropping_info { + media: TopicalExploreFeedResponseMedia; + tv_guide: TopicalExploreFeedResponseTv_guide; + display_content_metadata: boolean; } +export interface TopicalExploreFeedResponseMedia_cropping_info {} export interface TopicalExploreFeedResponseThumbnails { - video_length: number; - thumbnail_width: number; - thumbnail_height: number; - thumbnail_duration: string; - sprite_urls: string[]; - thumbnails_per_row: number; - max_thumbnails_per_sprite: number; - sprite_width: number; - sprite_height: number; - rendered_width: number; + video_length: number; + thumbnail_width: number; + thumbnail_height: number; + thumbnail_duration: string; + sprite_urls: string[]; + thumbnails_per_row: number; + max_thumbnails_per_sprite: number; + sprite_width: number; + sprite_height: number; + rendered_width: number; } export interface TopicalExploreFeedResponseAdditional_candidates { - igtv_first_frame: TopicalExploreFeedResponseIgtv_first_frame; - first_frame: TopicalExploreFeedResponseFirst_frame; + igtv_first_frame: TopicalExploreFeedResponseIgtv_first_frame; + first_frame: TopicalExploreFeedResponseFirst_frame; } export interface TopicalExploreFeedResponseIgtv_first_frame { - width: number; - height: number; - url: string; - scans_profile: string; - estimated_scans_sizes: number[]; + width: number; + height: number; + url: string; + scans_profile: string; + estimated_scans_sizes: number[]; } export interface TopicalExploreFeedResponseFirst_frame { - width: number; - height: number; - url: string; - scans_profile: string; - estimated_scans_sizes: number[]; + width: number; + height: number; + url: string; + scans_profile: string; + estimated_scans_sizes: number[]; } export interface TopicalExploreFeedResponseTv_guide { - channels: TopicalExploreFeedResponseChannelsItem[]; + channels: TopicalExploreFeedResponseChannelsItem[]; } export interface TopicalExploreFeedResponseChannelsItem { - id: string; - items: TopicalExploreFeedResponseItemsItem[]; - more_available: boolean; - seen_state: TopicalExploreFeedResponseSeen_state; - title: string; - type: string; - max_id: string; - user_dict: null; - description: null; - cover_photo_url: null; - approx_total_videos: null; - destination_client_configs: null; + id: string; + items: TopicalExploreFeedResponseItemsItem[]; + more_available: boolean; + seen_state: TopicalExploreFeedResponseSeen_state; + title: string; + type: string; + max_id: string; + user_dict: null; + description: null; + cover_photo_url: null; + approx_total_videos: null; + destination_client_configs: null; } export interface TopicalExploreFeedResponseItemsItem { - taken_at: number; - pk: string; - id: string; - device_timestamp: number | string; - media_type: number; - code: string; - client_cache_key: string; - filter_type: number; - user: TopicalExploreFeedResponseUser; - can_viewer_reshare: boolean; - caption_is_edited: boolean; - comment_likes_enabled: boolean; - comment_threading_enabled: boolean; - has_more_comments: boolean; - max_num_visible_preview_comments: number; - preview_comments: any[]; - can_view_more_preview_comments: boolean; - comment_count: number; - title: string; - product_type: string; - nearly_complete_copyright_match: boolean; - media_cropping_info: TopicalExploreFeedResponseMedia_cropping_info; - thumbnails: TopicalExploreFeedResponseThumbnails; - is_post_live: boolean; - image_versions2: TopicalExploreFeedResponseImage_versions2; - original_width: number; - original_height: number; - photo_of_you: boolean; - can_see_insights_as_brand: boolean; - is_dash_eligible: number; - video_dash_manifest: string; - video_codec: string; - number_of_qualities: number; - video_versions: TopicalExploreFeedResponseVideoVersionsItem[]; - has_audio: boolean; - video_duration: number; - view_count: number; - caption: TopicalExploreFeedResponseCaption; - can_viewer_save: boolean; - organic_tracking_token: string; - sharing_friction_info: TopicalExploreFeedResponseSharing_friction_info; - is_in_profile_grid: boolean; - profile_grid_control_enabled: boolean; - is_shop_the_look_eligible: boolean; - deleted_reason: number; - explore: TopicalExploreFeedResponseExplore; - mezql_token: string; -} -export interface TopicalExploreFeedResponseSeen_state { -} + taken_at: number; + pk: string; + id: string; + device_timestamp: number | string; + media_type: number; + code: string; + client_cache_key: string; + filter_type: number; + user: TopicalExploreFeedResponseUser; + can_viewer_reshare: boolean; + caption_is_edited: boolean; + comment_likes_enabled: boolean; + comment_threading_enabled: boolean; + has_more_comments: boolean; + max_num_visible_preview_comments: number; + preview_comments: any[]; + can_view_more_preview_comments: boolean; + comment_count: number; + title: string; + product_type: string; + nearly_complete_copyright_match: boolean; + media_cropping_info: TopicalExploreFeedResponseMedia_cropping_info; + thumbnails: TopicalExploreFeedResponseThumbnails; + is_post_live: boolean; + image_versions2: TopicalExploreFeedResponseImage_versions2; + original_width: number; + original_height: number; + photo_of_you: boolean; + can_see_insights_as_brand: boolean; + is_dash_eligible: number; + video_dash_manifest: string; + video_codec: string; + number_of_qualities: number; + video_versions: TopicalExploreFeedResponseVideoVersionsItem[]; + has_audio: boolean; + video_duration: number; + view_count: number; + caption: TopicalExploreFeedResponseCaption; + can_viewer_save: boolean; + organic_tracking_token: string; + sharing_friction_info: TopicalExploreFeedResponseSharing_friction_info; + is_in_profile_grid: boolean; + profile_grid_control_enabled: boolean; + is_shop_the_look_eligible: boolean; + deleted_reason: number; + explore: TopicalExploreFeedResponseExplore; + mezql_token: string; +} +export interface TopicalExploreFeedResponseSeen_state {} From 927cb56c4b6e3668f920b8937b10d61467167555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Tue, 28 Feb 2023 13:51:51 +0000 Subject: [PATCH 03/11] saved collection added --- src/feeds/saved-collection.feed.ts | 31 +++ src/responses/index.ts | 1 + .../saved-collection.feed.response.ts | 216 ++++++++++++++++++ 3 files changed, 248 insertions(+) create mode 100644 src/feeds/saved-collection.feed.ts create mode 100644 src/responses/saved-collection.feed.response.ts diff --git a/src/feeds/saved-collection.feed.ts b/src/feeds/saved-collection.feed.ts new file mode 100644 index 000000000..53e659bd7 --- /dev/null +++ b/src/feeds/saved-collection.feed.ts @@ -0,0 +1,31 @@ +import { Expose } from 'class-transformer'; +import { Feed } from '../core/feed'; +import { SavedCollectionFeedResponseRootObject, SavedFeedResponseMedia } from '../responses'; + +export class SavedCollectionFeed extends Feed { + id: number | string; + @Expose() + private nextMaxId: string; + + set state(body: SavedCollectionFeedResponseRootObject) { + this.moreAvailable = body.more_available; + this.nextMaxId = body.next_max_id; + } + + async request(): Promise { + const { body } = await this.client.request.send({ + url: `api/v1/feed/collection/${this.id}/all`, + qs: { + max_id: this.nextMaxId, + include_igtv_preview: false, + }, + }); + this.state = body; + return body; + } + + async items(): Promise { + const { save_media_response } = await this.request(); + return save_media_response.items.map(item => item.media); + } +} diff --git a/src/responses/index.ts b/src/responses/index.ts index 83098d2d7..7f14c7170 100644 --- a/src/responses/index.ts +++ b/src/responses/index.ts @@ -68,6 +68,7 @@ export * from './media.repository.configure-sidecar.response'; export * from './media.repository.configure-video.response'; export * from './saved.feed.response'; export * from './saved-collections.feed.response'; +export { SavedCollectionFeedResponseRootObject } from './saved-collection.feed.response'; export * from './status.response'; export * from './reels-tray.feed.response'; export * from './music.repository.moods.response'; diff --git a/src/responses/saved-collection.feed.response.ts b/src/responses/saved-collection.feed.response.ts new file mode 100644 index 000000000..aff113c06 --- /dev/null +++ b/src/responses/saved-collection.feed.response.ts @@ -0,0 +1,216 @@ +export interface SavedCollectionFeedResponseRootObject { + save_media_response: { + items: SavedFeedResponseItemsItem[]; + }; + num_results: number; + more_available: boolean; + auto_load_more_enabled: boolean; + status: string; + next_max_id: string; +} +export interface SavedFeedResponseItemsItem { + media: SavedFeedResponseMedia; +} +export interface SavedFeedResponseMedia { + 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?: SavedFeedResponseImage_versions2; + original_width?: number; + original_height?: number; + user: SavedFeedResponseUser; + 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: SavedFeedResponsePreviewCommentsItem[]; + 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?: SavedFeedResponseProduct_tags; + can_see_insights_as_brand?: boolean; + caption: SavedFeedResponseCaption; + can_viewer_save: boolean; + has_viewer_saved: boolean; + saved_collection_ids: any[]; + organic_tracking_token: string; + usertags?: SavedFeedResponseUsertags; + is_dash_eligible?: number; + video_dash_manifest?: string; + video_codec?: string; + number_of_qualities?: number; + video_versions?: SavedFeedResponseVideoVersionsItem[]; + has_audio?: boolean; + video_duration?: number; + view_count?: number; + carousel_media_count?: number; + carousel_media?: SavedFeedResponseCarouselMediaItem[]; + location?: SavedFeedResponseLocation; +} +export interface SavedFeedResponseImage_versions2 { + candidates: SavedFeedResponseCandidatesItem[]; +} +export interface SavedFeedResponseCandidatesItem { + width: number; + height: number; + url: string; + estimated_scans_sizes?: number[]; +} +export interface SavedFeedResponseUser { + pk: number; + username: string; + full_name: string; + is_private: boolean; + profile_pic_url: string; + friendship_status?: SavedFeedResponseFriendship_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 SavedFeedResponseFriendship_status { + following: boolean; + outgoing_request: boolean; + is_bestie: boolean; + is_restricted: boolean; +} +export interface SavedFeedResponsePreviewCommentsItem { + 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: SavedFeedResponseUser; + 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 SavedFeedResponseProduct_tags { + in: SavedFeedResponseInItem[]; +} +export interface SavedFeedResponseInItem { + product?: SavedFeedResponseProduct; + position: string[] | number[]; + user?: SavedFeedResponseUser; + start_time_in_video_in_sec?: null; + duration_in_video_in_sec?: null; +} +export interface SavedFeedResponseProduct { + name: string; + price: string; + current_price: string; + full_price: string; + product_id: string; + merchant: SavedFeedResponseMerchant; + description: string; + retailer_id: string; + has_viewer_saved: boolean; + main_image: SavedFeedResponseMain_image; + thumbnail_image: SavedFeedResponseThumbnail_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?: SavedFeedResponseVariantValuesItem[]; +} +export interface SavedFeedResponseMerchant { + pk: number; + username: string; + profile_pic_url: string; +} +export interface SavedFeedResponseMain_image { + image_versions2: SavedFeedResponseImage_versions2; + preview: null; +} +export interface SavedFeedResponseThumbnail_image { + image_versions2: SavedFeedResponseImage_versions2; + preview: null; +} +export interface SavedFeedResponseVariantValuesItem { + id: string; + value: string; + name: string; + is_preselected: boolean; + visual_style: string; +} +export interface SavedFeedResponseCaption { + 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: SavedFeedResponseUser; + did_report_as_spam: boolean; + share_enabled: boolean; + media_id: string; + has_translation?: boolean; +} +export interface SavedFeedResponseUsertags { + in: SavedFeedResponseInItem[]; +} +export interface SavedFeedResponseVideoVersionsItem { + type: number; + width: number; + height: number; + url: string; + id: string; +} +export interface SavedFeedResponseCarouselMediaItem { + id: string; + media_type: number; + image_versions2: SavedFeedResponseImage_versions2; + original_width: number; + original_height: number; + pk: string; + carousel_parent_id: string; + usertags: SavedFeedResponseUsertags; + video_versions?: SavedFeedResponseVideoVersionsItem[]; + video_duration?: number; + is_dash_eligible?: number; + video_dash_manifest?: string; + video_codec?: string; + number_of_qualities?: number; +} +export interface SavedFeedResponseLocation { + pk: number; + name: string; + address: string; + city: string; + short_name: string; + lng: number; + lat: number; + external_source: string; + facebook_places_id: number; +} From ec2ef2bf4922eb1c22f8c566f7a147b6651a84ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Tue, 28 Feb 2023 13:57:38 +0000 Subject: [PATCH 04/11] saved collection added --- src/feeds/index.ts | 1 + src/feeds/saved-collection.feed.ts | 31 +++ src/responses/index.ts | 1 + .../saved-collection.feed.response.ts | 216 ++++++++++++++++++ 4 files changed, 249 insertions(+) create mode 100644 src/feeds/saved-collection.feed.ts create mode 100644 src/responses/saved-collection.feed.response.ts diff --git a/src/feeds/index.ts b/src/feeds/index.ts index f6d9f5881..cfa511229 100644 --- a/src/feeds/index.ts +++ b/src/feeds/index.ts @@ -12,6 +12,7 @@ export * from './news.feed'; export * from './reels-media.feed'; export * from './saved.feed'; export * from './saved-collections.feed'; +export * from './saved-collection.feed'; export * from './tag.feed'; export * from './tags.feed'; export * from './timeline.feed'; diff --git a/src/feeds/saved-collection.feed.ts b/src/feeds/saved-collection.feed.ts new file mode 100644 index 000000000..53e659bd7 --- /dev/null +++ b/src/feeds/saved-collection.feed.ts @@ -0,0 +1,31 @@ +import { Expose } from 'class-transformer'; +import { Feed } from '../core/feed'; +import { SavedCollectionFeedResponseRootObject, SavedFeedResponseMedia } from '../responses'; + +export class SavedCollectionFeed extends Feed { + id: number | string; + @Expose() + private nextMaxId: string; + + set state(body: SavedCollectionFeedResponseRootObject) { + this.moreAvailable = body.more_available; + this.nextMaxId = body.next_max_id; + } + + async request(): Promise { + const { body } = await this.client.request.send({ + url: `api/v1/feed/collection/${this.id}/all`, + qs: { + max_id: this.nextMaxId, + include_igtv_preview: false, + }, + }); + this.state = body; + return body; + } + + async items(): Promise { + const { save_media_response } = await this.request(); + return save_media_response.items.map(item => item.media); + } +} diff --git a/src/responses/index.ts b/src/responses/index.ts index 83098d2d7..7f14c7170 100644 --- a/src/responses/index.ts +++ b/src/responses/index.ts @@ -68,6 +68,7 @@ export * from './media.repository.configure-sidecar.response'; export * from './media.repository.configure-video.response'; export * from './saved.feed.response'; export * from './saved-collections.feed.response'; +export { SavedCollectionFeedResponseRootObject } from './saved-collection.feed.response'; export * from './status.response'; export * from './reels-tray.feed.response'; export * from './music.repository.moods.response'; diff --git a/src/responses/saved-collection.feed.response.ts b/src/responses/saved-collection.feed.response.ts new file mode 100644 index 000000000..aff113c06 --- /dev/null +++ b/src/responses/saved-collection.feed.response.ts @@ -0,0 +1,216 @@ +export interface SavedCollectionFeedResponseRootObject { + save_media_response: { + items: SavedFeedResponseItemsItem[]; + }; + num_results: number; + more_available: boolean; + auto_load_more_enabled: boolean; + status: string; + next_max_id: string; +} +export interface SavedFeedResponseItemsItem { + media: SavedFeedResponseMedia; +} +export interface SavedFeedResponseMedia { + 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?: SavedFeedResponseImage_versions2; + original_width?: number; + original_height?: number; + user: SavedFeedResponseUser; + 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: SavedFeedResponsePreviewCommentsItem[]; + 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?: SavedFeedResponseProduct_tags; + can_see_insights_as_brand?: boolean; + caption: SavedFeedResponseCaption; + can_viewer_save: boolean; + has_viewer_saved: boolean; + saved_collection_ids: any[]; + organic_tracking_token: string; + usertags?: SavedFeedResponseUsertags; + is_dash_eligible?: number; + video_dash_manifest?: string; + video_codec?: string; + number_of_qualities?: number; + video_versions?: SavedFeedResponseVideoVersionsItem[]; + has_audio?: boolean; + video_duration?: number; + view_count?: number; + carousel_media_count?: number; + carousel_media?: SavedFeedResponseCarouselMediaItem[]; + location?: SavedFeedResponseLocation; +} +export interface SavedFeedResponseImage_versions2 { + candidates: SavedFeedResponseCandidatesItem[]; +} +export interface SavedFeedResponseCandidatesItem { + width: number; + height: number; + url: string; + estimated_scans_sizes?: number[]; +} +export interface SavedFeedResponseUser { + pk: number; + username: string; + full_name: string; + is_private: boolean; + profile_pic_url: string; + friendship_status?: SavedFeedResponseFriendship_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 SavedFeedResponseFriendship_status { + following: boolean; + outgoing_request: boolean; + is_bestie: boolean; + is_restricted: boolean; +} +export interface SavedFeedResponsePreviewCommentsItem { + 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: SavedFeedResponseUser; + 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 SavedFeedResponseProduct_tags { + in: SavedFeedResponseInItem[]; +} +export interface SavedFeedResponseInItem { + product?: SavedFeedResponseProduct; + position: string[] | number[]; + user?: SavedFeedResponseUser; + start_time_in_video_in_sec?: null; + duration_in_video_in_sec?: null; +} +export interface SavedFeedResponseProduct { + name: string; + price: string; + current_price: string; + full_price: string; + product_id: string; + merchant: SavedFeedResponseMerchant; + description: string; + retailer_id: string; + has_viewer_saved: boolean; + main_image: SavedFeedResponseMain_image; + thumbnail_image: SavedFeedResponseThumbnail_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?: SavedFeedResponseVariantValuesItem[]; +} +export interface SavedFeedResponseMerchant { + pk: number; + username: string; + profile_pic_url: string; +} +export interface SavedFeedResponseMain_image { + image_versions2: SavedFeedResponseImage_versions2; + preview: null; +} +export interface SavedFeedResponseThumbnail_image { + image_versions2: SavedFeedResponseImage_versions2; + preview: null; +} +export interface SavedFeedResponseVariantValuesItem { + id: string; + value: string; + name: string; + is_preselected: boolean; + visual_style: string; +} +export interface SavedFeedResponseCaption { + 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: SavedFeedResponseUser; + did_report_as_spam: boolean; + share_enabled: boolean; + media_id: string; + has_translation?: boolean; +} +export interface SavedFeedResponseUsertags { + in: SavedFeedResponseInItem[]; +} +export interface SavedFeedResponseVideoVersionsItem { + type: number; + width: number; + height: number; + url: string; + id: string; +} +export interface SavedFeedResponseCarouselMediaItem { + id: string; + media_type: number; + image_versions2: SavedFeedResponseImage_versions2; + original_width: number; + original_height: number; + pk: string; + carousel_parent_id: string; + usertags: SavedFeedResponseUsertags; + video_versions?: SavedFeedResponseVideoVersionsItem[]; + video_duration?: number; + is_dash_eligible?: number; + video_dash_manifest?: string; + video_codec?: string; + number_of_qualities?: number; +} +export interface SavedFeedResponseLocation { + pk: number; + name: string; + address: string; + city: string; + short_name: string; + lng: number; + lat: number; + external_source: string; + facebook_places_id: number; +} From 5321a7318eefb710d8f9179ed264d3d22865e900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Tue, 28 Feb 2023 14:05:10 +0000 Subject: [PATCH 05/11] added to factory --- src/core/feed.factory.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/feed.factory.ts b/src/core/feed.factory.ts index 6eda513d9..187ee8257 100644 --- a/src/core/feed.factory.ts +++ b/src/core/feed.factory.ts @@ -37,6 +37,7 @@ import { plainToClassFromExist } from 'class-transformer'; import * as Chance from 'chance'; import { PostsInsightsFeedOptions, TimelineFeedReason, IgAppModule } from '../types'; import { UserStoryFeed } from '../feeds/user-story.feed'; +import { SavedCollectionFeed } from '../feeds'; 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'; @@ -224,6 +225,10 @@ export class FeedFactory { return new SavedCollectionsFeed(this.client); } + public savedCollection(collectionId: string | number) { + return plainToClassFromExist(new SavedCollectionFeed(this.client), { collectionId }); + } + public listReelMediaViewers(mediaId: string): ListReelMediaViewerFeed { return plainToClassFromExist(new ListReelMediaViewerFeed(this.client), { mediaId }); } From 9d8d4340152178e4325f6fb5cc4bf92bff4331d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Tue, 28 Feb 2023 14:19:59 +0000 Subject: [PATCH 06/11] fixed parameter --- src/feeds/saved-collection.feed.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/feeds/saved-collection.feed.ts b/src/feeds/saved-collection.feed.ts index 53e659bd7..a05269384 100644 --- a/src/feeds/saved-collection.feed.ts +++ b/src/feeds/saved-collection.feed.ts @@ -3,7 +3,7 @@ import { Feed } from '../core/feed'; import { SavedCollectionFeedResponseRootObject, SavedFeedResponseMedia } from '../responses'; export class SavedCollectionFeed extends Feed { - id: number | string; + collectionId: number | string; @Expose() private nextMaxId: string; @@ -14,7 +14,7 @@ export class SavedCollectionFeed extends Feed { const { body } = await this.client.request.send({ - url: `api/v1/feed/collection/${this.id}/all`, + url: `api/v1/feed/collection/${this.collectionId}/all`, qs: { max_id: this.nextMaxId, include_igtv_preview: false, From 31d6178bac18cf92bc42caff35c2eac2394ec414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Tue, 28 Feb 2023 15:21:00 +0000 Subject: [PATCH 07/11] improve code --- src/feeds/saved.feed.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/feeds/saved.feed.ts b/src/feeds/saved.feed.ts index 47f9e7a73..9fc1598e7 100644 --- a/src/feeds/saved.feed.ts +++ b/src/feeds/saved.feed.ts @@ -23,6 +23,19 @@ export class SavedFeed extends Feed { + const { body } = await this.client.request.send({ + url: + 'api/v1/collections/list/?collection_types=%5B%22ALL_MEDIA_AUTO_COLLECTION%22%2C%22MEDIA%22%2C%22AUDIO_AUTO_COLLECTION%22%5D&include_public_only=0&get_cover_media_lists=true&max_id=QVFDV004M2FjcVQ0blNVVnp1dmZmM1JCMmZIb3REUnVyd0xsdGd0WVY5R25ILVBQMmRvWXV1Qk5DcF84cENNWGx1UThyb1NrVzZqeENVY2w1VXkwZlFhbg%3D%3D', + qs: { + max_id: this.nextMaxId, + include_igtv_preview: false, + }, + }); + this.state = body; + return body; + } + async items(): Promise { const { items } = await this.request(); return items.map(i => i.media); From edb23d04b741db2e6a1f7807208eeb879d7bd781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Tue, 28 Feb 2023 15:28:56 +0000 Subject: [PATCH 08/11] removed other stuff --- src/feeds/saved.feed.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/feeds/saved.feed.ts b/src/feeds/saved.feed.ts index 9fc1598e7..47f9e7a73 100644 --- a/src/feeds/saved.feed.ts +++ b/src/feeds/saved.feed.ts @@ -23,19 +23,6 @@ export class SavedFeed extends Feed { - const { body } = await this.client.request.send({ - url: - 'api/v1/collections/list/?collection_types=%5B%22ALL_MEDIA_AUTO_COLLECTION%22%2C%22MEDIA%22%2C%22AUDIO_AUTO_COLLECTION%22%5D&include_public_only=0&get_cover_media_lists=true&max_id=QVFDV004M2FjcVQ0blNVVnp1dmZmM1JCMmZIb3REUnVyd0xsdGd0WVY5R25ILVBQMmRvWXV1Qk5DcF84cENNWGx1UThyb1NrVzZqeENVY2w1VXkwZlFhbg%3D%3D', - qs: { - max_id: this.nextMaxId, - include_igtv_preview: false, - }, - }); - this.state = body; - return body; - } - async items(): Promise { const { items } = await this.request(); return items.map(i => i.media); From ccf8398e0341b1bb74db6c78a0e524eeb761fdec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Tue, 28 Feb 2023 22:51:17 +0000 Subject: [PATCH 09/11] fixed collection by id --- src/feeds/saved-collection.feed.ts | 6 +++--- src/responses/saved-collection.feed.response.ts | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/feeds/saved-collection.feed.ts b/src/feeds/saved-collection.feed.ts index a05269384..a790ee426 100644 --- a/src/feeds/saved-collection.feed.ts +++ b/src/feeds/saved-collection.feed.ts @@ -14,7 +14,7 @@ export class SavedCollectionFeed extends Feed { const { body } = await this.client.request.send({ - url: `api/v1/feed/collection/${this.collectionId}/all`, + url: `api/v1/feed/collection/${this.collectionId}/posts`, qs: { max_id: this.nextMaxId, include_igtv_preview: false, @@ -25,7 +25,7 @@ export class SavedCollectionFeed extends Feed { - const { save_media_response } = await this.request(); - return save_media_response.items.map(item => item.media); + const { items } = await this.request(); + return items.map(item => item.media); } } diff --git a/src/responses/saved-collection.feed.response.ts b/src/responses/saved-collection.feed.response.ts index aff113c06..dd7cd1705 100644 --- a/src/responses/saved-collection.feed.response.ts +++ b/src/responses/saved-collection.feed.response.ts @@ -1,7 +1,5 @@ export interface SavedCollectionFeedResponseRootObject { - save_media_response: { - items: SavedFeedResponseItemsItem[]; - }; + items: SavedFeedResponseItemsItem[]; num_results: number; more_available: boolean; auto_load_more_enabled: boolean; From 5f8fbfb2a441327378f77d8ac8141e0cf3a89f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Wed, 1 Mar 2023 01:33:41 +0000 Subject: [PATCH 10/11] updated parameters --- src/feeds/saved-collections.feed.ts | 16 +++++++++++++--- src/responses/saved-collections.feed.response.ts | 6 ++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/feeds/saved-collections.feed.ts b/src/feeds/saved-collections.feed.ts index 225bed4f5..464cc0e5d 100644 --- a/src/feeds/saved-collections.feed.ts +++ b/src/feeds/saved-collections.feed.ts @@ -1,6 +1,10 @@ import { Expose } from 'class-transformer'; import { Feed } from '../core/feed'; -import { SavedCollectionsFeedResponseRootObject, SavedCollectionsFeedResponse } from '../responses'; +import { + SavedCollectionsFeedResponseRootObject, + SavedCollectionsFeedResponse, + SavedCollectionCollectionType, +} from '../responses'; export class SavedCollectionsFeed extends Feed { @Expose() @@ -13,11 +17,17 @@ export class SavedCollectionsFeed extends Feed { const { body } = await this.client.request.send({ - url: - 'api/v1/collections/list/?collection_types=%5B%22ALL_MEDIA_AUTO_COLLECTION%22%2C%22MEDIA%22%2C%22AUDIO_AUTO_COLLECTION%22%5D&include_public_only=0&get_cover_media_lists=true&max_id=QVFDV004M2FjcVQ0blNVVnp1dmZmM1JCMmZIb3REUnVyd0xsdGd0WVY5R25ILVBQMmRvWXV1Qk5DcF84cENNWGx1UThyb1NrVzZqeENVY2w1VXkwZlFhbg%3D%3D', + url: 'api/v1/collections/list', qs: { max_id: this.nextMaxId, include_igtv_preview: false, + include_public_only: 0, + collection_types: [ + SavedCollectionCollectionType.Media, + SavedCollectionCollectionType.AudioAutoCollection, + SavedCollectionCollectionType.AllMediaAutoCollection, + ].join(','), + get_cover_media_lists: true, }, }); this.state = body; diff --git a/src/responses/saved-collections.feed.response.ts b/src/responses/saved-collections.feed.response.ts index 12f9721bb..98d46bf2d 100644 --- a/src/responses/saved-collections.feed.response.ts +++ b/src/responses/saved-collections.feed.response.ts @@ -17,6 +17,12 @@ export interface SavedCollectionsFeedResponse { viewer_access_level: string; } +export enum SavedCollectionCollectionType { + AllMediaAutoCollection = 'ALL_MEDIA_AUTO_COLLECTION', + AudioAutoCollection = 'AUDIO_AUTO_COLLECTION', + Media = 'MEDIA', +} + export interface CoverMedia { id: string; media_type: number; From 3309d8bd533068116639c70f55c4d1400c420844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20K=C4=B1z=C4=B1lo=C4=9Flu?= Date: Wed, 1 Mar 2023 01:51:11 +0000 Subject: [PATCH 11/11] fixes collection types --- src/feeds/saved-collections.feed.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/feeds/saved-collections.feed.ts b/src/feeds/saved-collections.feed.ts index 464cc0e5d..7b83a9b9f 100644 --- a/src/feeds/saved-collections.feed.ts +++ b/src/feeds/saved-collections.feed.ts @@ -22,11 +22,11 @@ export class SavedCollectionsFeed extends Feed