forked from dilame/instagram-private-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload-video.example.ts
35 lines (29 loc) · 939 Bytes
/
upload-video.example.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* tslint:disable:no-console */
import { IgApiClient } from '../src';
import { readFile } from 'fs';
import { promisify } from 'util';
const readFileAsync = promisify(readFile);
const ig = new IgApiClient();
async function login() {
// basic login-procedure
ig.state.generateDevice(process.env.IG_USERNAME);
ig.state.proxyUrl = process.env.IG_PROXY;
await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
}
(async () => {
await login();
const videoPath = './myVideo.mp4';
const coverPath = './myVideoCover.jpg';
const publishResult = await ig.publish.video({
// read the file into a Buffer
video: await readFileAsync(videoPath),
coverImage: await readFileAsync(coverPath),
/*
this does also support:
caption (string), ----+
usertags, ----+----> See upload-photo.example.ts
location, ----+
*/
});
console.log(publishResult);
})();