abot-scraper 1.1.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abot-scraper",
3
- "version": "1.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,8 +18,7 @@
18
18
  "license": "ISC",
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
- "tough-cookie": "^5.1.2"
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 FormData = require("form-data");
3
+ const qs = require("qs");
4
4
  global.creator = `@abotscraper – ahmuq`;
5
5
 
6
6
  module.exports = class Downloader {
7
- facebook = (url) => {
8
- return new Promise((resolve, reject) => {
9
- let headerss = {
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
- codehap_link: url,
20
- codehap: "true",
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
- axios("https://www.fdown.world/result.php", {
24
- method: "POST",
25
- data: new URLSearchParams(Object.entries(data)),
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
- resolve({
34
- creator: global.creator,
35
- status: 200,
36
- result: {
37
- thumbnail: imageUrl,
38
- videoUrl: videoUrl,
39
- },
40
- });
41
- })
42
- .catch(reject);
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 = (url) => {
47
- return new Promise((resolve, reject) => {
48
- let headers = {
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
- let config = {
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
- axios("https://ssstik.io/abc?url=dl", {
61
- method: "POST",
62
- data: new URLSearchParams(Object.entries(config)),
63
- headers: headers,
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 = (username) => {
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
- encoded = encoded
85
+ return encoded
89
86
  .replace(/[+]/g, ".")
90
87
  .replace(/[/]/g, "_")
91
88
  .replace(/[=]/g, "-");
92
-
93
- return encoded;
94
89
  }
95
- return new Promise(async (resolve) => {
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
- instagram = (url) => {
129
- return new Promise((resolve, reject) => {
130
- let config = {
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
- let headerss = {
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
- ytMP3(url) {
169
- return new Promise((resolve, reject) => {
170
- let configd = {
171
- k_query: url,
172
- k_page: "Youtube Downloader",
173
- hl: "en",
174
- q_auto: 0,
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
- let headerss = {
177
- "sec-ch-ua":
178
- '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
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
- ytMP4 = (url) => {
233
- return new Promise((resolve, reject) => {
234
- let configd = {
235
- k_query: url,
236
- k_page: "Youtube Downloader",
237
- hl: "en",
238
- q_auto: 0,
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
- let headerss = {
241
- "sec-ch-ua":
242
- '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
243
- "user-agent":
244
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
245
- Cookie:
246
- 'PHPSESSID=6jo2ggb63g5mjvgj45f612ogt7; _ga=GA1.2.405896420.1625200423; _gid=GA1.2.2135261581.1625200423; _PN_SBSCRBR_FALLBACK_DENIED=1625200785624; MarketGidStorage={"0":{},"C702514":{"page":5,"time":1625200846733}}',
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
- axios("https://www.y2mate.com/mates/analyzeV2/ajax", {
249
- method: "POST",
250
- data: new URLSearchParams(Object.entries(configd)),
251
- headers: headerss,
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
- // Import Axios (jika di Node.js)
2
- const axios = require("axios"); // Hapus baris ini jika di browser
1
+ const axios = require("axios");
2
+ const cheerio = require("cheerio");
3
3
 
4
- // Fungsi untuk meng-encode parameter
5
- function encodeParameter(username) {
6
- // Format parameter: "-1::username::token"
7
- const parameter = `-1::${username}::rJP2tBRKf6ktbRqPUBtRE9klgBWb7d`;
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
- // Encode ke Base64
10
- let encoded = Buffer.from(parameter).toString("base64");
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
- // Ganti karakter khusus
13
- encoded = encoded
14
- .replace(/[+]/g, ".")
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
- return encoded;
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
- // Fungsi untuk mengambil data story dari API menggunakan Axios
22
- async function fetchStoryData(username) {
23
- const baseUrl = "https://instanavigation.net";
24
- const encodedParameter = encodeParameter(username);
25
- const apiUrl = `${baseUrl}/api/v1/stories/${encodedParameter}`;
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
- try {
28
- // Lakukan permintaan ke API menggunakan Axios
29
- const response = await axios.get(apiUrl);
44
+ const hrefAttr = mp3ConvertElement.attr("href");
45
+ if (!hrefAttr) {
46
+ throw new Error("Atribut href tidak ditemukan");
47
+ }
30
48
 
31
- // Ambil data dari response
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
- // Contoh penggunaan
41
- (async () => {
42
- const username = "cristiano"; // Ganti dengan username yang diinginkan
43
- const storyData = await fetchStoryData(username);
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
- if (storyData) {
46
- console.log("Data Story:", storyData);
60
+ const mp3ConvertToken = mp3ConvertTokenMatch[2];
47
61
 
48
- // Simpan data ke localStorage (jika di browser)
49
- if (typeof localStorage !== "undefined" && storyData.user_info) {
50
- const userInfo = storyData.user_info;
51
- localStorage.setItem(
52
- userInfo.username,
53
- JSON.stringify([
54
- userInfo.id,
55
- userInfo.full_name,
56
- userInfo.profile_pic_url,
57
- userInfo.is_private,
58
- userInfo.is_verified,
59
- userInfo.posts,
60
- userInfo.followers,
61
- userInfo.following,
62
- Date.now(),
63
- ])
64
- );
65
- console.log("Data disimpan di localStorage.");
66
- }
67
- } else {
68
- console.log("Gagal mengambil data story.");
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));