Buat Downloader dan Search StickerLy
1const axios = require('axios');
2
3async function getStickerLyPack(url, needRelation = true) {
4 const stickerId = url.match(/sticker\.ly\/s\/([A-Z0-9]+)/i) || url.match(/sticker\.ly\/([A-Z0-9]+)/i);
5 if (!stickerId) {
6 throw new Error('Invalid sticker.ly URL. Could not extract ID.');
7 }
8
9 console.log(`Extracted sticker ID: ${stickerId}`);
10
11 try {
12 const response = await axios.get(`https://api.sticker.ly/v4/stickerPack/${stickerId}`, {
13 params: { needRelation },
14 headers: {
15 'User-Agent': 'androidapp.stickerly/3.31.0 (M2006C3LG; U; Android 29; in-ID; id;)'
16 }
17 });
18
19 return response.data;
20 } catch (error) {
21 console.error('Error fetching sticker pack:', error.message);
22 throw error;
23 }
24}
25
26async function getSearchStickerLy(keyword = 'jokowi') {
27 try {
28 const response = await axios.post(
29 'https://api.sticker.ly/v4/stickerPack/smartSearch',
30 {
31 keyword,
32 enabledKeywordSearch: true,
33 filter: {
34 extendSearchResult: false,
35 sortBy: 'RECOMMENDED',
36 languages: ['ALL'],
37 minStickerCount: 5,
38 searchBy: 'ALL',
39 stickerType: 'ALL',
40 },
41 },
42 {
43 headers: {
44 'User-Agent':
45 'androidapp.stickerly/3.31.0 (M2006C3LG; U; Android 29; in-ID; id;)',
46 'Content-Type': 'application/json',
47 },
48 }
49 );
50
51 return response.data;
52 } catch (error) {
53 console.error(
54 'Error:',
55 error.response?.data || error.message
56 );
57 throw error;
58 }
59}
60
61/*
62// contoh penggunaan
63getSearchStickerLy('jokowi')
64 .then((data) => {
65 console.log(data);
66 })
67 .catch((err) => {
68 console.error(err);
69 });
70*/
71
72// Contoh penggunaan
73getStickerLyPack('https://sticker.ly/s/PMXSZM', true)
74 .then(result => {
75 console.log('Sticker ID:', result.id);
76 console.log('Sticker Data:', result.data);
77 })
78 .catch(err => console.error(err));Wkwkwk