@ubedsockets/baileys 1.3.0 → 1.4.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 +46 -16
- package/package.json +1 -1
package/lib/Utils/Tiktok.js
CHANGED
|
@@ -1,44 +1,74 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Scraper TikTok untuk @ubedsockets/baileys
|
|
5
|
+
* Menggunakan API Vreden v1
|
|
6
|
+
*/
|
|
3
7
|
async function tiktok(url) {
|
|
4
|
-
if (!url)
|
|
8
|
+
if (!url) return { status: false, message: "URL tidak boleh kosong." };
|
|
5
9
|
|
|
10
|
+
// Pastikan menggunakan endpoint v1 sesuai contohmu
|
|
6
11
|
const apiUrl = `https://api.vreden.my.id/api/v1/download/tiktok?url=${encodeURIComponent(url)}`;
|
|
7
12
|
|
|
8
13
|
try {
|
|
9
14
|
const { data } = await axios.get(apiUrl);
|
|
10
15
|
|
|
16
|
+
// Validasi status dari respon API
|
|
11
17
|
if (!data.status || !data.result) {
|
|
12
|
-
|
|
18
|
+
return {
|
|
19
|
+
status: false,
|
|
20
|
+
message: "Gagal mengambil data dari provider API Vreden."
|
|
21
|
+
};
|
|
13
22
|
}
|
|
14
23
|
|
|
15
24
|
const res = data.result;
|
|
16
25
|
|
|
26
|
+
// Mendeteksi apakah ini konten foto (slideshow) atau video
|
|
27
|
+
// Pada API Vreden, foto biasanya ditandai dengan type: "photo" di dalam array data
|
|
28
|
+
const isSlideshow = res.data.some(v => v.type === "photo");
|
|
29
|
+
|
|
17
30
|
return {
|
|
18
31
|
status: true,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
title: res.title || '-',
|
|
22
|
-
metadata: {
|
|
32
|
+
result: {
|
|
33
|
+
title: res.title || '-',
|
|
23
34
|
taken_at: res.taken_at,
|
|
24
35
|
region: res.region,
|
|
36
|
+
id: res.id,
|
|
37
|
+
durations: res.durations,
|
|
38
|
+
duration: res.duration,
|
|
39
|
+
cover: res.cover,
|
|
40
|
+
type: isSlideshow ? 'slideshow' : 'video',
|
|
41
|
+
// Metadata Author
|
|
25
42
|
author: {
|
|
26
|
-
|
|
43
|
+
id: res.author.id,
|
|
27
44
|
fullname: res.author.fullname,
|
|
45
|
+
nickname: res.author.nickname,
|
|
28
46
|
avatar: res.author.avatar
|
|
29
47
|
},
|
|
30
|
-
|
|
31
|
-
|
|
48
|
+
// Metadata Musik
|
|
49
|
+
music_info: {
|
|
50
|
+
id: res.music_info.id,
|
|
32
51
|
title: res.music_info.title,
|
|
33
52
|
author: res.music_info.author,
|
|
34
|
-
|
|
53
|
+
album: res.music_info.album,
|
|
54
|
+
url: res.music_info.url // Link MP3
|
|
55
|
+
},
|
|
56
|
+
// Statistik
|
|
57
|
+
stats: {
|
|
58
|
+
views: res.stats.views,
|
|
59
|
+
likes: res.stats.likes,
|
|
60
|
+
comment: res.stats.comment,
|
|
61
|
+
share: res.stats.share,
|
|
62
|
+
download: res.stats.download
|
|
63
|
+
},
|
|
64
|
+
// Link Download yang sudah difilter
|
|
65
|
+
data: res.data, // Menyertakan data asli (array of video/photo)
|
|
66
|
+
download: {
|
|
67
|
+
// Mengambil kualitas terbaik (HD) jika ada, jika tidak pakai normal
|
|
68
|
+
video: res.data.find(v => v.type === "nowatermark_hd")?.url || res.data.find(v => v.type === "nowatermark")?.url || null,
|
|
69
|
+
music: res.music_info.url,
|
|
70
|
+
photos: res.data.filter(v => v.type === "photo").map(v => v.url) || []
|
|
35
71
|
}
|
|
36
|
-
},
|
|
37
|
-
download: {
|
|
38
|
-
// Mencoba mencari HD dulu, kalau tidak ada pakai nowatermark biasa
|
|
39
|
-
video: res.data.find(v => v.type === "nowatermark_hd")?.url || res.data.find(v => v.type === "nowatermark")?.url || null,
|
|
40
|
-
music: res.music_info.url,
|
|
41
|
-
photos: res.data.filter(v => v.type === "photo").map(v => v.url) || []
|
|
42
72
|
}
|
|
43
73
|
};
|
|
44
74
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubedsockets/baileys",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.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",
|