dilame / instagram-private-api

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

Unable to get public accounts media #1517

Closed sreza78 closed 2 years ago

sreza78 commented 3 years ago

Requirements

Description

trying to get an igtv of a public instagram page, but it says media is unavailable, while it's available and anyone can see it

Code

// link = "https://www.instagram.com/tv/CTxlYjplcWE/?utm_medium=copy_link";
var id = ref.urlSegmentToInstagramId("CTxlYjplcWE");
// id = 2662073270019671428;
ig.media.info(id).then(m =>{
      .....
})
.catch(ex => { .... })

Error and Output

IgResponseError: GET /api/v1/media/2662073270019671428/info/ - 400 Bad Request; Media not found or unavailable
    at Request.handleResponseError (.../node_modules/instagram-private-api/dist/core/request.js:125:16)
    at Request.send (.../node_modules/instagram-private-api/dist/core/request.js:53:28)
    at async MediaRepository.info (.../node_modules/instagram-private-api/dist/repositories/media.repository.js:9:26)
Nerixyz commented 2 years ago

IIrc, the format should be /^\d+_\d+$/ so e.g. 32454432_45544332436632.

Nerixyz commented 2 years ago

still says login required.

GET /api/v1/media/2662073270019671428/info/ - 400 Bad Request; Media not found or unavailable

That's not login-required. If you get a login_reqiured, you need to relogin your session.

sreza78 commented 2 years ago

IIrc, the format should be /^\d+_\d+$/ so e.g. 32454432_45544332436632.

how can i get such id? the url-to-code library give me that kind of id (2662073270019671428).

Nerixyz commented 2 years ago

how can i get such id? the url-to-code library give me that kind of id (2662073270019671428).

This kind of id might work too now that I think about it. I'll take a look at it.

were talking about anonymous access here, so your comment is not appropriate.

This library or rather the IG Android API requires you to be logged in. You can't see a post in the app without being logged in.

sreza78 commented 2 years ago

how can i get such id? the url-to-code library give me that kind of id (2662073270019671428).

This kind of id might work too now that I think about it. I'll take a look at it.

were talking about anonymous access here, so your comment is not appropriate.

This library or rather the IG Android API requires you to be logged in. You can't see a post in the app without being logged in.

Tnx to you if you look at it. i just have the link and needs to get media by that link, i try this such id but it was unsuccessful

sreza78 commented 2 years ago

when i send it as an direct item, it show me that it's a "placeholder" item but of course it's "felix share" the response data is :

{
  item_id: '30111053639820498298384609236221952',
  user_id: 2153007540,
  timestamp: '1632323488606047',
  item_type: 'placeholder',
  placeholder: {
    is_linked: false,
    title: 'Post Unavailable',
    message: 'This post is unavailable.'
  },
  client_context: '6846460932261670658',
  show_forward_attribution: false,
  is_shh_mode: false,
  tq_seq_id: 2706
}
Nerixyz commented 2 years ago

it show me that it's a "placeholder"

That's because this library is emulating an outdated version of the app.

sreza78 commented 2 years ago

outdated version of the app.

@Nerixyz oh i see. can it be update? i have another issue about version of app (#1471), and there is several issues and a pull request about it.

Nerixyz commented 2 years ago

oh i see. can it be update?

Yeah there's a PR, though I can't publish a new version on npm.

sreza78 commented 2 years ago

oh i see. can it be update?

Yeah there's a PR, though I can't publish a new version on npm.

oh nice, so i will use that PR

and if you found any update about that link and id, i will be glad if you help me tnx

Nerixyz commented 2 years ago

Now that I think about it. It might be related to the version as it may not display IGTV videos.

sreza78 commented 2 years ago

@Nerixyz What is your suggestion for me to fix this problem?

Nerixyz commented 2 years ago

@Nerixyz What is your suggestion for me to fix this problem?

Basically #1471 would need to be addressed.

sreza78 commented 2 years ago

@Nerixyz What is your suggestion for me to fix this problem?

Basically #1471 would need to be addressed.

Yes, is there any ways for me to fix this for myself? or i must wait until new version of package?

Nerixyz commented 2 years ago

Yes, is there any ways for me to fix this for myself?

You can clone a repo that has updated constants. In your package.json you can specify a path dependency (docs). Though note that you have to compile the library first (npm ci && npm run build).

sreza78 commented 2 years ago

As a workaround, you can make a request like this:

GET /p/CTxlYjplcWE/?__a=1 HTTP/1.1
Host: www.instagram.com
User-Agent: Instagram 207.0.0.39.120 Android
Authorization: Bearer IGT:2:eyJkc191c2VyX2lkIjoiNDkzNzgxNzEzMzQiLCJzZXNzaW9uaW...

You can omit the last line if you under the rate limit.

Tnx, as you mention the app version on the request is different from this package app version, and it works well

sreza78 commented 2 years ago

Yes, is there any ways for me to fix this for myself?

You can clone a repo that has updated constants. In your package.json you can specify a path dependency (docs). Though note that you have to compile the library first (npm ci && npm run build).

I didn't found any packages with updated constants, is there any standard schema for that? to find updated version info and use them in repo

sreza78 commented 2 years ago

It's related to #1571