Skip to content

Commit

Permalink
fix(data): enhanced support for resonse data
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhitexe committed Jul 9, 2023
1 parent 658b50e commit 3ab0bad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 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-spider",
"version": "1.0.1",
"version": "1.0.2",
"description": "",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
Expand Down
9 changes: 8 additions & 1 deletion src/requests/fetchReel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ export async function downloadReel(link: string, cookie: string) {
// },

const videoDataJson = await videoData.data;
const { graphql, items } = videoDataJson;

return videoDataJson.graphql.shortcode_media.video_url;
if (graphql?.shortcode_media?.video_url) {
return graphql.shortcode_media.video_url;
}

if (items?.[0]?.video_versions?.[0]?.url) {
return items[0].video_versions[0].url;
}
} catch (err) {
return { error: `Error fetching video ${err}` };
}
Expand Down

0 comments on commit 3ab0bad

Please sign in to comment.