Repository navigation
Expand file tree
/
Copy pathexample.ts
More file actions
58 lines (52 loc) · 1.46 KB
/
Copy pathexample.ts
File metadata and controls
58 lines (52 loc) · 1.46 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {
createPinto,
downloadImageWithFormat,
downloadVideoWithFormat,
} from "../src/index.js";
import type { Pin, UserProfile, Board } from "../src/index.js";
async function main(): Promise<void> {
const pinto = createPinto();
const pin: Pin = await pinto.getPin("https://pin.it/67v3VVvF2");
console.log("Pin:", pin.id);
console.log(" image :", pin.image);
console.log(" saves :", pin.saves);
const img = await downloadImageWithFormat(
pinto.session,
"https://pin.it/67v3VVvF2",
);
console.log(
"Image bytes:",
img.bytes.length,
"format:",
img.format,
"type:",
img.contentType,
);
const vpin: Pin = await pinto.getPin("https://pin.it/1MHcB3WGA");
console.log("Video pin:", vpin.id, "isVideo:", vpin.isVideo);
if (vpin.video !== undefined) {
console.log(" video :", vpin.video);
}
const vid = await downloadVideoWithFormat(
pinto.session,
"https://pin.it/1MHcB3WGA",
);
console.log(
"Video bytes:",
vid.bytes.length,
"format:",
vid.format,
"type:",
vid.contentType,
);
const user: UserProfile = await pinto.getUser(
"https://www.pinterest.com/Corex2410/",
);
console.log("User:", user.username, "followers:", user.followers);
const board: Board = await pinto.getBoard("https://pin.it/1XGGDuEDn");
console.log("Board:", board.name, "pins:", board.pinsCount);
}
main().catch(function (error) {
console.error("Example failed:", error);
process.exit(1);
});