tubeninja.net
by RFour · Aug 5, 2026 ·javascript
tubeninja downloader, this has a lot of url type that are supported, it's pretty cool.
DownloaderMusicMp3Mp4
| 1 | const axios = require('axios'); |
| 2 | const qs = require('querystring'); |
| 3 | |
| 4 | const client = axios.create({ |
| 5 | baseURL: 'https://www.tubeninja.net', |
| 6 | headers: { |
| 7 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36', |
| 8 | 'Accept': '*/*', |
| 9 | 'Accept-Language': 'en-US,en;q=0.9,id-ID;q=0.8,id;q=0.7', |
| 10 | 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', |
| 11 | 'X-Requested-With': 'XMLHttpRequest', |
| 12 | 'Origin': 'https://www.tubeninja.net', |
| 13 | 'sec-ch-ua': '"Chromium";v="137", "Not/A)Brand";v="24"', |
| 14 | 'sec-ch-ua-mobile': '?1', |
| 15 | 'sec-ch-ua-platform': '"Android"' |
| 16 | }, |
| 17 | withCredentials: true |
| 18 | }); |
| 19 | |
| 20 | client.interceptors.response.use(res => { |
| 21 | const cookies = res.headers['set-cookie']; |
| 22 | if (cookies && cookies.length) { |
| 23 | const cookieString = cookies.map(c => c.split(';')[0]).join('; '); |
| 24 | client.defaults.headers.common['Cookie'] = cookieString; |
| 25 | } |
| 26 | return res; |
| 27 | }); |
| 28 | |
| 29 | async function getCsrf() { |
| 30 | await client.get('/welcome'); |
| 31 | const cookie = client.defaults.headers.common['Cookie'] || ''; |
| 32 | return { |
| 33 | csrf: cookie.match(/csrftoken=([^;]+)/)?.[1] || '', |
| 34 | ga: cookie.match(/_ga=([^;]+)/)?.[1] || '', |
| 35 | ga2: cookie.match(/_ga_LJ99WGV91T=([^;]+)/)?.[1] || '' |
| 36 | }; |
| 37 | } |
| 38 | |
| 39 | function tubeninja(url) { |
| 40 | getCsrf().then(({ csrf, ga, ga2 }) => { |
| 41 | const data = { url: url, csrfmiddlewaretoken: csrf }; |
| 42 | client.post('/get', qs.stringify(data), { |
| 43 | headers: { |
| 44 | 'Cookie': 'csrftoken=' + csrf + '; _ga=' + ga + '; _ga_LJ99WGV91T=' + ga2, |
| 45 | 'Referer': 'https://www.tubeninja.net/welcome?url=' + encodeURIComponent(url) |
| 46 | } |
| 47 | }).then(res => { |
| 48 | const html = res.data; |
| 49 | const urls = html.match(/https?:\/\/[^\s"'<>]+\.(mp3|mp4|m4a|webm|jpg|jpeg|png|gif)[^\s"'<>]*/gi) || []; |
| 50 | const unique = [...new Set(urls)]; |
| 51 | unique.forEach(u => console.log(u)); |
| 52 | }).catch(err => console.error(err.message)); |
| 53 | }).catch(err => console.error(err.message)); |
| 54 | } |
| 55 | |
| 56 | tubeninja('https://on.soundcloud.com/wB4uEh8FtTLvVscRqr'); |