Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send a video as a direct? #891

Closed
qm3ster opened this issue Sep 14, 2019 · 1 comment
Closed

How to send a video as a direct? #891

qm3ster opened this issue Sep 14, 2019 · 1 comment

Comments

@qm3ster
Copy link

qm3ster commented Sep 14, 2019

Henlo, trying to make a DM out of an mp4.

Based on what I found here:

public async broadcastPhoto(options: DirectThreadBroadcastPhotoOptions) {
const { upload_id } = await this.client.upload.photo({
uploadId: options.uploadId,
file: options.file,
});
return await this.broadcast({
item: 'configure_photo',
form: {
allow_full_aspect_ratio: options.allowFullAspectRatio || true,
upload_id,
},
});
}

I tried:

    const vidUp = await ig.upload.video({
      video: await fs.readFile(
        path.resolve(__dirname, "../data/SampleVideo_1280x720_1mb.mp4")
      ),
      duration: 5312,
      height: 720,
      width: 1280
    })
    console.log("vidUp", vidUp)

The video upload process returns: vidUp { xsharing_nonces: {}, status: 'ok' } (no upload_id in response body)

I based configure_video not just on similarity, but also these lines from mgp25/Instagram-API (see URL).

Not sure what video_result there stands for.

It's strange I am not getting an upload_id back despite the 'ok', it seems to be expected.

I also tried this:

    const uploadId = "1568498701788"
    const vidUp = await ig.upload.video({
      uploadId,
      video: await fs.readFile(
        path.resolve(__dirname, "../data/SampleVideo_1280x720_1mb.mp4")
      ),
      duration: 5312,
      height: 720,
      width: 1280
    })
    console.log("vidUp", vidUp)
    console.log("uploadId", uploadId)
    const res = await ig.directThread.broadcast({
      item: "configure_video",
      form: {
        upload_id: uploadId
      },
      threadIds: "340282366841710300949128112692906930936"
    })

which is probably stupid since the ID I should get back is probably different than the option ID. (I didn't check in the photo case, but the current code uses the returned one.)
Anyway, this gives 403 Forbidden (probably because I am referencing someone else's or nonexistent video upload).

@Nerixyz
Copy link
Collaborator

Nerixyz commented Jan 1, 2020

Should be available in the latest version:

await DirectThreadEntity.broadcastVideo({
      video: await readFileAsync(PATH_TO_FILE),
});

@qm3ster qm3ster closed this as completed Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants