File size: 4,824 Bytes
d01810a
54a8ea6
d01810a
0f905d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b2e7404
0f905d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d01810a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c8c889d
 
5880a3e
c8c889d
 
d01810a
fdebe9c
d01810a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca5e313
e3f33e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76c0b03
e3f33e3
 
 
 
 
ec4a1b0
e3f33e3
 
 
ca5e313
e3f33e3
 
ca5e313
e3f33e3
 
 
ca5e313
 
7a598f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
const axios = require('axios');
const cheerio = require('cheerio');

async function yt(url, format) {
    const headers = {
    "accept": "*/*",
    "accept-language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
    "sec-ch-ua": "\"Not A(Brand\";v=\"8\", \"Chromium\";v=\"132\"",
    "sec-ch-ua-mobile": "?1",
    "sec-ch-ua-platform": "\"Android\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "cross-site",
    "Referer": "https://id.ytmp3.mobi/",
    "Referrer-Policy": "strict-origin-when-cross-origin"
  }

const initial = await fetch(`https://d.ymcdn.org/api/v1/init?p=y&23=1llum1n471&_=${Math.random()}`, {headers});
format =  format || 'mp3'; //mp3
const init = await initial.json();
console.log(init)

const id = url.match(/(?:youtu\.be\/|youtube\.com\/(?:.*v=|.*\/|.*embed\/))([^&?/]+)/)?.[1];
let convertURL = init.convertURL + `&v=${id}&f=${format}&_=${Math.random()}`;
//console.log(convertURL)

const converts = await fetch(convertURL, {headers});
const convert = await converts.json();
//console.log(convert)

let info = {};
for (let i = 0; i < 3; i++ ){
    let j = await fetch(convert.progressURL, {headers});
    info = await j.json();
    console.log(info);
    if (info.progress == 3) break;
}

return { url: convert.downloadURL };
};

async function tiktok(url) {
    const { data } = await axios.get(`https://www.tikwm.com/api?url=${url}&hd=1`);
    if(!data.status !== 0) return { status: false, r: 'error' };
    return { status: true, url: data.data.play, hd: data.data.hdplay, audio: data.data.music_info.play };
};

async function instagram(url) {
  const { data } = await axios.post(
    'https://yt1s.io/api/ajaxSearch',
    new URLSearchParams({
      p: 'home',
      q: url,
      w: '',
      lang: 'en'
    }),
    {
      headers: {
        'User-Agent': 'Postify/1.0.0',
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'Accept': 'application/json, text/plain, */*',
        'Origin': 'https://yt1s.io',
        'Referer': 'https://yt1s.io/'
      }
    }
  )

  const $ = cheerio.load(data.data)
  const rres = [];
  $('a.abutton.is-success.is-fullwidth.btn-premium')
    .map((_, el) => {
      rres.push($(el).attr('href'));
    })
    .get()
    return { url: rres }
}

async function threads(url) {
  try {
    const apiUrl = `https://snapthreads.net/api/download?url=${encodeURIComponent(url)}`;

    const response = await axios.get(apiUrl, {
      headers: {
        "User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Mobile Safari/537.36",
        "Referer": "https://snapthreads.net/id",
        "Accept": "*/*",
        "X-Requested-With": "XMLHttpRequest"
      }
    });
    if (response.data && response.data.directLink) {
      return {
        success: true,
        url: response.data.directLink
      };
    } else {
      return {
        success: false,
        r: 'cant find download link'
      };
    }
  } catch (error) {
    console.error("Error:", error.response ? error.response.data : error.message);
    return {
      success: false,
      r: error.response ? error.response.data : error.message
    };
  }
}

async function twitter(url) {
  try {
    const formData = new URLSearchParams();
    formData.append("q", url);
    formData.append("lang", "id");
    formData.append("cftoken", "JWT.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpcCI6IjE4Mi4xLjEzNS4yMzgiLCJ1cmwiOiJodHRwczovL3guY29tL2dhbGFzYW5zL3N0YXR1cy8xOTAxMTI5MDYyOTU1MDE2Mzk3P3Q9VTgzM0JmSExpUmRYM0NSUDVGOUhrZyZzPTE5IiwibmJmIjoxNzQyMzA0MzI2LCJleHAiOjE3NDIzMDQ2MjYsImlhdCI6MTc0MjMwNDMyNn0.h0GMNpNikiYqJgdhEEA2NN023_5fq5m7Scn31aMqYOo"); 
    const headers = {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
      "Accept": "*/*",
      "X-Requested-With": "XMLHttpRequest",
      "User-Agent":
        "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Mobile Safari/537.36",
      "Referer": "https://x2twitter.com/id",
    };
    const response = await axios.post(
      "https://x2twitter.com/api/ajaxSearch",
      formData,
      { headers }
    );
    if (response.data.status !== "ok") {
      throw new Error("Gagal mengambil data dari server.");
    }

    const html = response.data.data;
    const $ = cheerio?.load(html);
    let results = [];
    $(".dl-action a").each((_, el) => {
      const type = $(el).text().trim();
      const downloadUrl = $(el).attr("href");
      if (downloadUrl && downloadUrl !== "#") {
        results.push({ type, url: downloadUrl });
      }
    });

    return {
      success: results.length > 0,
      url: results
    };
  } catch (error) {
    return { success: false, r: error.message };
  }
}

module.exports =  { yt, tiktok, instagram, threads, twitter };