LucasMod

Tiktok

Nov 17th, 2025
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 2.15 KB | Source Code | 0 0
  1. //By: π–§„ 𝐋𝐔𝐂𝐀𝐒 πŒπŽπƒ πƒπŽπŒπˆππ€ π–§„
  2. //Canal: https://whatsapp.com/channel/0029Vb69bDnAe5VmzSMwBH11
  3.  
  4. const axios = require('axios');
  5. const cheerio = require('cheerio');
  6.  
  7. async function baixarTikTok(url) {
  8. try {
  9. if (!url.includes('tiktok.com')) throw new Error('URL invΓ‘lida.');
  10. const { data: html, headers } = await axios.get('https://musicaldown.com/en');
  11. const $ = cheerio.load(html);
  12. const dadosFormulario = {};
  13. $('#submit-form input').each((i, elemento) => {
  14. const nome = $(elemento).attr('name');
  15. const valor = $(elemento).attr('value');
  16. if (nome) dadosFormulario[nome] = valor || '';
  17. });
  18. const campoUrl = Object.keys(dadosFormulario).find(chave => !dadosFormulario[chave]);
  19. if (campoUrl) dadosFormulario[campoUrl] = url;
  20. const { data } = await axios.post('https://musicaldown.com/download', new URLSearchParams(dadosFormulario).toString(), {
  21. headers: {
  22. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  23. cookie: headers['set-cookie'].join('; '),
  24. origin: 'https://musicaldown.com',
  25. referer: 'https://musicaldown.com/',
  26. 'user-agent': 'Mozilla/5.0 (Linux; Android 15; SM-F958 Build/AP3A.240905.015) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.86 Mobile Safari/537.36'
  27. }
  28. });
  29. const $$ = cheerio.load(data);
  30. const cabecalhoVideo = $$('.video-header');
  31. const imagemFundo = cabecalhoVideo.attr('style');
  32. const capaMatch = imagemFundo?.match(/url\((.*?)\)/);
  33. const downloads = [];
  34. $$('a.download').each((i, elemento) => {
  35. const $elemento = $$(elemento);
  36. const tipo = $elemento.data('event')?.replace('_download_click', '');
  37. const rotulo = $elemento.text().trim();
  38. downloads.push({
  39. tipo: tipo,
  40. rotulo: rotulo,
  41. url: $elemento.attr('href')
  42. });
  43. });
  44. return {
  45. titulo: $$('.video-desc').text().trim(),
  46. autor: {
  47. usuario: $$('.video-author b').text().trim(),
  48. avatar: $$('.img-area img').attr('src')
  49. },
  50. capa: capaMatch ? capaMatch[1] : null,
  51. downloads: downloads
  52. };
  53. } catch (erro) {
  54. throw new Error(erro.message);
  55. }
  56. }
  57.  
  58. module.exports = baixarTikTok;
  59.  
  60. // Exemplo de uso:
  61. // baixarTikTok('https://vm.tiktok.com/ZSH3eSA7UTts9-FK9xz/')
  62. // .then(console.log)
  63. // .catch(console.error);
Advertisement
Add Comment
Please, Sign In to add comment