-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstreamtape-dl.js
61 lines (51 loc) · 1.27 KB
/
streamtape-dl.js
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
59
60
61
#!/usr/bin/env node
/*!
* Streamtape-dl
* Copyright (c) 2023
*
* @author Zubin
* @username (GitHub) losparviero
* @license AGPL-3.0
*/
// Add env vars as a preliminary
require("dotenv").config();
const st = require("streamtape");
const input = require("input");
async function getLink() {
let url;
// Input
do {
url = await input.text("Enter Streamtape link:", { default: null });
if (url == null) {
console.log("Enter a valid Streamtape link.");
} else if (!url.match(/^https:\/\/streamtape\.com\/v\/[a-zA-Z0-9]+$/)) {
console.log("Enter a valid Streamtape link.");
url = null;
}
} while (url == null);
return url;
}
async function getDownload() {
const url = await getLink();
await st
.download(url, process.env.API_USER, process.env.API_PASS)
.then(console.log)
.catch((error) => {
if (
error.message.includes(
"Cannot read properties of null (reading 'ticket')"
)
) {
console.log("Error: Wrong API parameters set.");
return;
}
if (
error.message.includes("Cannot read properties of null (reading 'url')")
) {
console.log("Error: Invalid Streamtape link.");
return;
}
console.log(error);
});
}
getDownload();