abot-scraper 1.1.1 → 1.1.3
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 +1 -1
- package/license +21 -0
- package/package.json +3 -4
- package/src/scraper/downloader.js +160 -239
- package/testing.js +80 -60
package/README.MD
CHANGED
@@ -67,4 +67,4 @@ We welcome contributions from the community. If you'd like to contribute, please
|
|
67
67
|
|
68
68
|
## License
|
69
69
|
|
70
|
-
|
70
|
+
This project is licensed under the MIT License. See [LICENSE](LICENSE) for more details.
|
package/license
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Ahlul Mukhramin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "abot-scraper",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.3",
|
4
4
|
"description": "scraper random for downloader and searching",
|
5
5
|
"main": "src/index.js",
|
6
6
|
"scripts": {
|
@@ -15,11 +15,10 @@
|
|
15
15
|
"facebook"
|
16
16
|
],
|
17
17
|
"author": "Ahlul Mukhramin",
|
18
|
-
"license": "
|
18
|
+
"license": "MIT",
|
19
19
|
"dependencies": {
|
20
20
|
"axios": "^1.5.1",
|
21
|
-
"axios-cookiejar-support": "^5.0.5",
|
22
21
|
"cheerio": "^1.0.0-rc.12",
|
23
|
-
"
|
22
|
+
"qs": "^6.14.0"
|
24
23
|
}
|
25
24
|
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
const { default: axios } = require("axios");
|
2
2
|
const cheerio = require("cheerio");
|
3
|
-
const
|
3
|
+
const qs = require("qs");
|
4
4
|
global.creator = `@abotscraper – ahmuq`;
|
5
5
|
|
6
6
|
module.exports = class Downloader {
|
7
|
-
facebook
|
8
|
-
|
9
|
-
|
7
|
+
async facebook(url) {
|
8
|
+
try {
|
9
|
+
const headers = {
|
10
10
|
"User-Agent":
|
11
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
12
|
Origin: "https://www.fdown.world",
|
@@ -15,280 +15,201 @@ module.exports = class Downloader {
|
|
15
15
|
Cookie: "codehap_domain=www.fdown.world",
|
16
16
|
};
|
17
17
|
|
18
|
-
const data = {
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
const data = new URLSearchParams({ codehap_link: url, codehap: "true" });
|
19
|
+
|
20
|
+
const response = await axios.post(
|
21
|
+
"https://www.fdown.world/result.php",
|
22
|
+
data,
|
23
|
+
{ headers }
|
24
|
+
);
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
headers: headerss,
|
27
|
-
})
|
28
|
-
.then(({ data }) => {
|
29
|
-
const $ = cheerio.load(data);
|
30
|
-
const videoUrl = $("video source").attr("src");
|
31
|
-
const imageUrl = $("img").attr("src");
|
26
|
+
const $ = cheerio.load(response.data);
|
27
|
+
const videoUrl = $("video source").attr("src");
|
28
|
+
const imageUrl = $("img").attr("src");
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
44
|
-
}
|
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
|
+
}
|
45
42
|
|
46
|
-
tiktokDownloader
|
47
|
-
|
48
|
-
|
43
|
+
async tiktokDownloader(url) {
|
44
|
+
try {
|
45
|
+
const headers = {
|
49
46
|
"sec-ch-ua":
|
50
47
|
'" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
|
51
48
|
"user-agent":
|
52
49
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
53
50
|
};
|
54
51
|
|
55
|
-
|
52
|
+
const data = new URLSearchParams({
|
56
53
|
id: url,
|
57
54
|
locale: "en",
|
58
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
|
+
},
|
59
75
|
};
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
})
|
65
|
-
.then(({ data }) => {
|
66
|
-
const $ = cheerio.load(data);
|
67
|
-
const title = $("p.maintext").text().trim();
|
68
|
-
const audio = $("a.download_link.music").attr("href");
|
69
|
-
const video = $("a.download_link.without_watermark").attr("href");
|
70
|
-
resolve({
|
71
|
-
creator: global.creator,
|
72
|
-
status: 200,
|
73
|
-
result: {
|
74
|
-
title: title,
|
75
|
-
video: video,
|
76
|
-
audio: audio,
|
77
|
-
},
|
78
|
-
});
|
79
|
-
})
|
80
|
-
.catch(reject);
|
81
|
-
});
|
82
|
-
};
|
76
|
+
} catch (error) {
|
77
|
+
return { creator: global.creator, status: false, msg: error.message };
|
78
|
+
}
|
79
|
+
}
|
83
80
|
|
84
|
-
igstory
|
81
|
+
async igstory(username) {
|
85
82
|
function encodeParameter(username) {
|
86
83
|
const parameter = `-1::${username}::rJP2tBRKf6ktbRqPUBtRE9klgBWb7d`;
|
87
84
|
let encoded = Buffer.from(parameter).toString("base64");
|
88
|
-
|
85
|
+
return encoded
|
89
86
|
.replace(/[+]/g, ".")
|
90
87
|
.replace(/[/]/g, "_")
|
91
88
|
.replace(/[=]/g, "-");
|
92
|
-
|
93
|
-
return encoded;
|
94
89
|
}
|
95
|
-
|
90
|
+
|
91
|
+
try {
|
96
92
|
const headers = {
|
97
93
|
"User-Agent":
|
98
94
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/",
|
99
95
|
};
|
100
|
-
try {
|
101
|
-
const encodedParameter = encodeParameter(username);
|
102
|
-
const storyData = await axios(
|
103
|
-
`https://instanavigation.net/api/v1/stories/${encodedParameter}`,
|
104
|
-
{
|
105
|
-
method: "GET",
|
106
|
-
headers: headers,
|
107
|
-
}
|
108
|
-
);
|
109
|
-
const data = storyData.data;
|
110
|
-
const sources = data.stories.map((story) => story.source);
|
111
|
-
return resolve({
|
112
|
-
creator: global.creator,
|
113
|
-
status: 200,
|
114
|
-
result: {
|
115
|
-
user_info: data.user_info,
|
116
|
-
links: sources,
|
117
|
-
},
|
118
|
-
});
|
119
|
-
} catch (error) {
|
120
|
-
return resolve({
|
121
|
-
creator: global.creator,
|
122
|
-
status: false,
|
123
|
-
});
|
124
|
-
}
|
125
|
-
});
|
126
|
-
};
|
127
96
|
|
128
|
-
|
129
|
-
|
130
|
-
|
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({
|
131
122
|
url: url,
|
132
123
|
new: 2,
|
133
124
|
lang: "en",
|
134
125
|
app: "",
|
135
|
-
};
|
136
|
-
|
126
|
+
});
|
127
|
+
|
128
|
+
const headers = {
|
137
129
|
"user-agent":
|
138
130
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
139
131
|
};
|
140
|
-
axios("https://snapinsta.app/get-data.php", {
|
141
|
-
method: "POST",
|
142
|
-
data: new URLSearchParams(Object.entries(config)),
|
143
|
-
headers: headerss,
|
144
|
-
})
|
145
|
-
.then(({ data }) => {
|
146
|
-
const downloadLinks = data.files
|
147
|
-
.map((file) => {
|
148
|
-
if (file.__type === "GraphVideo") {
|
149
|
-
return file.video_url;
|
150
|
-
} else if (file.__type === "GraphImage") {
|
151
|
-
return file.download_url;
|
152
|
-
}
|
153
|
-
return null;
|
154
|
-
})
|
155
|
-
.filter((link) => link !== null);
|
156
|
-
resolve({
|
157
|
-
creator: global.creator,
|
158
|
-
status: 200,
|
159
|
-
result: downloadLinks,
|
160
|
-
});
|
161
|
-
})
|
162
|
-
.catch(({ error }) => {
|
163
|
-
reject(error);
|
164
|
-
});
|
165
|
-
});
|
166
|
-
};
|
167
132
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
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,
|
175
153
|
};
|
176
|
-
|
177
|
-
|
178
|
-
|
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 = {
|
179
164
|
"user-agent":
|
180
165
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
181
|
-
Cookie:
|
182
|
-
'PHPSESSID=6jo2ggb63g5mjvgj45f612ogt7; _ga=GA1.2.405896420.1625200423; _gid=GA1.2.2135261581.1625200423; _PN_SBSCRBR_FALLBACK_DENIED=1625200785624; MarketGidStorage={"0":{},"C702514":{"page":5,"time":1625200846733}}',
|
183
166
|
};
|
184
|
-
axios("https://www.y2mate.com/mates/analyzeV2/ajax", {
|
185
|
-
method: "POST",
|
186
|
-
data: new URLSearchParams(Object.entries(configd)),
|
187
|
-
headers: headerss,
|
188
|
-
})
|
189
|
-
.then(({ data }) => {
|
190
|
-
let url = "https://www.youtube.com/watch?v=" + data.vid;
|
191
|
-
let configimg = {
|
192
|
-
url: "https://www.youtube.be/" + url,
|
193
|
-
q_auto: 0,
|
194
|
-
ajax: 1,
|
195
|
-
};
|
196
|
-
let configdl = {
|
197
|
-
vid: data.vid,
|
198
|
-
k: data.links.mp3.mp3128.k,
|
199
|
-
};
|
200
|
-
let size = data.links.mp3.mp3128.size;
|
201
|
-
axios("https://www.y2mate.com/mates/en68/analyze/ajax", {
|
202
|
-
method: "POST",
|
203
|
-
data: new URLSearchParams(Object.entries(configimg)),
|
204
|
-
headers: headerss,
|
205
|
-
}).then(({ data }) => {
|
206
|
-
const $ = cheerio.load(data.result);
|
207
|
-
let img = $("div.thumbnail.cover > a > img").attr("src");
|
208
|
-
axios("https://www.y2mate.com/mates/convertV2/index", {
|
209
|
-
method: "POST",
|
210
|
-
data: new URLSearchParams(Object.entries(configdl)),
|
211
|
-
headers: headerss,
|
212
|
-
}).then(({ data }) => {
|
213
|
-
resolve({
|
214
|
-
creator: global.creator,
|
215
|
-
status: 200,
|
216
|
-
result: {
|
217
|
-
title: data.title,
|
218
|
-
ftype: data.ftype,
|
219
|
-
quality: data.fquality,
|
220
|
-
thumb: img,
|
221
|
-
size_mp3: size,
|
222
|
-
link: data.dlink,
|
223
|
-
},
|
224
|
-
});
|
225
|
-
});
|
226
|
-
});
|
227
|
-
})
|
228
|
-
.catch(reject);
|
229
|
-
});
|
230
|
-
}
|
231
167
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
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"),
|
239
180
|
};
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
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
|
+
},
|
247
210
|
};
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
})
|
253
|
-
.then(({ data }) => {
|
254
|
-
let url = "https://www.youtube.com/watch?v=" + data.vid;
|
255
|
-
let configimg = {
|
256
|
-
url: "https://www.youtube.be/" + url,
|
257
|
-
q_auto: 0,
|
258
|
-
ajax: 1,
|
259
|
-
};
|
260
|
-
let configdl = {
|
261
|
-
vid: data.vid,
|
262
|
-
k: data.links.mp4[135].k,
|
263
|
-
};
|
264
|
-
let size = data.links.mp4[135].size;
|
265
|
-
axios("https://www.y2mate.com/mates/en68/analyze/ajax", {
|
266
|
-
method: "POST",
|
267
|
-
data: new URLSearchParams(Object.entries(configimg)),
|
268
|
-
headers: headerss,
|
269
|
-
}).then(({ data }) => {
|
270
|
-
const $ = cheerio.load(data.result);
|
271
|
-
let img = $("div.thumbnail.cover > a > img").attr("src");
|
272
|
-
axios("https://www.y2mate.com/mates/convertV2/index", {
|
273
|
-
method: "POST",
|
274
|
-
data: new URLSearchParams(Object.entries(configdl)),
|
275
|
-
headers: headerss,
|
276
|
-
}).then(({ data }) => {
|
277
|
-
resolve({
|
278
|
-
creator: global.creator,
|
279
|
-
status: 200,
|
280
|
-
result: {
|
281
|
-
title: data.title,
|
282
|
-
ftype: data.ftype,
|
283
|
-
thumb: img,
|
284
|
-
size_mp4: size,
|
285
|
-
link: data.dlink,
|
286
|
-
},
|
287
|
-
});
|
288
|
-
});
|
289
|
-
});
|
290
|
-
})
|
291
|
-
.catch(reject);
|
292
|
-
});
|
293
|
-
};
|
211
|
+
} catch (error) {
|
212
|
+
return { creator: global.creator, status: false, msg: error.message };
|
213
|
+
}
|
214
|
+
}
|
294
215
|
};
|
package/testing.js
CHANGED
@@ -1,70 +1,90 @@
|
|
1
|
-
|
2
|
-
const
|
1
|
+
const axios = require("axios");
|
2
|
+
const cheerio = require("cheerio");
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
+
};
|
8
16
|
|
9
|
-
|
10
|
-
|
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);
|
11
26
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
.replace(/[/]/g, "_")
|
16
|
-
.replace(/[=]/g, "-");
|
27
|
+
// Extract title
|
28
|
+
const title = $(".caption b").text().trim();
|
29
|
+
const thumbnailUrl = $(".thumbnail.cover img").attr("src");
|
17
30
|
|
18
|
-
|
19
|
-
|
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
|
+
};
|
20
37
|
|
21
|
-
//
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
+
}
|
26
43
|
|
27
|
-
|
28
|
-
|
29
|
-
|
44
|
+
const hrefAttr = mp3ConvertElement.attr("href");
|
45
|
+
if (!hrefAttr) {
|
46
|
+
throw new Error("Atribut href tidak ditemukan");
|
47
|
+
}
|
30
48
|
|
31
|
-
|
32
|
-
const data = response.data;
|
33
|
-
return data;
|
34
|
-
} catch (error) {
|
35
|
-
console.error("Error fetching story data:", error.message);
|
36
|
-
return null;
|
37
|
-
}
|
38
|
-
}
|
49
|
+
console.log(hrefAttr);
|
39
50
|
|
40
|
-
//
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
+
}
|
44
59
|
|
45
|
-
|
46
|
-
console.log("Data Story:", storyData);
|
60
|
+
const mp3ConvertToken = mp3ConvertTokenMatch[2];
|
47
61
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
})
|
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));
|