@ubedsockets/baileys 1.2.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.
@@ -2,36 +2,58 @@ const axios = require('axios');
2
2
 
3
3
  /**
4
4
  * Scraper TikTok untuk @ubedsockets/baileys
5
- * @param {string} url - Link video atau slide TikTok
6
- * @returns {Promise<Object>} Data hasil scrape
5
+ * Menggunakan API Vreden v1
7
6
  */
8
7
  async function tiktok(url) {
9
- if (!url) throw new Error("URL tidak boleh kosong.");
8
+ if (!url) return { status: false, message: "URL tidak boleh kosong." };
10
9
 
10
+ // Pastikan menggunakan endpoint v1 sesuai contohmu
11
11
  const apiUrl = `https://api.vreden.my.id/api/v1/download/tiktok?url=${encodeURIComponent(url)}`;
12
12
 
13
13
  try {
14
14
  const { data } = await axios.get(apiUrl);
15
15
 
16
+ // Validasi status dari respon API
16
17
  if (!data.status || !data.result) {
17
- throw new Error("Gagal mengambil data dari provider API.");
18
+ return {
19
+ status: false,
20
+ message: "Gagal mengambil data dari provider API Vreden."
21
+ };
18
22
  }
19
23
 
20
24
  const res = data.result;
21
25
 
22
- // Memetakan ulang agar response lebih bersih tapi tetap lengkap
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
+
23
30
  return {
24
31
  status: true,
25
- type: res.data.some(v => v.type === "photo") ? 'slideshow' : 'video',
26
- title: res.title || '-',
27
- metadata: {
28
- region: res.region,
32
+ result: {
33
+ title: res.title || '-',
29
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,
40
+ type: isSlideshow ? 'slideshow' : 'video',
41
+ // Metadata Author
30
42
  author: {
31
- username: res.author.nickname,
43
+ id: res.author.id,
32
44
  fullname: res.author.fullname,
45
+ nickname: res.author.nickname,
33
46
  avatar: res.author.avatar
34
47
  },
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
35
57
  stats: {
36
58
  views: res.stats.views,
37
59
  likes: res.stats.likes,
@@ -39,17 +61,14 @@ async function tiktok(url) {
39
61
  share: res.stats.share,
40
62
  download: res.stats.download
41
63
  },
42
- music: {
43
- title: res.music_info.title,
44
- author: res.music_info.author,
45
- url: res.music_info.url
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) || []
46
71
  }
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
72
  }
54
73
  };
55
74
  } catch (error) {
@@ -60,5 +79,4 @@ async function tiktok(url) {
60
79
  }
61
80
  }
62
81
 
63
- // Export fungsi agar bisa di-require langsung
64
82
  module.exports = tiktok;
package/lib/index.js CHANGED
@@ -16,8 +16,8 @@ const thanksColor = [
16
16
 
17
17
 
18
18
  const textColor = [
19
- "#FF1E1E",
20
- "#FF6A00",
19
+ "#f70190",
20
+ "#5900ff",
21
21
  "#FFD60A"
22
22
  ];
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubedsockets/baileys",
3
- "version": "1.2.0",
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",
@@ -19,7 +19,7 @@
19
19
  "automation",
20
20
  "multi-device"
21
21
  ],
22
- "homepage": "https://whatsapp.com/channel/",
22
+ "homepage": "https://wa.me/6285147777105",
23
23
  "license": "MIT",
24
24
  "author": "ubed",
25
25
  "main": "./lib/index.js",