Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async () => {
- // main function, return object, throws error, param string youtube videos url and string format mp3 or mp4 (opsional)
- let ytmp3mobi = async (youtubeUrl, format="mp3") => {
- // param 1 validation
- const regYoutubeId = /https:\/\/(www.youtube.com\/watch\?v=|youtu.be\/|youtube.com\/shorts\/|youtube.com\/watch\?v=)([^&|^?]+)/
- const videoId = youtubeUrl.match(regYoutubeId)?.[2]
- if (!videoId) throw Error("cant extract youtube video id from given link. please check your youtube link")
- // param 2 validation
- const availableFormat = ["mp3", "mp4"]
- const formatIndex = availableFormat.findIndex( v => v == format.toLocaleLowerCase())
- if (formatIndex == -1) throw Error (`${format} is invalid format, available format : ${availableFormat.join(", ")}. pick one!`)
- const urlParam = {
- v: videoId, // your youtube video id 0OjISWlmM9k (example)
- f: format, // or mp4 if you want to download video
- _: Math.random()
- }
- const headers = {
- "Referer": "https://id.ytmp3.mobi/",
- }
- const fetchJson = async (url, fetchDescription) => {
- const res = await fetch(url, { headers })
- if (!res.ok) throw Error(`fetch failed on ${fetchDescription} | ${res.status} ${res.statusText}`)
- const json = await res.json()
- return json
- }
- const { convertURL } = await fetchJson("https://d.ymcdn.org/api/v1/init?p=y&23=1llum1n471&_=" + Math.random(), "get convertURL")
- const { progressURL, downloadURL } = await fetchJson(`${convertURL}&${new URLSearchParams(urlParam).toString()}`, "get progressURL and downloadURL")
- let { error, progress, title } = {}
- while (progress != 3) {
- ({ error, progress, title } = await fetchJson(progressURL, "fetch progressURL"))
- if (error) throw Error(`error found in json object after fetch progressURL, here the value of error key : ${error}`)
- let statusToPrint = progress == 1 ? "[loading]" : progress == 2 ? "[converting]" : progress == 2 ? "[ready]" : "[unkonwn]"
- statusToPrint += ` ${title}`
- console.log(statusToPrint)
- }
- const result = { title, downloadURL }
- return result
- }
- // how to use
- const youtubeUrl = "https://www.youtube.com/watch?v=WK-PlNz52FM&t=208s"
- ytmp3mobi(youtubeUrl) // or ytmp3mobi(youtubeUrl, "mp4") to download video, second param is optional, its mp3 by default if its not specified
- .then(data => console.log(data))
- .catch(error => console.log(error.message))
- })()
- /* output
- {
- title: 'G Sounds - point the star 2',
- downloadURL: 'https://dl.ymcdn.org/3d3bc76ebca890a1b0d12395b8171e00/Hlyb9urvzck'
- }
- */
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=fmwyzwdfqi
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment