Instagram-Downloader icon indicating copy to clipboard operation
Instagram-Downloader copied to clipboard

Cannot read property 'shortcode_media' of undefined

Open iAmKeyvan72 opened this issue 4 years ago • 3 comments

Hi, i could run your script to get videos on my local mac, and everything was so good. but when i deployed my code on my ubuntu vps, it gets following error:


Error happened in the submitPost , function: TypeError: Cannot read property 'shortcode_media' of undefined at getMediaType (/root/addNewSongTelegramBot/node_modules/@juliendu11/instagram-downloader/index.js:11:17) at Object.downloadMedia (/root/addNewSongTelegramBot/node_modules/@juliendu11/instagram-downloader/index.js:85:19) at process._tickCallback (internal/process/next_tick.js:68:7)


and here is my code:

const fs = require('fs');
const instagram_download = require('@juliendu11/instagram-downloader');

const { deleteFile } = require('./DeleteFile');

const instagramPostDownloader = async (url, fileName) => {
  console.log(url);
  console.log(fileName);
  const value = await instagram_download.downloadMedia(url, './dl/');
  const orgPostFilePath = './dl/' + value.file.split('/').pop();
  const newPostFilePath = './dl/' + fileName + '.mp4';
  fs.renameSync(orgPostFilePath, newPostFilePath);
  await deleteFile(value.thumbnail);
  return newPostFilePath;
};

module.exports = { instagramPostDownloader };

and this is url of instagram video post: https://www.instagram.com/p/CRY1joKgNC-/

could you please help me with this one?

iAmKeyvan72 avatar Jul 17 '21 09:07 iAmKeyvan72

same error

2021-09-26T18:53:49.012490+00:00 app[web.1]: TypeError: Cannot read property 'shortcode_media' of undefined 2021-09-26T18:53:49.012500+00:00 app[web.1]: at getMediaType (/app/node_modules/@juliendu11/instagram-downloader/index.js:11:17)

Shubhamrawat5 avatar Sep 26 '21 18:09 Shubhamrawat5

I think it is because of Axios request. Any fix?

0cto-pus avatar Jan 16 '22 00:01 0cto-pus

I think it's because instagram is not public anymore and you have to be logged in to take videos and images out of it. Maybe you can login once and use auth key to remain logged in, then use this repo to download.

iAmKeyvan72 avatar Jan 18 '22 16:01 iAmKeyvan72