Added clips (aka reels) feed#1636
Conversation
|
Looks fine to me. Though I'm not sure if we should call it |
|
I could change the name, I really don't know how to name it as there is Please tell me what name should it have, so I can change it. |
|
import 'dotenv/config'; const sessionFilePath = path.resolve(__dirname, 'session.json'); async function getReelsByUsername(ig, username) { let reels = await reelsFeed.items(); while (reelsFeed.isMoreAvailable()) { // Log detailed information about each reel // Return the mapped array }); async function saveSession(data: object) { async function sessionExists(): Promise { async function loadSession(): Promise { (async () => { if (process.env.IG_PROXY) { (ig.request.end$ as any).subscribe(async () => { if (await sessionExists()) { |
|
@NickCis plz let me know i have logged in user is these calls can be happen with non logged in users ? also can i use proxy with logged in users plz let me know what best practices to use this .Thanks for the work all you did |
|
Any way we can get this merged? It would unblock a side-project of mine a lot! |
|
I can merge this, but I can't release a new version. Note that npm and friends allow you to take file dependencies docs. |
|
I'm unblocked now but wanted to share some things I discovered. I was having some weird issues installing the branch in alpine docker, it kept saying things like: Turns out I had to change I also had to run it as non-root or else I'd get a bunch of errors that boiled down to: While I was struggling with that, I reimplemented the feature of this PR, but without the feeds API. This might be useful for anyone who's just hacking around and can't get a branch installed. I have to say, the code is incredibly straightforward and very modular. I'm impressed! Here's my hack: /**
* Gets the reels page of the given user
* Optionally provide options: {limit: 30} if you want more or less of the feed
*/
async function get_user_reels(ig, username, options) {
// Assumes ig is already logged in
const user = await ig.user.searchExact(username);
const userId = user.pk
const url = '/api/v1/clips/user/';
const form = {
target_user_id: userId,
_csrftoken: ig.state.cookieCsrfToken,
_uuid: ig.state.uuid,
}
return await get_feed_manual(ig, url, form, options);
}
/**
* Basically an implementation of "feeds" in the instagram-private-api world, but we do it ourselves.
* It recursively gets more and more items until options.limit is hit or there's no more content.
* Limit defaults to 50.
*/
async function get_feed_manual(ig, url, form, options) {
const limit = options?.limit ?? 50
const items = options?.items ?? [];
const { body } = await ig.request.send({
url,
form,
method: 'POST',
});
for (const item of body.items) {
items.push(item.media);
}
if (body.paging_info.more_available && items.length < limit) {
const newForm = {
...form,
max_id: body.paging_info.max_id,
}
const newOptions = {
...options,
items,
}
await get_feed_manual(ig, url, newForm, newOptions);
}
return items
} |
This PR implements the Clips (aka reels) Feed (#1308 )