|
| 1 | +// bbm — harga BBM Indonesia. Sumber: dataset terverifikasi bbm-predictor (dari |
| 2 | +// berita resmi penyesuaian Pertamina, di-host publik), bukan scraping situs SPBU. |
| 3 | +// Pertamina non-subsidi = data bulanan terverifikasi; subsidi (Pertalite/Biosolar) |
| 4 | +// = harga tetap yang dipatok pemerintah. Shell/BP/Vivo TIDAK disertakan: tidak ada |
| 5 | +// sumber data publik legal untuk itu (hanya via scraping situs mereka = di luar |
| 6 | +// prinsip jangkau). Lihat catatan di output. |
| 7 | +import { fetchJson, runChannel } from "../core.mjs"; |
| 8 | + |
| 9 | +export const meta = { |
| 10 | + name: "bbm", |
| 11 | + description: "Harga BBM Indonesia (Pertamina, dari data terverifikasi)", |
| 12 | + tier: 0, |
| 13 | + backends: ["bbm-predictor-gh"], |
| 14 | + usage: "jangkau bbm", |
| 15 | +}; |
| 16 | + |
| 17 | +const SRC = "https://raw.githubusercontent.com/ryanda9910/bbm-predictor/main/data/history.json"; |
| 18 | + |
| 19 | +// BBM subsidi: harga dipatok pemerintah (bukan formula), stabil sepanjang 2026. |
| 20 | +const SUBSIDI = [ |
| 21 | + { nama: "Pertalite (RON 90)", harga: 10000, jenis: "subsidi" }, |
| 22 | + { nama: "Biosolar (CN 48)", harga: 6800, jenis: "subsidi" }, |
| 23 | +]; |
| 24 | + |
| 25 | +const rp = (n) => `Rp${Math.round(n).toLocaleString("id-ID")}`; |
| 26 | + |
| 27 | +export async function run() { |
| 28 | + const { result } = await runChannel("bbm", { |
| 29 | + "bbm-predictor-gh": async () => { |
| 30 | + const d = await fetchJson(SRC, { timeout: 12000 }); |
| 31 | + const fuels = Object.entries(d).filter(([k]) => !k.startsWith("_")); |
| 32 | + if (!fuels.length) throw new Error("dataset kosong"); |
| 33 | + return fuels; |
| 34 | + }, |
| 35 | + }); |
| 36 | + |
| 37 | + let bulan = ""; |
| 38 | + const nonSubsidi = result.map(([nama, hist]) => { |
| 39 | + const last = hist[hist.length - 1]; |
| 40 | + bulan = last.month; |
| 41 | + return { nama, harga: rp(last.price), jenis: "non-subsidi" }; |
| 42 | + }); |
| 43 | + |
| 44 | + return { |
| 45 | + berlaku: `${bulan} (Jabodetabek, per liter)`, |
| 46 | + pertamina: [ |
| 47 | + ...SUBSIDI.map((s) => ({ ...s, harga: rp(s.harga) })), |
| 48 | + ...nonSubsidi, |
| 49 | + ], |
| 50 | + catatan: "Harga Pertamina dari data resmi terverifikasi (berita penyesuaian). Harga bisa beda antar wilayah (pajak daerah). Shell/BP/Vivo tidak tersedia: tak ada sumber data publik legal (hanya via scraping situs = di luar prinsip jangkau).", |
| 51 | + sumber: "dataset bbm-predictor (github.com/ryanda9910/bbm-predictor)", |
| 52 | + }; |
| 53 | +} |
| 54 | + |
| 55 | +export async function check() { |
| 56 | + const d = await fetchJson(SRC, { timeout: 10000 }); |
| 57 | + const turbo = d["Pertamax Turbo (RON 98)"]; |
| 58 | + if (!turbo?.length) throw new Error("format berubah"); |
| 59 | + return `Pertamax Turbo ${rp(turbo[turbo.length - 1].price)} (${turbo[turbo.length - 1].month})`; |
| 60 | +} |
0 commit comments