@ubedsockets/baileys 1.4.0 → 1.5.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 +50 -52
- package/package.json +1 -1
package/lib/Utils/Tiktok.js
CHANGED
|
@@ -1,80 +1,78 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Scraper TikTok
|
|
5
|
-
*
|
|
4
|
+
* Scraper TikTok Multi-API (Vreden & Siputzx)
|
|
5
|
+
* Mendukung Video, Audio, dan Slideshow
|
|
6
6
|
*/
|
|
7
7
|
async function tiktok(url) {
|
|
8
8
|
if (!url) return { status: false, message: "URL tidak boleh kosong." };
|
|
9
|
-
|
|
10
|
-
// Pastikan menggunakan endpoint v1 sesuai contohmu
|
|
11
|
-
const apiUrl = `https://api.vreden.my.id/api/v1/download/tiktok?url=${encodeURIComponent(url)}`;
|
|
12
|
-
|
|
9
|
+
|
|
13
10
|
try {
|
|
14
|
-
const
|
|
11
|
+
const vredenApi = `https://api.vreden.my.id/api/v1/download/tiktok?url=${encodeURIComponent(url.trim())}`;
|
|
12
|
+
const siputzxApi = `https://api.siputzx.my.id/api/d/tiktok/v2?url=${encodeURIComponent(url.trim())}`;
|
|
15
13
|
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
}
|
|
14
|
+
// Jalankan fetch secara bersamaan untuk efisiensi
|
|
15
|
+
const [vredenRes, siputzxRes] = await Promise.all([
|
|
16
|
+
axios.get(vredenApi).catch(() => ({ data: { status: false } })),
|
|
17
|
+
axios.get(siputzxApi).catch(() => ({ data: { status: false } }))
|
|
18
|
+
]);
|
|
23
19
|
|
|
24
|
-
const
|
|
20
|
+
const vreden = vredenRes.data;
|
|
21
|
+
const siput = siputzxRes.data;
|
|
22
|
+
|
|
23
|
+
// Validasi: Jika keduanya gagal, lempar error
|
|
24
|
+
if (!vreden.status && !siput.status) {
|
|
25
|
+
return { status: false, message: "Gagal mengambil data dari kedua provider API." };
|
|
26
|
+
}
|
|
25
27
|
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
// Tentukan data utama (Vreden prioritas untuk metadata, Siput prioritas untuk video/audio stabil)
|
|
29
|
+
const main = vreden.status ? vreden.result : siput.data;
|
|
30
|
+
|
|
31
|
+
// Cek apakah Slideshow
|
|
32
|
+
const isSlideshow = vreden.status
|
|
33
|
+
? main.data.some(v => v.type === "photo")
|
|
34
|
+
: (Array.isArray(siput.data?.slides) && siput.data.slides.length > 0);
|
|
29
35
|
|
|
30
36
|
return {
|
|
31
37
|
status: true,
|
|
32
38
|
result: {
|
|
33
|
-
title:
|
|
34
|
-
taken_at: res.taken_at,
|
|
35
|
-
region: res.region,
|
|
36
|
-
id: res.id,
|
|
37
|
-
durations: res.durations,
|
|
38
|
-
duration: res.duration,
|
|
39
|
-
cover: res.cover,
|
|
39
|
+
title: main.title || main.text || '-',
|
|
40
40
|
type: isSlideshow ? 'slideshow' : 'video',
|
|
41
|
-
// Metadata Author
|
|
42
41
|
author: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
avatar: res.author.avatar
|
|
42
|
+
fullname: main.author?.fullname || main.author_nickname || '-',
|
|
43
|
+
nickname: main.author?.nickname || main.author_nickname || '-',
|
|
44
|
+
avatar: main.author?.avatar || null
|
|
47
45
|
},
|
|
48
|
-
// Metadata Musik
|
|
49
|
-
music_info: {
|
|
50
|
-
id: res.music_info.id,
|
|
51
|
-
title: res.music_info.title,
|
|
52
|
-
author: res.music_info.author,
|
|
53
|
-
album: res.music_info.album,
|
|
54
|
-
url: res.music_info.url // Link MP3
|
|
55
|
-
},
|
|
56
|
-
// Statistik
|
|
57
46
|
stats: {
|
|
58
|
-
views:
|
|
59
|
-
likes:
|
|
60
|
-
comment:
|
|
61
|
-
share:
|
|
62
|
-
download: res.stats.download
|
|
47
|
+
views: main.stats?.views || main.play_count || 0,
|
|
48
|
+
likes: main.stats?.likes || main.like_count || 0,
|
|
49
|
+
comment: main.stats?.comment || main.comment_count || 0,
|
|
50
|
+
share: main.stats?.share || main.share_count || 0
|
|
63
51
|
},
|
|
64
|
-
// Link Download yang sudah difilter
|
|
65
|
-
data: res.data, // Menyertakan data asli (array of video/photo)
|
|
66
52
|
download: {
|
|
67
|
-
//
|
|
68
|
-
video:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
// Prioritas Link Video: Siput HD > Siput Normal > Vreden HD > Vreden Normal
|
|
54
|
+
video: siput.data?.no_watermark_link_hd ||
|
|
55
|
+
siput.data?.no_watermark_link ||
|
|
56
|
+
vreden.result?.data?.find(v => v.type === "nowatermark_hd")?.url ||
|
|
57
|
+
vreden.result?.data?.find(v => v.type === "nowatermark")?.url || null,
|
|
58
|
+
|
|
59
|
+
// Prioritas Audio: Siput > Vreden
|
|
60
|
+
music: siput.data?.music_link || vreden.result?.music_info?.url || null,
|
|
61
|
+
|
|
62
|
+
// Prioritas Photos: Vreden (karena struktur datanya lebih rapi untuk Baileys Carousel)
|
|
63
|
+
photos: vreden.status
|
|
64
|
+
? vreden.result.data.filter(v => v.type === "photo").map(v => v.url)
|
|
65
|
+
: (siput.data?.slides || [])
|
|
66
|
+
},
|
|
67
|
+
// Simpan data mentah jika dibutuhkan untuk debug
|
|
68
|
+
raw: { vreden: vreden.result || null, siput: siput.data || null }
|
|
72
69
|
}
|
|
73
70
|
};
|
|
71
|
+
|
|
74
72
|
} catch (error) {
|
|
75
73
|
return {
|
|
76
74
|
status: false,
|
|
77
|
-
message: error.message
|
|
75
|
+
message: "Internal Error: " + error.message
|
|
78
76
|
};
|
|
79
77
|
}
|
|
80
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubedsockets/baileys",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
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",
|