fast72 commited on
Commit
0f905d5
·
verified ·
1 Parent(s): bee5ae5

Update lib/yt.js

Browse files
Files changed (1) hide show
  1. lib/yt.js +35 -28
lib/yt.js CHANGED
@@ -1,35 +1,42 @@
1
  const axios = require('axios');
2
  const cheerio = require('cheerio');
3
 
4
- async function notube(url, format, lang, subscribed) {
5
- try {
6
- const response = await axios({
7
- method: 'post',
8
- url: 'https://s53.notube.lol/recover_weight.php',
9
- headers: {
10
- 'Accept': 'text/html, */*; q=0.01',
11
- 'Accept-Language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
12
- 'Connection': 'keep-alive',
13
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
14
- 'Origin': 'https://notube.lol',
15
- 'Referer': 'https://notube.lol/',
16
- 'Sec-Fetch-Dest': 'empty',
17
- 'Sec-Fetch-Mode': 'cors',
18
- 'Sec-Fetch-Site': 'same-site',
19
- 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Mobile Safari/537.36',
20
- 'sec-ch-ua': '"Not A(Brand";v="8", "Chromium";v="132"',
21
- 'sec-ch-ua-mobile': '?1',
22
- 'sec-ch-ua-platform': '"Android"'
23
- },
24
- data: `url=${encodeURIComponent(url)}&format=${encodeURIComponent(format)}&lang=${encodeURIComponent(lang)}&subscribed=${encodeURIComponent(subscribed)}`,
25
- responseType: 'json'
26
- });
27
 
28
- return response.data;
29
- } catch (error) {
30
- console.error('Error fetching video data:', error);
31
- throw error;
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  };
34
 
35
  async function tiktok(url) {
 
1
  const axios = require('axios');
2
  const cheerio = require('cheerio');
3
 
4
+ async function yt(url, format) {
5
+ const headers = {
6
+ "accept": "*/*",
7
+ "accept-language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
8
+ "sec-ch-ua": "\"Not A(Brand\";v=\"8\", \"Chromium\";v=\"132\"",
9
+ "sec-ch-ua-mobile": "?1",
10
+ "sec-ch-ua-platform": "\"Android\"",
11
+ "sec-fetch-dest": "empty",
12
+ "sec-fetch-mode": "cors",
13
+ "sec-fetch-site": "cross-site",
14
+ "Referer": "https://id.ytmp3.mobi/",
15
+ "Referrer-Policy": "strict-origin-when-cross-origin"
16
+ }
 
 
 
 
 
 
 
 
 
 
17
 
18
+ const initial = await fetch(`https://d.ymcdn.org/api/v1/init?p=y&23=1llum1n471&_=${Math.random()}`, {headers});
19
+ let format = format || 'mp3'; //mp3
20
+ const init = await initial.json();
21
+ console.log(init)
22
+
23
+ const id = url.match(/(?:youtu\.be\/|youtube\.com\/(?:.*v=|.*\/|.*embed\/))([^&?/]+)/)?.[1];
24
+ let convertURL = init.convertURL + `&v=${id}&f=${format}&_=${Math.random()}`;
25
+ //console.log(convertURL)
26
+
27
+ const converts = await fetch(convertURL, {headers});
28
+ const convert = await converts.json();
29
+ //console.log(convert)
30
+
31
+ let info = {};
32
+ for (let i = 0; i < 3; i++ ){
33
+ let j = await fetch(convert.progressURL, {headers});
34
+ info = await j.json();
35
+ console.log(info);
36
+ if (info.progress == 3) break;
37
+ }
38
+
39
+ return { url: convert.downloadURL };
40
  };
41
 
42
  async function tiktok(url) {