abot-scraper 1.1.0 → 1.1.2
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 +6 -4
- package/package.json +4 -3
- package/src/index.js +2 -2
- package/src/scraper/downloader.js +181 -273
- package/testing.js +90 -0
package/README.MD
CHANGED
@@ -21,9 +21,10 @@ npm i github:ahlulmukh/abot-scraper
|
|
21
21
|
For Downloader
|
22
22
|
|
23
23
|
```js
|
24
|
-
const {
|
24
|
+
const { downloader } = require("@ahlulmukh/abot-scraper");
|
25
25
|
|
26
|
-
|
26
|
+
downloader
|
27
|
+
.ytMP4("https://youtu.be/j_MlBCb9-m8?si=g6KsGM6cHNotU-rH")
|
27
28
|
.then((result) => {
|
28
29
|
console.log(result); // json;
|
29
30
|
})
|
@@ -35,9 +36,10 @@ Downloader.ytMP4("https://youtu.be/j_MlBCb9-m8?si=g6KsGM6cHNotU-rH")
|
|
35
36
|
For Search
|
36
37
|
|
37
38
|
```js
|
38
|
-
const {
|
39
|
+
const { search } = require("@ahlulmukh/abot-scraper");
|
39
40
|
|
40
|
-
|
41
|
+
search
|
42
|
+
.ytPlay("Lagu Terbaru")
|
41
43
|
.then((result) => {
|
42
44
|
console.log(result); // json;
|
43
45
|
})
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "abot-scraper",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.2",
|
4
4
|
"description": "scraper random for downloader and searching",
|
5
5
|
"main": "src/index.js",
|
6
6
|
"scripts": {
|
@@ -18,6 +18,7 @@
|
|
18
18
|
"license": "ISC",
|
19
19
|
"dependencies": {
|
20
20
|
"axios": "^1.5.1",
|
21
|
-
"cheerio": "^1.0.0-rc.12"
|
21
|
+
"cheerio": "^1.0.0-rc.12",
|
22
|
+
"qs": "^6.14.0"
|
22
23
|
}
|
23
|
-
}
|
24
|
+
}
|
package/src/index.js
CHANGED
@@ -1,307 +1,215 @@
|
|
1
1
|
const { default: axios } = require("axios");
|
2
2
|
const cheerio = require("cheerio");
|
3
|
+
const qs = require("qs");
|
3
4
|
global.creator = `@abotscraper – ahmuq`;
|
4
5
|
|
5
6
|
module.exports = class Downloader {
|
6
|
-
facebook
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
"
|
13
|
-
|
14
|
-
"
|
15
|
-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
16
|
-
Cookie:
|
17
|
-
'PHPSESSID=6jo2ggb63g5mjvgj45f612ogt7; _ga=GA1.2.405896420.1625200423; _gid=GA1.2.2135261581.1625200423; _PN_SBSCRBR_FALLBACK_DENIED=1625200785624; MarketGidStorage={"0":{},"C702514":{"page":5,"time":1625200846733}}',
|
7
|
+
async facebook(url) {
|
8
|
+
try {
|
9
|
+
const headers = {
|
10
|
+
"User-Agent":
|
11
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0",
|
12
|
+
Origin: "https://www.fdown.world",
|
13
|
+
referer: "https://www.fdown.world/",
|
14
|
+
"x-requested-with": "XMLHttpRequest",
|
15
|
+
Cookie: "codehap_domain=www.fdown.world",
|
18
16
|
};
|
19
|
-
axios("https://www.getfvid.com/downloader", {
|
20
|
-
method: "POST",
|
21
|
-
data: new URLSearchParams(Object.entries(config)),
|
22
|
-
headers: headerss,
|
23
|
-
})
|
24
|
-
.then(({ data }) => {
|
25
|
-
const $ = cheerio.load(data);
|
26
|
-
const title = $(".card-title a").text().trim();
|
27
|
-
const links = {
|
28
|
-
hd: "",
|
29
|
-
sd: "",
|
30
|
-
audio: "",
|
31
|
-
};
|
32
17
|
|
33
|
-
|
34
|
-
const link = $(element).attr("href");
|
35
|
-
const text = $(element).text();
|
36
|
-
if (text.includes("HD Quality")) {
|
37
|
-
links.hd = link;
|
38
|
-
} else if (text.includes("Normal Quality")) {
|
39
|
-
links.sd = link;
|
40
|
-
} else if (text.includes("Audio Only")) {
|
41
|
-
links.audio = link;
|
42
|
-
}
|
43
|
-
});
|
18
|
+
const data = new URLSearchParams({ codehap_link: url, codehap: "true" });
|
44
19
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
hd: links.hd,
|
51
|
-
sd: links.sd,
|
52
|
-
audio: links.audio,
|
53
|
-
},
|
54
|
-
});
|
55
|
-
})
|
56
|
-
.catch(reject);
|
57
|
-
});
|
58
|
-
};
|
20
|
+
const response = await axios.post(
|
21
|
+
"https://www.fdown.world/result.php",
|
22
|
+
data,
|
23
|
+
{ headers }
|
24
|
+
);
|
59
25
|
|
60
|
-
|
61
|
-
|
62
|
-
|
26
|
+
const $ = cheerio.load(response.data);
|
27
|
+
const videoUrl = $("video source").attr("src");
|
28
|
+
const imageUrl = $("img").attr("src");
|
29
|
+
|
30
|
+
return {
|
31
|
+
creator: global.creator,
|
32
|
+
status: 200,
|
33
|
+
result: {
|
34
|
+
thumbnail: imageUrl,
|
35
|
+
videoUrl: videoUrl,
|
36
|
+
},
|
37
|
+
};
|
38
|
+
} catch (error) {
|
39
|
+
return { creator: global.creator, status: false, msg: error.message };
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
async tiktokDownloader(url) {
|
44
|
+
try {
|
45
|
+
const headers = {
|
63
46
|
"sec-ch-ua":
|
64
47
|
'" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
|
65
48
|
"user-agent":
|
66
49
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
67
50
|
};
|
68
51
|
|
69
|
-
|
52
|
+
const data = new URLSearchParams({
|
70
53
|
id: url,
|
71
54
|
locale: "en",
|
72
55
|
tt: "WmNzZDk_",
|
56
|
+
});
|
57
|
+
|
58
|
+
const response = await axios.post("https://ssstik.io/abc?url=dl", data, {
|
59
|
+
headers,
|
60
|
+
});
|
61
|
+
|
62
|
+
const $ = cheerio.load(response.data);
|
63
|
+
const title = $("p.maintext").text().trim();
|
64
|
+
const audio = $("a.download_link.music").attr("href");
|
65
|
+
const video = $("a.download_link.without_watermark").attr("href");
|
66
|
+
|
67
|
+
return {
|
68
|
+
creator: global.creator,
|
69
|
+
status: 200,
|
70
|
+
result: {
|
71
|
+
title: title,
|
72
|
+
video: video,
|
73
|
+
audio: audio,
|
74
|
+
},
|
73
75
|
};
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
})
|
79
|
-
.then(({ data }) => {
|
80
|
-
const $ = cheerio.load(data);
|
81
|
-
const title = $("p.maintext").text().trim();
|
82
|
-
const audio = $("a.download_link.music").attr("href");
|
83
|
-
const video = $("a.download_link.without_watermark").attr("href");
|
84
|
-
resolve({
|
85
|
-
creator: global.creator,
|
86
|
-
status: 200,
|
87
|
-
result: {
|
88
|
-
title: title,
|
89
|
-
video: video,
|
90
|
-
audio: audio,
|
91
|
-
},
|
92
|
-
});
|
93
|
-
})
|
94
|
-
.catch(reject);
|
95
|
-
});
|
96
|
-
};
|
76
|
+
} catch (error) {
|
77
|
+
return { creator: global.creator, status: false, msg: error.message };
|
78
|
+
}
|
79
|
+
}
|
97
80
|
|
98
|
-
igstory
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
const hasil = await axios.get(
|
108
|
-
"https://igs.sf-converter.com/api/stories/" + userId
|
109
|
-
);
|
110
|
-
const result = [];
|
111
|
-
hasil.data.result.forEach((item, index) => {
|
112
|
-
const imageUrl =
|
113
|
-
item.image_versions2 &&
|
114
|
-
item.image_versions2.candidates &&
|
115
|
-
item.image_versions2.candidates.length > 0
|
116
|
-
? item.image_versions2.candidates[0].url
|
117
|
-
: null;
|
118
|
-
const videoUrl =
|
119
|
-
item.video_versions && item.video_versions.length > 0
|
120
|
-
? item.video_versions[0].url
|
121
|
-
: null;
|
122
|
-
result.push(imageUrl);
|
123
|
-
if (videoUrl) {
|
124
|
-
result.push(videoUrl);
|
125
|
-
}
|
126
|
-
resolve({
|
127
|
-
creator: global.creator,
|
128
|
-
status: 200,
|
129
|
-
result: result,
|
130
|
-
});
|
131
|
-
});
|
132
|
-
} catch (error) {
|
133
|
-
console.log(error);
|
134
|
-
return resolve({
|
135
|
-
creator: global.creator,
|
136
|
-
status: false,
|
137
|
-
});
|
138
|
-
}
|
139
|
-
});
|
140
|
-
};
|
81
|
+
async igstory(username) {
|
82
|
+
function encodeParameter(username) {
|
83
|
+
const parameter = `-1::${username}::rJP2tBRKf6ktbRqPUBtRE9klgBWb7d`;
|
84
|
+
let encoded = Buffer.from(parameter).toString("base64");
|
85
|
+
return encoded
|
86
|
+
.replace(/[+]/g, ".")
|
87
|
+
.replace(/[/]/g, "_")
|
88
|
+
.replace(/[=]/g, "-");
|
89
|
+
}
|
141
90
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
lang_code: "en",
|
147
|
-
token: "",
|
91
|
+
try {
|
92
|
+
const headers = {
|
93
|
+
"User-Agent":
|
94
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/",
|
148
95
|
};
|
149
|
-
|
150
|
-
|
151
|
-
|
96
|
+
|
97
|
+
const encodedParameter = encodeParameter(username);
|
98
|
+
const response = await axios.get(
|
99
|
+
`https://instanavigation.net/api/v1/stories/${encodedParameter}`,
|
100
|
+
{ headers }
|
101
|
+
);
|
102
|
+
|
103
|
+
const data = response.data;
|
104
|
+
const sources = data.stories.map((story) => story.source);
|
105
|
+
|
106
|
+
return {
|
107
|
+
creator: global.creator,
|
108
|
+
status: 200,
|
109
|
+
result: {
|
110
|
+
user_info: data.user_info,
|
111
|
+
links: sources,
|
112
|
+
},
|
113
|
+
};
|
114
|
+
} catch (error) {
|
115
|
+
return { creator: global.creator, status: false, msg: error.message };
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
async instagram(url) {
|
120
|
+
try {
|
121
|
+
const config = new URLSearchParams({
|
122
|
+
url: url,
|
123
|
+
new: 2,
|
124
|
+
lang: "en",
|
125
|
+
app: "",
|
126
|
+
});
|
127
|
+
|
128
|
+
const headers = {
|
152
129
|
"user-agent":
|
153
130
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
154
|
-
Cookie:
|
155
|
-
'PHPSESSID=6jo2ggb63g5mjvgj45f612ogt7; _ga=GA1.2.405896420.1625200423; _gid=GA1.2.2135261581.1625200423; _PN_SBSCRBR_FALLBACK_DENIED=1625200785624; MarketGidStorage={"0":{},"C702514":{"page":5,"time":1625200846733}}',
|
156
131
|
};
|
157
|
-
axios("https://fastdl.app/c/", {
|
158
|
-
method: "POST",
|
159
|
-
data: new URLSearchParams(Object.entries(config)),
|
160
|
-
headers: headerss,
|
161
|
-
})
|
162
|
-
.then(({ data }) => {
|
163
|
-
const $ = cheerio.load(data);
|
164
|
-
const downloadLinks = [];
|
165
|
-
$("a[href]").each((index, element) => {
|
166
|
-
const hrefValue = $(element).attr("href");
|
167
|
-
downloadLinks.push(hrefValue);
|
168
|
-
});
|
169
|
-
resolve({
|
170
|
-
creator: global.creator,
|
171
|
-
status: 200,
|
172
|
-
result: downloadLinks,
|
173
|
-
});
|
174
|
-
})
|
175
|
-
.catch(({ error }) => {
|
176
|
-
reject(error);
|
177
|
-
});
|
178
|
-
});
|
179
|
-
};
|
180
132
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
133
|
+
const response = await axios.post(
|
134
|
+
"https://snapinsta.app/get-data.php",
|
135
|
+
config,
|
136
|
+
{ headers }
|
137
|
+
);
|
138
|
+
|
139
|
+
const downloadLinks = response.data.files
|
140
|
+
.map((file) =>
|
141
|
+
file.__type === "GraphVideo"
|
142
|
+
? { type: "video", url: file.video_url }
|
143
|
+
: file.__type === "GraphImage"
|
144
|
+
? { type: "image", url: file.download_url }
|
145
|
+
: null
|
146
|
+
)
|
147
|
+
.filter((link) => link !== null);
|
148
|
+
|
149
|
+
return {
|
150
|
+
creator: global.creator,
|
151
|
+
status: 200,
|
152
|
+
result: downloadLinks,
|
188
153
|
};
|
189
|
-
|
190
|
-
|
191
|
-
|
154
|
+
} catch (error) {
|
155
|
+
return { creator: global.creator, status: false, msg: error.message };
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
async youtubeDownloader(url) {
|
160
|
+
try {
|
161
|
+
const config = qs.stringify({ url: url, q_auto: 0, ajax: 1, lang: "en" });
|
162
|
+
|
163
|
+
const headers = {
|
192
164
|
"user-agent":
|
193
165
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
194
|
-
Cookie:
|
195
|
-
'PHPSESSID=6jo2ggb63g5mjvgj45f612ogt7; _ga=GA1.2.405896420.1625200423; _gid=GA1.2.2135261581.1625200423; _PN_SBSCRBR_FALLBACK_DENIED=1625200785624; MarketGidStorage={"0":{},"C702514":{"page":5,"time":1625200846733}}',
|
196
166
|
};
|
197
|
-
axios("https://www.y2mate.com/mates/analyzeV2/ajax", {
|
198
|
-
method: "POST",
|
199
|
-
data: new URLSearchParams(Object.entries(configd)),
|
200
|
-
headers: headerss,
|
201
|
-
})
|
202
|
-
.then(({ data }) => {
|
203
|
-
let url = "https://www.youtube.com/watch?v=" + data.vid;
|
204
|
-
let configimg = {
|
205
|
-
url: "https://www.youtube.be/" + url,
|
206
|
-
q_auto: 0,
|
207
|
-
ajax: 1,
|
208
|
-
};
|
209
|
-
let configdl = {
|
210
|
-
vid: data.vid,
|
211
|
-
k: data.links.mp3.mp3128.k,
|
212
|
-
};
|
213
|
-
let size = data.links.mp3.mp3128.size;
|
214
|
-
axios("https://www.y2mate.com/mates/en68/analyze/ajax", {
|
215
|
-
method: "POST",
|
216
|
-
data: new URLSearchParams(Object.entries(configimg)),
|
217
|
-
headers: headerss,
|
218
|
-
}).then(({ data }) => {
|
219
|
-
const $ = cheerio.load(data.result);
|
220
|
-
let img = $("div.thumbnail.cover > a > img").attr("src");
|
221
|
-
axios("https://www.y2mate.com/mates/convertV2/index", {
|
222
|
-
method: "POST",
|
223
|
-
data: new URLSearchParams(Object.entries(configdl)),
|
224
|
-
headers: headerss,
|
225
|
-
}).then(({ data }) => {
|
226
|
-
resolve({
|
227
|
-
creator: global.creator,
|
228
|
-
status: 200,
|
229
|
-
result: {
|
230
|
-
title: data.title,
|
231
|
-
ftype: data.ftype,
|
232
|
-
quality: data.fquality,
|
233
|
-
thumb: img,
|
234
|
-
size_mp3: size,
|
235
|
-
link: data.dlink,
|
236
|
-
},
|
237
|
-
});
|
238
|
-
});
|
239
|
-
});
|
240
|
-
})
|
241
|
-
.catch(reject);
|
242
|
-
});
|
243
|
-
}
|
244
167
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
168
|
+
const response = await axios.post(
|
169
|
+
"https://yt1s.net/ajax?retry=undefined&platform=youtube",
|
170
|
+
config,
|
171
|
+
{ headers }
|
172
|
+
);
|
173
|
+
|
174
|
+
const $ = cheerio.load(response.data.result);
|
175
|
+
const title = $(".caption b").text().trim();
|
176
|
+
const downloadLinks = {
|
177
|
+
"480p": $('a[data-fquality="480p"]').attr("href"),
|
178
|
+
"720p": $('a[data-fquality="720p"]').attr("href"),
|
179
|
+
"1080p": $('a[data-fquality="1080p"]').attr("href"),
|
252
180
|
};
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
181
|
+
const thumbnailUrl = $(".thumbnail.cover img").attr("src");
|
182
|
+
|
183
|
+
const mp3ConvertElement = $("#convert-mp3 a");
|
184
|
+
const hrefAttr = mp3ConvertElement.attr("href");
|
185
|
+
|
186
|
+
if (!hrefAttr) throw new Error("MP3 conversion link not found.");
|
187
|
+
|
188
|
+
const mp3ConvertTokenMatch = hrefAttr.match(
|
189
|
+
/mp3_convert_task\('(\d+)',\s*'([^']+)'\)/
|
190
|
+
);
|
191
|
+
|
192
|
+
if (!mp3ConvertTokenMatch)
|
193
|
+
throw new Error("MP3 conversion token not found.");
|
194
|
+
|
195
|
+
const mp3ConvertToken = mp3ConvertTokenMatch[2];
|
196
|
+
|
197
|
+
const mp3Response = await axios.get(
|
198
|
+
`https://api.fabdl.com/youtube/mp3-convert-task?token=${mp3ConvertToken}`
|
199
|
+
);
|
200
|
+
|
201
|
+
return {
|
202
|
+
creator: global.creator,
|
203
|
+
status: true,
|
204
|
+
result: {
|
205
|
+
title: title,
|
206
|
+
thumbnail: thumbnailUrl,
|
207
|
+
downloadLinks: downloadLinks,
|
208
|
+
mp3DownloadUrl: `https://api.fabdl.com${mp3Response.data.result.download_url}`,
|
209
|
+
},
|
260
210
|
};
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
})
|
266
|
-
.then(({ data }) => {
|
267
|
-
let url = "https://www.youtube.com/watch?v=" + data.vid;
|
268
|
-
let configimg = {
|
269
|
-
url: "https://www.youtube.be/" + url,
|
270
|
-
q_auto: 0,
|
271
|
-
ajax: 1,
|
272
|
-
};
|
273
|
-
let configdl = {
|
274
|
-
vid: data.vid,
|
275
|
-
k: data.links.mp4[135].k,
|
276
|
-
};
|
277
|
-
let size = data.links.mp4[135].size;
|
278
|
-
axios("https://www.y2mate.com/mates/en68/analyze/ajax", {
|
279
|
-
method: "POST",
|
280
|
-
data: new URLSearchParams(Object.entries(configimg)),
|
281
|
-
headers: headerss,
|
282
|
-
}).then(({ data }) => {
|
283
|
-
const $ = cheerio.load(data.result);
|
284
|
-
let img = $("div.thumbnail.cover > a > img").attr("src");
|
285
|
-
axios("https://www.y2mate.com/mates/convertV2/index", {
|
286
|
-
method: "POST",
|
287
|
-
data: new URLSearchParams(Object.entries(configdl)),
|
288
|
-
headers: headerss,
|
289
|
-
}).then(({ data }) => {
|
290
|
-
resolve({
|
291
|
-
creator: global.creator,
|
292
|
-
status: 200,
|
293
|
-
result: {
|
294
|
-
title: data.title,
|
295
|
-
ftype: data.ftype,
|
296
|
-
thumb: img,
|
297
|
-
size_mp4: size,
|
298
|
-
link: data.dlink,
|
299
|
-
},
|
300
|
-
});
|
301
|
-
});
|
302
|
-
});
|
303
|
-
})
|
304
|
-
.catch(reject);
|
305
|
-
});
|
306
|
-
};
|
211
|
+
} catch (error) {
|
212
|
+
return { creator: global.creator, status: false, msg: error.message };
|
213
|
+
}
|
214
|
+
}
|
307
215
|
};
|
package/testing.js
ADDED
@@ -0,0 +1,90 @@
|
|
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));
|