@ubedsockets/baileys 1.0.0 → 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/lib/Utils/Tiktok.js +64 -0
- package/lib/Utils/facebook.js +48 -0
- package/lib/Utils/instagram.js +50 -0
- package/lib/Utils/youtube.js +44 -0
- package/lib/index.js +2 -2
- package/package.json +11 -6
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scraper TikTok untuk @ubedsockets/baileys
|
|
5
|
+
* @param {string} url - Link video atau slide TikTok
|
|
6
|
+
* @returns {Promise<Object>} Data hasil scrape
|
|
7
|
+
*/
|
|
8
|
+
async function tiktok(url) {
|
|
9
|
+
if (!url) throw new Error("URL tidak boleh kosong.");
|
|
10
|
+
|
|
11
|
+
const apiUrl = `https://api.vreden.my.id/api/v1/download/tiktok?url=${encodeURIComponent(url)}`;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const { data } = await axios.get(apiUrl);
|
|
15
|
+
|
|
16
|
+
if (!data.status || !data.result) {
|
|
17
|
+
throw new Error("Gagal mengambil data dari provider API.");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const res = data.result;
|
|
21
|
+
|
|
22
|
+
// Memetakan ulang agar response lebih bersih tapi tetap lengkap
|
|
23
|
+
return {
|
|
24
|
+
status: true,
|
|
25
|
+
type: res.data.some(v => v.type === "photo") ? 'slideshow' : 'video',
|
|
26
|
+
title: res.title || '-',
|
|
27
|
+
metadata: {
|
|
28
|
+
region: res.region,
|
|
29
|
+
taken_at: res.taken_at,
|
|
30
|
+
author: {
|
|
31
|
+
username: res.author.nickname,
|
|
32
|
+
fullname: res.author.fullname,
|
|
33
|
+
avatar: res.author.avatar
|
|
34
|
+
},
|
|
35
|
+
stats: {
|
|
36
|
+
views: res.stats.views,
|
|
37
|
+
likes: res.stats.likes,
|
|
38
|
+
comment: res.stats.comment,
|
|
39
|
+
share: res.stats.share,
|
|
40
|
+
download: res.stats.download
|
|
41
|
+
},
|
|
42
|
+
music: {
|
|
43
|
+
title: res.music_info.title,
|
|
44
|
+
author: res.music_info.author,
|
|
45
|
+
url: res.music_info.url
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
// Filter link download
|
|
49
|
+
download: {
|
|
50
|
+
video: res.data.find(v => v.type === "nowatermark")?.url || null,
|
|
51
|
+
watermark: res.data.find(v => v.type === "watermark")?.url || null,
|
|
52
|
+
photos: res.data.filter(v => v.type === "photo").map(v => v.url) || []
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
status: false,
|
|
58
|
+
message: error.message
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Export fungsi agar bisa di-require langsung
|
|
64
|
+
module.exports = tiktok;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scraper Facebook untuk @ubedsockets/baileys
|
|
5
|
+
* @param {string} url - Link video Facebook
|
|
6
|
+
* @returns {Promise<Object>} Data hasil scrape dengan format konsisten
|
|
7
|
+
*/
|
|
8
|
+
async function facebook(url) {
|
|
9
|
+
if (!url) throw new Error("URL tidak boleh kosong.");
|
|
10
|
+
|
|
11
|
+
const apiUrl = `https://api.ubed.my.id/download/facebook?apikey=alhamdulillah&url=${encodeURIComponent(url)}`;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const { data } = await axios.get(apiUrl);
|
|
15
|
+
|
|
16
|
+
if (!data.status || !data.result) {
|
|
17
|
+
throw new Error(data.message || "Gagal mendapatkan data dari Facebook.");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const res = data.result;
|
|
21
|
+
|
|
22
|
+
// Mencari resolusi terbaik (prioritas 720p atau yang paling tinggi)
|
|
23
|
+
const video720 = res.video.find(v => /720/.test(v.quality));
|
|
24
|
+
const bestVideo = video720 || [...res.video].sort((a, b) => parseInt(b.quality) - parseInt(a.quality))[0];
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
status: true,
|
|
28
|
+
title: res.title || '-',
|
|
29
|
+
metadata: {
|
|
30
|
+
duration: res.duration || '00:00',
|
|
31
|
+
thumbnail: res.thumbnail || null,
|
|
32
|
+
source: url
|
|
33
|
+
},
|
|
34
|
+
download: {
|
|
35
|
+
url: bestVideo.url,
|
|
36
|
+
quality: bestVideo.quality,
|
|
37
|
+
all_qualities: res.video // Tetap sertakan semua pilihan jika bot ingin memproses pilihan resolusi
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return {
|
|
42
|
+
status: false,
|
|
43
|
+
message: error.message
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = facebook;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scraper Instagram untuk @ubedsockets/baileys
|
|
5
|
+
* @param {string} url - Link postingan Instagram
|
|
6
|
+
* @returns {Promise<Object>} Data JSON hasil scrape
|
|
7
|
+
*/
|
|
8
|
+
async function instagram(url) {
|
|
9
|
+
if (!url) throw new Error("URL tidak boleh kosong.");
|
|
10
|
+
|
|
11
|
+
const apiUrl = `https://api.vreden.my.id/api/v1/download/instagram?url=${encodeURIComponent(url)}`;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const { data } = await axios.get(apiUrl);
|
|
15
|
+
|
|
16
|
+
if (!data.status || !data.result) {
|
|
17
|
+
throw new Error("Gagal mendapatkan data dari Instagram.");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const res = data.result;
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
status: true,
|
|
24
|
+
title: res.caption?.text || '-',
|
|
25
|
+
metadata: {
|
|
26
|
+
user: {
|
|
27
|
+
username: res.profile.username,
|
|
28
|
+
fullname: res.profile.full_name,
|
|
29
|
+
avatar: res.profile.profile_pic_url
|
|
30
|
+
},
|
|
31
|
+
stats: {
|
|
32
|
+
likes: res.statistics.like_count,
|
|
33
|
+
comments: res.statistics.comment_count
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
// List media dikembalikan sebagai array agar bot bisa handle Carousel
|
|
37
|
+
download: res.data.map(item => ({
|
|
38
|
+
type: item.type, // 'image' atau 'video'
|
|
39
|
+
url: item.url
|
|
40
|
+
}))
|
|
41
|
+
};
|
|
42
|
+
} catch (error) {
|
|
43
|
+
return {
|
|
44
|
+
status: false,
|
|
45
|
+
message: error.message
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = instagram;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scraper YouTube untuk @ubedsockets/baileys
|
|
5
|
+
* @param {string} url - Link YouTube
|
|
6
|
+
* @returns {Promise<Object>} Data JSON hasil scrape
|
|
7
|
+
*/
|
|
8
|
+
async function youtube(url) {
|
|
9
|
+
if (!url) throw new Error("URL tidak boleh kosong.");
|
|
10
|
+
|
|
11
|
+
const apiUrl = `https://api.fruatre.my.id/api/ytplay?url=${encodeURIComponent(url)}`;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const { data: res } = await axios.get(apiUrl);
|
|
15
|
+
|
|
16
|
+
if (!res.status || !res.data?.result?.dl) {
|
|
17
|
+
throw new Error("Gagal mengambil data dari YouTube.");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const meta = res.data.result;
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
status: true,
|
|
24
|
+
title: meta.title,
|
|
25
|
+
metadata: {
|
|
26
|
+
format: meta.format,
|
|
27
|
+
quality: meta.quality,
|
|
28
|
+
thumbnail: meta.thumb, // Ini yang nanti dipakai buat canvas di bot
|
|
29
|
+
size: meta.size,
|
|
30
|
+
kbps: meta.kbps
|
|
31
|
+
},
|
|
32
|
+
download: {
|
|
33
|
+
url: meta.dl
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return {
|
|
38
|
+
status: false,
|
|
39
|
+
message: error.message
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = youtube;
|
package/lib/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
const gradient = require("gradient-string");
|
|
5
5
|
|
|
6
|
-
const thanks = "terimakasih telah menggunakan @
|
|
7
|
-
const vyzen = "©
|
|
6
|
+
const thanks = "terimakasih telah menggunakan @ubedsockets/baileys";
|
|
7
|
+
const vyzen = "©ubedsockets/baileys";
|
|
8
8
|
|
|
9
9
|
const thanksColor = [
|
|
10
10
|
"#A2D2FF",
|
package/package.json
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubedsockets/baileys",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "@ubedsockets/baileys,
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "@ubedsockets/baileys,baileys A high-performance WhatsApp Web API wrapper based on Baileys, optimized for bot developers with integrated utility scrapers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"baileys",
|
|
7
7
|
"baileys-mod",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"ubed-bot",
|
|
9
|
+
"ubedsockets",
|
|
10
10
|
"whatsapp",
|
|
11
11
|
"whatsapp-api",
|
|
12
12
|
"whatsapp-web",
|
|
13
13
|
"whatsapp-bot",
|
|
14
|
+
"scrape",
|
|
15
|
+
"youtube",
|
|
16
|
+
"instagram",
|
|
17
|
+
"tiktok",
|
|
18
|
+
"facebook",
|
|
14
19
|
"automation",
|
|
15
20
|
"multi-device"
|
|
16
21
|
],
|
|
17
|
-
"homepage": "https://whatsapp.com/channel/
|
|
22
|
+
"homepage": "https://whatsapp.com/channel/",
|
|
18
23
|
"license": "MIT",
|
|
19
|
-
"author": "
|
|
24
|
+
"author": "ubed",
|
|
20
25
|
"main": "./lib/index.js",
|
|
21
26
|
"files": [
|
|
22
27
|
"lib/*",
|