Ayogiakbar

Smule Downloader

Aug 14th, 2025 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Smule Downloader
  3.  * Author : gienetic
  4.  * Base   : https://sownloader.com
  5.  */
  6.  
  7.  
  8. const axios = require("axios");
  9. const cheerio = require("cheerio");
  10.  
  11. async function smuledl(smuleUrl) {
  12.   if (!smuleUrl) return { status: false, msg: "URL Smule wajib diisi" };
  13.  
  14.   const target = "https://sownloader.com/index.php?url=" + encodeURIComponent(smuleUrl);
  15.  
  16.   try {
  17.     const { data } = await axios.get(target, {
  18.       headers: {
  19.         "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
  20.         "Accept": "text/html",
  21.       }
  22.     });
  23.  
  24.     const $ = cheerio.load(data);
  25.  
  26.     const title = $("h4 a").first().text().trim();
  27.     const smule_link = $("h4 a").attr("href");
  28.     const thumbnail = $(".sownloader-web-thumbnail").attr("src");
  29.     const description = $(".sownloader-web-thumbnail")
  30.       .closest(".row")
  31.       .find("p")
  32.       .first()
  33.       .text()
  34.       .trim();
  35.  
  36.     let audio_m4a = $("a.btn[href*='.m4a']").attr("href");
  37.     if (audio_m4a && audio_m4a.startsWith("/")) {
  38.       audio_m4a = "https://sownloader.com" + audio_m4a;
  39.     }
  40.  
  41.     let audio_mp3 = $("button.btn:contains('Download as MP3')").attr("onclick");
  42.     if (audio_mp3) {
  43.       const match = audio_mp3.match(/'(https?:\/\/[^']+\.m4a)'/);
  44.       if (match) {
  45.         audio_mp3 = "https://sownloader.com/system/modules/downloader.php?url=" +
  46.           encodeURIComponent(match[1]) +
  47.           `&name=${encodeURIComponent(title)}&ext=mp3`;
  48.       }
  49.     }
  50.  
  51.     let video_mp4 = $("a.btn[href*='.mp4']").attr("href");
  52.     if (video_mp4 && video_mp4.startsWith("/")) {
  53.       video_mp4 = "https://sownloader.com" + video_mp4;
  54.     }
  55.  
  56.     return {
  57.       status: true,
  58.       metadata: {
  59.         title,
  60.         smule_link,
  61.         thumbnail,
  62.         description
  63.       },
  64.       audio: {
  65.         m4a: audio_m4a,
  66.       },
  67.       video: {
  68.         mp4: video_mp4
  69.       }
  70.     };
  71.   } catch (err) {
  72.     return { status: false, msg: err.message };
  73.   }
  74. }
  75.  
  76. module.exports = smuledl;
  77.  
Advertisement
Add Comment
Please, Sign In to add comment