home chevron_right src chevron_right Winbu.js
code

Winbu.js

JavaScript 8.62 KB 331 baris visibility 29 views
open_in_new
src/Winbu.js
/*
  Author: dann
  Request: Nanda
  Base: https://winbu.net
  Channel: https://whatsapp.com/channel/0029VbBu0IqFSAt272cmVk0F
  Fitur: News (search anime terbaru lah intinya)
  Note: no hapus cr wak
*/

(async () => {
  async function scrapeLatestAnime() {
    const axios = (await import("axios")).default
    const cheerioModule = await import("cheerio")
    const cheerio = cheerioModule.default || cheerioModule

    try {
      const { data } = await axios.get('https://winbu.net/anime-terbaru-animasu/', {
        headers: {
          'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
        }
      })
      
      const $ = cheerio.load(data)
      const animeList = []

      $('.ml-item').each((i, el) => {
        const $el = $(el)
        const $link = $el.find('a.ml-mask')
        const $infoHidden = $el.find('.info-hidden')

        animeList.push({
          title: $link.attr('title'),
          url: $link.attr('href'),
          image: $el.find('.mli-thumb').attr('src'),
          episode: $el.find('.mli-episode').text().trim(),
          duration: $el.find('.mli-waktu').text().trim(),
          views: $el.find('.mli-mvi').text().trim(),
          rating: $infoHidden.data('rating'),
          isTop: $el.find('.mli-topten').length > 0,
          topRank: $el.find('.mli-topten b').text().trim() || null
        })
      })

      return { status: true, data: animeList }

    } catch (e) {
      return { status: false, error: e.message }
    }
  }

  const output = await scrapeLatestAnime()

  if (output.status) {
    return m.reply(JSON.stringify(output.data, null, 2))
  } else {
    return m.reply(JSON.stringify(output, null, 2))
  }
})()


// Fitur: Searh (search anime menggunakan query)

(async () => {
  async function searchAnime(query) {
    const axios = (await import('axios')).default
    const cheerioModule = await import('cheerio')
    const cheerio = cheerioModule.default || cheerioModule

    try {
      const url = `https://winbu.net/?s=${encodeURIComponent(query)}`

      const { data } = await axios.get(url, {
        headers: {
          'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
        }
      })

      const $ = cheerio.load(data)
      const results = []

      $('.a-item').each((i, el) => {
        const $el = $(el)
        const $link = $el.find('a.ml-mask')

        results.push({
          title: $link.find('.judul').text().trim(),
          url: $link.attr('href'),
          thumbnail: $link.find('img.mli-thumb').attr('src'),
          type: $link.find('.mli-mvi-x').first().text().replace(/[^\w\s]/g, '').trim(),
          dateOrSeason: $link.find('.mli-mvi-x').eq(1).text().replace(/[^\w\s-]/g, '').trim(),
          description: $link.find('.mli-desc').text().trim()
        })
      })

      return {
        status: true,
        data: results
      }

    } catch (e) {
      return {
        status: false,
        error: e.message
      }
    }
  }

  const output = await searchAnime('One Piece')

  return m.reply(JSON.stringify(output, null, 2))
})()


// Fitur: Detail

(async () => {
  async function detailAnime(url) {
    const axios = (await import('axios')).default
    const cheerioModule = await import('cheerio')
    const cheerio = cheerioModule.default || cheerioModule

    try {
      const { data } = await axios.get(url, {
        headers: {
          'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
        }
      })

      const $ = cheerio.load(data)

      const result = {
        judul: $('.list-title h2').first().text().replace(/^[•●\s]+/, '').trim(),

        rating: $('.mli-mvi')
          .filter((i, el) => $(el).text().includes('Rating'))
          .text()
          .replace(/Rating\s*:\s*/i, '')
          .trim(),

        sinopsis: $('.mli-desc p').text().trim() || $('.mli-desc').first().text().trim(),

        poster: $('.mli-thumb-box .mli-thumb').attr('src') || $('.mli-thumb').first().attr('src'),

        tanggal: $('.mli-mvi')
          .filter((i, el) => $(el).find('.fa-calendar').length > 0)
          .text()
          .replace(/[^\w\s:-]/g, '')
          .trim(),

        genre: [],

        negara: '',

        episodes: [],

        trailer: ''
      }

      $('.mli-mvi a[rel="tag"]').each((i, el) => {
        result.genre.push($(el).text().trim())
      })

      const negaraEl = $('.mli-mvi').filter((i, el) => $(el).text().includes('Negara'))

      if (negaraEl.length) {
        result.negara = negaraEl.find('a').text().trim() || negaraEl.text().replace('Negara :', '').trim()
      }

      $('.tvseason .les-content a').each((i, el) => {
        result.episodes.push({
          title: $(el).text().trim(),
          url: $(el).attr('href')
        })
      })

      const trailerIframe = $('.trailer-anime iframe')

      if (trailerIframe.length) {
        result.trailer = trailerIframe.attr('src')
      }

      return {
        status: true,
        data: result
      }

    } catch (e) {
      return {
        status: false,
        error: e.message
      }
    }
  }

  const output = await detailAnime('https://winbu.net/series/one-piece-live-action-season-2/')

  return m.reply(JSON.stringify(output, null, 2))
})()


// download (masih kurang stabil) anuin sendiri aja wak

(async () => {
  async function getDownloadLinks(url) {
    const axios = (await import("axios")).default
    const cheerioModule = await import("cheerio")
    const cheerio = cheerioModule.default || cheerioModule

    try {
      const { data } = await axios.get(url, {
        headers: {
          'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
        }
      })
      
      const $ = cheerio.load(data)
      const result = {}

      result.judul = $('.list-title h2').first().text().trim()
      result.currentEpisode = $('.dropdownEpisodeList .dropdown-item a.active').text().trim()
      result.downloads = []

      $('.download-eps li').each((i, el) => {
        const $el = $(el)
        const resolusi = $el.find('strong').text().trim()
        const links = []

        $el.find('a').each((j, linkEl) => {
          const $link = $(linkEl)
          links.push({
            server: $link.text().trim(),
            url: $link.attr('href')
          })
        })

        if (resolusi) {
          result.downloads.push({ resolusi, links })
        }
      })

      if (result.downloads.length === 0) {
        $('.download-eps').find('a').each((i, el) => {
          const $link = $(el)
          const text = $link.text().trim()
          if (text && $link.attr('href')) {
            result.downloads.push({
              resolusi: text,
              url: $link.attr('href')
            })
          }
        })
      }

      result.episodes = []
      $('.dropdownEpisodeList .dropdown-item a').each((i, el) => {
        result.episodes.push({
          title: $(el).text().trim(),
          url: $(el).attr('href'),
          active: $(el).hasClass('active')
        })
      })

      result.nextEpisode = $('.nvs.rght a').attr('href') || null
      result.prevEpisode = $('.nvs').first().find('a').attr('href') || null

      return { status: true, data: result }

    } catch (e) {
      return { status: false, error: e.message }
    }
  }

  const targetUrl = "https://winbu.net/one-piece-live-action-season-2-episode-1/"
  const output = await getDownloadLinks(targetUrl)

  if (output.status) {
    return m.reply(JSON.stringify(output.data, null, 2))
  } else {
    return m.reply(JSON.stringify(output, null, 2))
  }
})()


// Jadwal nih versi jadwal

> (async () => {
  async function getJadwalRilis(hari) {
    const axios = (await import("axios")).default

    try {
      const days = {
        senin: 'monday',
        selasa: 'tuesday',
        rabu: 'wednesday',
        kamis: 'thursday',
        jumat: 'friday',
        sabtu: 'saturday',
        minggu: 'sunday'
      }

      const day = days[hari.toLowerCase()] || 'monday'

      const { data } = await axios.get('https://winbu.net/wp-json/custom/v1/all-schedule', {
        params: {
          day: day,
          perpage: 100
        },
        headers: {
          'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
        }
      })

      return { status: true, data: data }

    } catch (e) {
      return { status: false, error: e.message }
    }
  }

  const targetDay = "senin"
  const output = await getJadwalRilis(targetDay)

  if (output.status) {
    return m.reply(JSON.stringify(output.data, null, 2))
  } else {
    return m.reply(JSON.stringify(output, null, 2))
  }
})()


link

Direct URL

check Disalin!