Skip to content

Instantly share code, notes, and snippets.

@siputzx
Created March 31, 2025 15:35
Show Gist options
  • Select an option

  • Save siputzx/0b9f12d726c6491ef5349940d3769c6b to your computer and use it in GitHub Desktop.

Select an option

Save siputzx/0b9f12d726c6491ef5349940d3769c6b to your computer and use it in GitHub Desktop.
scraper from ytdown.siputzx.my.id
const axios = require('axios');
const FormData = require('form-data');
const getVideoData = async (url, format = 'mp4') => {
try {
const formDataInfo = new FormData();
formDataInfo.append('url', url);
const { data: info } = await axios.post('https://ytdown.siputzx.my.id/api/get-info', formDataInfo, {
headers: { ...formDataInfo.getHeaders() }
});
const dl = new FormData();
dl.append('id', info.id);
dl.append('format', format);
dl.append('info', JSON.stringify(info));
const { data } = await axios.post('https://ytdown.siputzx.my.id/api/download', dl, {
headers: { ...dl.getHeaders() }
});
if (!data.download_url) {
throw new Error('Gagal mendapatkan link unduhan.');
}
return {
id: info.id,
title: info.title,
type: info.type,
album: info.album,
artist: info.artist,
description: info.description,
duration: info.duration,
upload_date: info.upload_date,
like_count: info.like_count,
view_count: info.view_count,
tags: info.tags,
thumbnail: info.thumbnail,
download_url: `https://ytdown.siputzx.my.id${data.download_url}`,
};
} catch (error) {
throw new Error(`Gagal mengambil data video: ${error.message}`);
}
};
(async () => {
const videoURL = 'https://music.youtube.com/watch?v=X4w-HqEKFyY';
const videoData = await getVideoData(videoURL, 'mp3'); //mp4
console.log(videoData);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment