abot-scraper 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +215 -70
- package/dist/index.cjs +575 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +123 -0
- package/dist/index.d.ts +123 -0
- package/dist/index.js +535 -0
- package/dist/index.js.map +1 -0
- package/license +21 -0
- package/package.json +66 -24
- package/types/index.d.ts +172 -0
- package/src/index.js +0 -7
- package/src/scraper/downloader.js +0 -215
- package/src/scraper/search.js +0 -144
- package/testing.js +0 -90
package/testing.js
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
const axios = require("axios");
|
2
|
-
const cheerio = require("cheerio");
|
3
|
-
|
4
|
-
function youtubeDownloader(url) {
|
5
|
-
return new Promise((resolve, reject) => {
|
6
|
-
let configd = {
|
7
|
-
url: url,
|
8
|
-
q_auto: 0,
|
9
|
-
ajax: 1,
|
10
|
-
lang: "en",
|
11
|
-
};
|
12
|
-
let headerss = {
|
13
|
-
"user-agent":
|
14
|
-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
15
|
-
};
|
16
|
-
|
17
|
-
axios
|
18
|
-
.post(
|
19
|
-
"https://yt1s.net/ajax?retry=undefined&platform=youtube",
|
20
|
-
new URLSearchParams(Object.entries(configd)),
|
21
|
-
{ headers: headerss }
|
22
|
-
)
|
23
|
-
.then(({ data }) => {
|
24
|
-
console.log(data);
|
25
|
-
const $ = cheerio.load(data.result);
|
26
|
-
|
27
|
-
// Extract title
|
28
|
-
const title = $(".caption b").text().trim();
|
29
|
-
const thumbnailUrl = $(".thumbnail.cover img").attr("src");
|
30
|
-
|
31
|
-
// Extract download links for 480p, 720p, 1080p
|
32
|
-
const downloadLinks = {
|
33
|
-
"480p": $('a[data-fquality="480p"]').attr("href"),
|
34
|
-
"720p": $('a[data-fquality="720p"]').attr("href"),
|
35
|
-
"1080p": $('a[data-fquality="1080p"]').attr("href"),
|
36
|
-
};
|
37
|
-
|
38
|
-
// Extract MP3 convert token
|
39
|
-
const mp3ConvertElement = $("#convert-mp3 a");
|
40
|
-
if (!mp3ConvertElement.length) {
|
41
|
-
throw new Error("Elemen konversi MP3 tidak ditemukan");
|
42
|
-
}
|
43
|
-
|
44
|
-
const hrefAttr = mp3ConvertElement.attr("href");
|
45
|
-
if (!hrefAttr) {
|
46
|
-
throw new Error("Atribut href tidak ditemukan");
|
47
|
-
}
|
48
|
-
|
49
|
-
console.log(hrefAttr);
|
50
|
-
|
51
|
-
// Extract token from href attribute
|
52
|
-
const mp3ConvertTokenMatch = hrefAttr.match(
|
53
|
-
/mp3_convert_task\('(\d+)',\s*'([^']+)'\)/
|
54
|
-
);
|
55
|
-
|
56
|
-
if (!mp3ConvertTokenMatch || !mp3ConvertTokenMatch[2]) {
|
57
|
-
throw new Error("Token konversi MP3 tidak ditemukan");
|
58
|
-
}
|
59
|
-
|
60
|
-
const mp3ConvertToken = mp3ConvertTokenMatch[2];
|
61
|
-
|
62
|
-
// Convert MP3
|
63
|
-
axios
|
64
|
-
.get(
|
65
|
-
`https://api.fabdl.com/youtube/mp3-convert-task?token=${mp3ConvertToken}`
|
66
|
-
)
|
67
|
-
.then(({ data: mp3Data }) => {
|
68
|
-
const mp3DownloadUrl = `https://api.fabdl.com${mp3Data.result.download_url}`;
|
69
|
-
|
70
|
-
resolve({
|
71
|
-
creator: global.creator,
|
72
|
-
status: 200,
|
73
|
-
result: {
|
74
|
-
title: title,
|
75
|
-
thumbnail: thumbnailUrl,
|
76
|
-
downloadLinks: downloadLinks,
|
77
|
-
mp3DownloadUrl: mp3DownloadUrl,
|
78
|
-
},
|
79
|
-
});
|
80
|
-
})
|
81
|
-
.catch(reject);
|
82
|
-
})
|
83
|
-
.catch(reject);
|
84
|
-
});
|
85
|
-
}
|
86
|
-
|
87
|
-
// Contoh penggunaan
|
88
|
-
youtubeDownloader("https://www.youtube.com/watch?v=8JW6qzPCkE8")
|
89
|
-
.then((result) => console.log(result))
|
90
|
-
.catch((error) => console.error(error));
|