-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtest.js
39 lines (36 loc) · 1.06 KB
/
test.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
import got from 'got';
import slugify from 'slugify';
import ytdl from 'ytdl-core';
const video = "https://www.facebook.com/LyricsEngsongs/videos/321854395918041/";
const YT_VIDEO = "https://www.youtube.com/watch?v=bKDdT_nyP54";
(async () => {
try {
const response = await got(video);
const seo_title = response.body.split('<title>')[1].split('</title>')[0];
const title = slugify(seo_title, {
replacement: '-',
remove: /[*+~.()'"!:@]/g,
lower: true,
strict: true
});
console.log(title);
} catch (error) {
console.log("null");
}
try {
var url = YT_VIDEO;
if (!ytdl.validateURL(url)) {
return res.sendStatus(400);
}
let info = await ytdl.getInfo(url);
const title = slugify(info.videoDetails.title, {
replacement: '-',
remove: /[*+~.()'"!:@]/g,
lower: true,
strict: false
});
console.log(title);
} catch (err) {
console.error(err);
}
})();