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

ig.feed.reelsMedia retrieves stories instead of reels #1728

Open
5 of 6 tasks
vandrieu opened this issue Oct 17, 2023 · 1 comment
Open
5 of 6 tasks

ig.feed.reelsMedia retrieves stories instead of reels #1728

vandrieu opened this issue Oct 17, 2023 · 1 comment
Labels
bug unconfirmed This issue hasn't been read/confirmed/accepted by an admin

Comments

@vandrieu
Copy link

Requirements

Platform

  • I'm using Node.js version v18.14.2
  • I'm using electron

Description

Imagine a user who published 2 recent stories and 5 reels.

  • Expected behaviour: ig.feed.userStory returns 2 items / ig.feed.reelsMedia returns 5 items
  • Actual behaviour: ig.feed.userStory returns 2 items / ig.feed.reelsMedia returns 2 items.
    The 2 videos returned by ig.feed.reelsMedia are actually not reels, they are the 2 stories.

Example with natgeo:

1 recent story:

Capture d’écran 2023-10-17 à 17 03 25

Lots of reels:

Capture d’écran 2023-10-17 à 17 03 37

Code

import 'dotenv/config';
import { IgApiClient, ReelsMediaFeedResponseItem, UserStoryFeedResponseItemsItem } from 'instagram-private-api';

async function main() {
  console.log("----- INIT/AUTH")
  const ig = new IgApiClient()
  ig.state.generateDevice(process.env.IG_USERNAME!);
  await ig.account.login(process.env.IG_USERNAME!, process.env.IG_PASSWORD!);

  console.log("----- SEARCH USER")
  const targetUser = await ig.user.searchExact("natgeo");

  console.log("----- FETCH STORIES")
  const userStoryFeed = ig.feed.userStory(targetUser.pk);
  const stories = await userStoryFeed.items();
  console.log("🟢", `Found ${stories.length} stories:`)
  console.log("🟢", stories.map(getMediaUrl))

  console.log("----- FETCH REELS")
  const reelsFeed = ig.feed.reelsMedia({ userIds: [targetUser.pk] });
  const reels = await reelsFeed.items();
  console.log("🟢", `Found ${reels.length} reels:`)
  console.log("🟢", reels.map(getMediaUrl))

}
main()

function getMediaUrl(item: UserStoryFeedResponseItemsItem | ReelsMediaFeedResponseItem) {
  if (item.video_versions) {
    return item.video_versions[0].url
  } else {
    return item.image_versions2.candidates[0].url
  }
}

Output

----- INIT/AUTH
  ig:state Could not find ds_user_id +0ms
  ig:request Requesting POST /api/v1/qe/sync/ +0ms
  ig:request Requesting POST /api/v1/accounts/login/ +354ms
----- SEARCH USER
  ig:request Requesting GET /api/v1/users/search/ +3s
----- FETCH STORIES
  ig:request Requesting GET /api/v1/feed/user/787132/story/ +516ms
🟢 Found 1 stories:
🟢 [
  'https://scontent-cdg4-2.cdninstagram.com/v/t51.2885-15/392891143_3631602433827303_8631248491435106258_n.jpg?se=8&stp=dst-jpg_e35&efg=eyJ2ZW5jb2RlX3RhZyI6ImltYWdlX3VybGdlbi44Mjh4MTQ3Mi5zZHIifQ&_nc_ht=scontent-cdg4-2.cdninstagram.com&_nc_cat=1&_nc_ohc=SVkWxTkU1MsAX9Nre9R&edm=ALCvFkgBAAAA&ccb=7-5&ig_cache_key=MzIxNTEwNjMwMjk3OTg0OTIwNA%3D%3D.2-ccb7-5&oh=00_AfAJ5-toT5jyOAArW7XaRwq3thsHS3rOUZdfGobli-CSGw&oe=6530204D&_nc_sid=6d62aa'
]
----- FETCH REELS
  ig:request Requesting POST /api/v1/feed/reels_media/ +270ms
🟢 Found 1 reels:
🟢 [
  'https://scontent-cdg4-2.cdninstagram.com/v/t51.2885-15/392891143_3631602433827303_8631248491435106258_n.jpg?se=8&stp=dst-jpg_e35&efg=eyJ2ZW5jb2RlX3RhZyI6ImltYWdlX3VybGdlbi44Mjh4MTQ3Mi5zZHIifQ&_nc_ht=scontent-cdg4-2.cdninstagram.com&_nc_cat=1&_nc_ohc=SVkWxTkU1MsAX9Nre9R&edm=ANmP7GQBAAAA&ccb=7-5&ig_cache_key=MzIxNTEwNjMwMjk3OTg0OTIwNA%3D%3D.2-ccb7-5&oh=00_AfDsjRul1ZnljaOU_P3fH0yoJiCBx6wySb_ogap2snUtvA&oe=6530204D&_nc_sid=982cc7'
]

Even if the end of the URL changes a little bit, both images are the same. The reel is not a reel. Both images are the same and unique story image.

How can I retrieve netgeo's reels?

@vandrieu vandrieu added bug unconfirmed This issue hasn't been read/confirmed/accepted by an admin labels Oct 17, 2023
@NickCis
Copy link

NickCis commented Nov 29, 2023

You can find more info in #1308 . In Instagram Terms Reels are Stories, and Clips are Reels. Getting Reels isn't implemented by the library, I've written a PR that implemented it some time ago, but it was never merged. I believe that this library is kind of dead and the maintainers have started with a new library but it's closed source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unconfirmed This issue hasn't been read/confirmed/accepted by an admin
Projects
None yet
Development

No branches or pull requests

2 participants