-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (31 loc) · 695 Bytes
/
index.js
File metadata and controls
36 lines (31 loc) · 695 Bytes
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
'use strict';
const got = require('got');
const msg = 'Either the video is deleted or it\'s not shared publicly!';
const lowResolution = link => {
return got(link).then(res => {
const link = res.body.split('sd_src:"')[1].split('",hd_tag')[0];
return {
url: link
};
}).catch(error => {
if (error) {
error.message = msg;
}
return error.message;
});
};
const highResolution = link => {
return got(link).then(res => {
const link = res.body.split('hd_src:"')[1].split('",sd_src:"')[0];
return {
url: link
};
}).catch(error => {
if (error) {
error.message = msg;
}
return error.message;
});
};
exports.low = lowResolution;
exports.high = highResolution;