wolfyflutter

youtube search videos [youtube] [search] [official api]

Jul 10th, 2025 (edited)
354
1
Never
8
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   nama    : youtube search
  3.   fungsi  : search video di youtube
  4.   base    : www.youtube.com
  5.   node    : v24.4.0
  6.   by      : wolep
  7.   update2 : 14 Juli 2025
  8.   fix     : empty result, filter discard live videos
  9. */
  10.  
  11. const youtubeSearch = async (query) => {
  12.     if (typeof (query) !== "string" || query.length === 0) throw Error(`invalid query`)
  13.  
  14.     const headers = {
  15.         "Accept-Encoding": "gzip, deflate, br, zstd"
  16.     }
  17.  
  18.     const body = JSON.stringify({
  19.         "context": {
  20.             "client": {
  21.                 "hl": "en", // ubah ke id kalau mau result bahasa indo
  22.                 "gl": "ID",
  23.                 "clientName": "WEB",
  24.                 "clientVersion": "2.20250701.09.00",
  25.             },
  26.         },
  27.         "params": "EgIQAQ%3D%3D",
  28.         query
  29.     });
  30.  
  31.     const response = await fetch('https://www.youtube.com/youtubei/v1/search?prettyPrint=false', { headers, body, "method": "post" })
  32.     if (!response.ok) throw Error(`${response.status} ${response.statusText}\n${await response.text()}`)
  33.     const json = await response.json()
  34.  
  35.     const result = json.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[0].itemSectionRenderer.contents
  36.         .filter(v => v?.videoRenderer?.lengthText?.simpleText).map(v => {
  37.             const vr = v.videoRenderer
  38.             const videoId = vr.videoId
  39.             const obj = {
  40.                 videoId,
  41.                 title: vr.title.runs[0].text,
  42.                 channel: vr.ownerText.runs[0].text,
  43.                 url: `https://youtu.be/${videoId}`,
  44.                 thumbnail: vr.thumbnail.thumbnails[1]?.url || vr.thumbnail.thumbnails[0]?.url,
  45.                 duration: vr.lengthText.simpleText,
  46.                 datePassed: vr.publishedTimeText?.simpleText || null,
  47.                 views: vr.shortViewCountText.simpleText
  48.             }
  49.             return obj
  50.         })
  51.  
  52.     if (result.length === 0) throw Error(`tidak bisa menemukan video dari keyword ${query}`)
  53.     return result
  54.  
  55. }
  56.  
  57. // youtubeSearch("live lofi")
  58. // .then(j => console.log(JSON.stringify(j)))
  59.  
  60.  
  61. /* output
  62. [
  63.   {
  64.     videoId: 'zPyg4N7bcHM',
  65.     title: 'Calm Your Anxiety',
  66.     channel: 'NEOTIC',
  67.     url: 'https://youtu.be/zPyg4N7bcHM',
  68.     thumbnail: 'https://img.youtube.com/vi/zPyg4N7bcHM/maxresdefault.jpg',
  69.     duration: '24:14',
  70.     datePassed: '4 years ago',
  71.     views: '22M views'
  72.   },
  73.  
  74.   (dan belasan array lainnya....)
  75.  
  76. ]
  77.  
  78. */
  79.  
  80. export default youtubeSearch
  81.  
Tags: youtube search
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Xarvekig
    15 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. 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.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Rekegbi
    5 hours
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=hhdwnjbgvr
    4.  
    5. 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.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment