Skip to content

Commit

Permalink
feat: formatHiglight
Browse files Browse the repository at this point in the history
  • Loading branch information
Gimenz committed Mar 13, 2024
1 parent 1f88c0b commit 1a9ac3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "insta-fetcher",
"version": "1.3.33",
"version": "1.3.34",
"description": "Simplified Instagram metadata scraping",
"main": "./dist/index.js",
"scripts": {
Expand Down
15 changes: 8 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,26 +380,27 @@ export class igApi {
* @param {ids} ids of highlight
* @returns
*/
public _getReels = async (ids: string): Promise<ReelsMediaData[]> => {
public _getReels = async (ids: string): Promise<HMedia> => {
const res = await this.FetchIGAPI(
config.instagram_base_url,
'/graphql/query/',
config.iPhone,
{ params: highlight_media_query(ids) }
)
const graphql: HMedia = res?.data;
let result: ReelsMediaData[] = graphql.data.reels_media[0].items.map((item) => ({
const graphql = res?.data;
return graphql;
}

private formatHighlight = async (graphql: HMedia): Promise<ReelsMediaData[]> => {
return graphql.data.reels_media[0].items.map((item) => ({
owner: graphql.data.reels_media[0].owner,
media_id: item.id,
mimetype: item.is_video ? 'video/mp4' || 'video/gif' : 'image/jpeg',
taken_at: item.taken_at_timestamp,
type: item.is_video ? 'video' : 'image',
url: item.is_video ? item.video_resources[0].src : item.display_url,
dimensions: item.dimensions,
...graphql
}))

return result;
}

/**
Expand All @@ -410,7 +411,7 @@ export class igApi {
public fetchHighlights = async (username: username): Promise<IHighlightsMetadata> => {
try {
const ids = await this._getReelsIds(username);
const reels = await Promise.all(ids.map(x => this._getReels(x.highlight_id)))
const reels = await Promise.all(ids.map(async x => this.formatHighlight(await this._getReels(x.highlight_id))))

let data: IReelsMetadata[] = [];
for (let i = 0; i < reels.length; i++) {
Expand Down

0 comments on commit 1a9ac3a

Please sign in to comment.