@ubedsockets/baileys 1.3.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 +58 -30
- package/package.json +1 -1
package/lib/Utils/Tiktok.js
CHANGED
|
@@ -1,50 +1,78 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Scraper TikTok Multi-API (Vreden & Siputzx)
|
|
5
|
+
* Mendukung Video, Audio, dan Slideshow
|
|
6
|
+
*/
|
|
3
7
|
async function tiktok(url) {
|
|
4
|
-
if (!url)
|
|
5
|
-
|
|
6
|
-
const apiUrl = `https://api.vreden.my.id/api/v1/download/tiktok?url=${encodeURIComponent(url)}`;
|
|
7
|
-
|
|
8
|
+
if (!url) return { status: false, message: "URL tidak boleh kosong." };
|
|
9
|
+
|
|
8
10
|
try {
|
|
9
|
-
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())}`;
|
|
13
|
+
|
|
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
|
+
]);
|
|
19
|
+
|
|
20
|
+
const vreden = vredenRes.data;
|
|
21
|
+
const siput = siputzxRes.data;
|
|
10
22
|
|
|
11
|
-
|
|
12
|
-
|
|
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." };
|
|
13
26
|
}
|
|
14
27
|
|
|
15
|
-
|
|
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);
|
|
16
35
|
|
|
17
36
|
return {
|
|
18
37
|
status: true,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
metadata: {
|
|
23
|
-
taken_at: res.taken_at,
|
|
24
|
-
region: res.region,
|
|
38
|
+
result: {
|
|
39
|
+
title: main.title || main.text || '-',
|
|
40
|
+
type: isSlideshow ? 'slideshow' : 'video',
|
|
25
41
|
author: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
avatar:
|
|
42
|
+
fullname: main.author?.fullname || main.author_nickname || '-',
|
|
43
|
+
nickname: main.author?.nickname || main.author_nickname || '-',
|
|
44
|
+
avatar: main.author?.avatar || null
|
|
29
45
|
},
|
|
30
|
-
stats:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
stats: {
|
|
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
|
|
51
|
+
},
|
|
52
|
+
download: {
|
|
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 }
|
|
42
69
|
}
|
|
43
70
|
};
|
|
71
|
+
|
|
44
72
|
} catch (error) {
|
|
45
73
|
return {
|
|
46
74
|
status: false,
|
|
47
|
-
message: error.message
|
|
75
|
+
message: "Internal Error: " + error.message
|
|
48
76
|
};
|
|
49
77
|
}
|
|
50
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",
|