Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- nama : youtube search
- fungsi : search video di youtube
- base : www.youtube.com
- node : v24.4.0
- by : wolep
- update2 : 14 Juli 2025
- fix : empty result, filter discard live videos
- */
- const youtubeSearch = async (query) => {
- if (typeof (query) !== "string" || query.length === 0) throw Error(`invalid query`)
- const headers = {
- "Accept-Encoding": "gzip, deflate, br, zstd"
- }
- const body = JSON.stringify({
- "context": {
- "client": {
- "hl": "en", // ubah ke id kalau mau result bahasa indo
- "gl": "ID",
- "clientName": "WEB",
- "clientVersion": "2.20250701.09.00",
- },
- },
- "params": "EgIQAQ%3D%3D",
- query
- });
- const response = await fetch('https://www.youtube.com/youtubei/v1/search?prettyPrint=false', { headers, body, "method": "post" })
- if (!response.ok) throw Error(`${response.status} ${response.statusText}\n${await response.text()}`)
- const json = await response.json()
- const result = json.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[0].itemSectionRenderer.contents
- .filter(v => v?.videoRenderer?.lengthText?.simpleText).map(v => {
- const vr = v.videoRenderer
- const videoId = vr.videoId
- const obj = {
- videoId,
- title: vr.title.runs[0].text,
- channel: vr.ownerText.runs[0].text,
- url: `https://youtu.be/${videoId}`,
- thumbnail: vr.thumbnail.thumbnails[1]?.url || vr.thumbnail.thumbnails[0]?.url,
- duration: vr.lengthText.simpleText,
- datePassed: vr.publishedTimeText?.simpleText || null,
- views: vr.shortViewCountText.simpleText
- }
- return obj
- })
- if (result.length === 0) throw Error(`tidak bisa menemukan video dari keyword ${query}`)
- return result
- }
- // youtubeSearch("live lofi")
- // .then(j => console.log(JSON.stringify(j)))
- /* output
- [
- {
- videoId: 'zPyg4N7bcHM',
- title: 'Calm Your Anxiety',
- channel: 'NEOTIC',
- url: 'https://youtu.be/zPyg4N7bcHM',
- thumbnail: 'https://img.youtube.com/vi/zPyg4N7bcHM/maxresdefault.jpg',
- duration: '24:14',
- datePassed: '4 years ago',
- views: '22M views'
- },
- (dan belasan array lainnya....)
- ]
- */
- export default youtubeSearch
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=hhdwnjbgvr
- 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