Downloader JavaScript

Pinterest Downloader

Mendownload Foto, Carousel, Video, dan GIF

JA Pinterest Downloader.javascript
src > modules > Pinterest Downloader.javascript
/**
 * Judul : Pinterest Downloader
 * Base URL : https://ssspin.io
 * Author : Cx99 - t.me/exploit99
 * Deskripsi : Mendownload  Foto, Carousel, Video, dan GIF
 * Channel : https://whatsapp.com/channel/0029VbCSF8sA89MopCVOYW06
 */

'use strict'

const axios = require('axios')
const cheerio = require('cheerio')
const FormData = require('form-data')

const BASE_URL = 'https://ssspin.io'
const HEADERS = {
	'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36',
	Accept: '*/*',
	'Accept-Language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
	Origin: BASE_URL,
	Referer: `${BASE_URL}/id`,
	'X-Requested-With': 'XMLHttpRequest'
}

async function pindown(targetUrl) {
	try {
		targetUrl = String(targetUrl || '').trim()
		if (!targetUrl) throw new Error('URL wajib diisi')

		const parsed = new URL(targetUrl)
		if (!['http:', 'https:'].includes(parsed.protocol)) throw new Error('URL tidak valid')

		const initRes = await axios.get(`${BASE_URL}/id`, {
			headers: { 'User-Agent': HEADERS['User-Agent'], Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' },
			timeout: 30000
		})

		const cookies = initRes.headers['set-cookie']
		const cookieHeader = cookies ? cookies.map(cookie => cookie.split(';')[0]).join('; ') : ''
		let vtoken = ''

		try {
			const form = new FormData()
			form.append('url', targetUrl)

			const { data } = await axios.post(`${BASE_URL}/action/token`, form, {
				headers: { ...HEADERS, ...form.getHeaders(), Cookie: cookieHeader },
				timeout: 30000
			})

			if (typeof data === 'string') vtoken = data
			else vtoken = data?.token || data?.vtoken || ''
		} catch {
			const match = initRes.data.match(/name=["']vtoken["']\s+value=["']([^"']+)["']/i) || initRes.data.match(/vtoken\s*=\s*["']([^"']+)["']/i)
			if (match) vtoken = match[1]
		}

		const form = new FormData()
		form.append('lang', 'id')
		form.append('url', targetUrl)
		if (vtoken) form.append('vtoken', vtoken)

		const { data } = await axios.post(`${BASE_URL}/action`, form, {
			headers: { ...HEADERS, ...form.getHeaders(), Cookie: cookieHeader },
			timeout: 30000
		})

		if (!data?.success || !data?.html) throw new Error('Gagal memproses data dari server')

		const $ = cheerio.load(data.html)
		let title = $('h3, h4, .title, p strong, p').not(':contains("Download")').first().text().trim()
		if (!title) title = $('h2').first().text().trim()

		const thumbnail = $('img').first().attr('src') || ''
		const downloads = []
		const seen = new Set()

		$('a, button').each((_, el) => {
			const text = $(el).text().trim().replace(/\s+/g, ' ')
			let link = $(el).attr('href') || $(el).attr('data-url') || $(el).attr('data-href')
			if (!link || link === '#' || /^javascript:/i.test(link)) return

			try {
				link = new URL(link, BASE_URL).href
			} catch {
				return
			}

			if (link.endsWith('/id') || /download lagi/i.test(text) || seen.has(link)) return
			seen.add(link)
			downloads.push({ quality: text || 'Download', url: link })
		})

		if (!downloads.length && thumbnail) {
			downloads.push({ quality: 'Download Gambar Asli', url: new URL(thumbnail, BASE_URL).href })
			for (const size of ['736x', '600x315', '564x', '474x', '170x', '236x', '136x136', '60x60']) {
				const url = thumbnail.replace('/originals/', `/${size}/`)
				if (url !== thumbnail) downloads.push({ quality: `Download Gambar [${size}]`, url })
			}
		}

		return { status: true, title, thumbnail, downloads }
	} catch (error) {
		return { status: false, message: error.response?.data?.message || error.message }
	}
}

module.exports = { pindown }

(async () => {
	const { pindown } = require('./pindown')

	const result = await pindown('https://pin.it/xxxxx')
	console.log(JSON.stringify(result, null, 2))
})()
Kembali ke Home
Home Search Request Owner Login