dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.83k stars 1.13k forks source link

Get Reels Tab Vidoes #1733

Open zakrian07 opened 7 months ago

zakrian07 commented 7 months ago

Hello I want fetch the UserReels of a user https://www.instagram.com/luliziv/reels/
image specific for this tab i dont want loop from user posts if there is 5 k posts and only 5 videos it will loop with all data my goal is just get reels async function getReelsByUsername(ig: IgApiClient, username: string) { const targetUser = await ig.user.searchExact(username); console.log("targetuser",targetUser) const reelsFeed = ig.feed.reelsMedia({ userIds: [targetUser.pk] }); const allReels = []; console.log("reelsFeed",reelsFeed) let reels = await reelsFeed.items(); allReels.push(...reels); console.log(Fetched ${reels.length} reels);

while (reelsFeed.isMoreAvailable()) { console.log('More reels are available, fetching...'); reels = await reelsFeed.items(); allReels.push(...reels); console.log(Fetched ${reels.length} more reels); }

return allReels.map(reel => ({ id: reel.id, videoUrl: reel.video_versions ? reel.video_versions[0].url : null, caption: reel.caption ? reel.caption.text : '', })); } this is not giving me expected results here is out put npx ts-node ./examples/session.example.ts Session file path: /home/singhera/projects/instagram/instagram-private-api/examples/session.json Session file exists. Session data loaded successfully. Login works. targetuser [Object: null prototype] { fbid_v2: '17841401558740719', pk: 46067958, pk_id: '46067958', strong_id__: '46067958', full_name: 'Ludovica Guspini | LuliZiv ♥ Safe Zone', is_private: false, third_party_downloads_enabled: 1, has_anonymous_profile_picture: false, username: 'luliziv', is_verified: true, profile_pic_id: '3200604805365274706_46067958', profile_pic_url: 'https://instagram.fkhi4-4.fna.fbcdn.net/v/t51.2885-19/382903399_1613943749014007_4468674898876614633_n.jpg?stp=dst-jpg_e0_s150x150&_nc_ad=z-m&_nc_ht=instagram.fkhi4-4.fna.fbcdn.net&_nc_cat=111&_nc_ohc=0ZmfLxaQ7HsAX8Enphx&edm=AM7KJZYBAAAA&ccb=7-5&oh=00_AfBylTgNHmApj2Rx1GZN3OViofARs5F8bVI_3WfupZEXJw&oe=6559E96F&_nc_sid=8ec269', has_opt_eligible_shop: false, account_badges: [], friendship_status: [Object: null prototype] { following: false, is_private: false, incoming_request: false, outgoing_request: false, is_bestie: false, is_restricted: false, is_feed_favorite: false }, latest_reel_media: 1700052540, is_verified_search_boosted: false, should_show_category: false } reelsFeed ReelsMediaFeed { attemptOptions: { delay: 60000, factor: 1.5, maxAttempts: 10, minDelay: 60000, maxDelay: 300000, jitter: true }, rankToken: undefined, source: 'feed_timeline', userIds: [ 46067958 ], moreAvailable: undefined } Saving session to file... Session saved successfully. Fetched 3 reels [ { id: '3235958857074720616_46067958', videoUrl: 'https://instagram.fkhi4-2.fna.fbcdn.net/o1/v/t16/f1/m78/5C49C26C9D3A5EE7CB16885DD96E3786_video_dashinit.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLnN0b3J5LmMyLjcyMC5iYXNlbGluZSJ9&_nc_ht=instagram.fkhi4-2.fna.fbcdn.net&_nc_cat=102&vs=1497430581045694_1615315621&_nc_vs=HBksFQIYUWlnX3hwdl9wbGFjZW1lbnRfcGVybWFuZW50X3YyLzVDNDlDMjZDOUQzQTVFRTdDQjE2ODg1REQ5NkUzNzg2X3ZpZGVvX2Rhc2hpbml0Lm1wNBUAAsgBABUCGDpwYXNzdGhyb3VnaF9ldmVyc3RvcmUvR0h3TDVSZEc1QWNmV3RZQUFFZkxIVzBqOVI0ZGJwa3dBQUFGFQICyAEAKAAYABsBiAd1c2Vfb2lsATEVAAAmlr%2Fgnqz9nUEVAigCQzMsF0AZMzMzMzMzGBJkYXNoX2Jhc2VsaW5lXzFfdjERAHXoBwA%3D&_nc_rid=bebcbeac8a&ccb=9-4&oh=00_AfA5JlZuG_1tTEHzJYeA1vF15QaT-xb7uhxLSt1KbfWNtA&oe=65561CEC&_nc_sid=982cc7', caption: '' }, { id: '3236080833239788401_46067958', videoUrl: null, caption: '' }, { id: '3236597764355209921_46067958', videoUrl: null, caption: '' } ] Saving session to file... Session saved successfully. any help will be great this is breaking data coming

NickCis commented 7 months ago

It's implemented in this PR . This issue is a duplication of #1308 .

zakrian07 commented 7 months ago

@NickCis can you help me how can i do this i could not find a direction or doc for this

NickCis commented 7 months ago

You'll have to fork the PR or use the published versión I've forked (@nickcis/instagram-private-api).

Then you should edit your example and useconst feed = ig.feed.clips(targetUser.pk); instead of ig.feed.reelsMedia({ userIds: [targetUser.pk] });. You should avoid the seen call.

zakrian07 commented 7 months ago

Let me give a try and share code example

zakrian07 commented 7 months ago

[image: image.png] [image: image.png] this specific user giving me 1 reels with video however it have more here is dataset mrbeats not working as expected mrbeat worked as expected

https://www.instagram.com/mrbeats/reels/ https://www.instagram.com/mrbeat/reels/ plz check the issue

On Fri, Dec 1, 2023 at 9:39 PM Nicolas Cisco @.***> wrote:

You'll have to fork the PR or use the published versión I've forked ( @nickcis/instagram-private-api).

Then you should edit your example and useconst feed = ig.feed.clips(targetUser.pk); instead of ig.feed.reelsMedia({ userIds: [targetUser.pk] });. You should avoid the seen call.

— Reply to this email directly, view it on GitHub https://github.com/dilame/instagram-private-api/issues/1733#issuecomment-1836434782, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPI5XOQOYAO44M4WIHOVULYHIB2JAVCNFSM6AAAAAA7MQCS5SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZWGQZTINZYGI . You are receiving this because you authored the thread.Message ID: @.***>