fast72 commited on
Commit
ca5e313
·
verified ·
1 Parent(s): fdebe9c

Update lib/yt.js

Browse files
Files changed (1) hide show
  1. lib/yt.js +16 -0
lib/yt.js CHANGED
@@ -100,4 +100,20 @@ async function threads(url) {
100
  }
101
  }
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  module.exports = { notube, tiktok, instagram, threads };
 
100
  }
101
  }
102
 
103
+ async function twitter(url) {
104
+ const regex = /https?:\/\/?(?:mobile\.)?(?:www\.)?(?:twitter\.com|x\.com)\/(?:\w+\/status\/)?(\d+)/;
105
+ if(!regex.test(url)) return { status: false, r: 'cant find video id' };
106
+ const match = url.match(regex);
107
+ const id = match ? match[1] : null;
108
+ const res = (await axios.get(`https://tweeload.com/download/${id}`)).data
109
+ const $ = cheerio.load(res);
110
+ const section = $('section.content__section.download_result_section');
111
+ const link = section.find('a.btn').attr('href');
112
+ const name = section.find('.download__item__profile_pic span').first().text();
113
+ const username = section.find('.download__item__profile_pic span').last().text();
114
+ return {
115
+ url: link
116
+ };
117
+ }
118
+
119
  module.exports = { notube, tiktok, instagram, threads };