npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xbibzlibrary/teraboxscraper

v1.0.0

Published

The ultimate, highly-optimized, and complex Terabox Downloader and Scraper library for Node.js, designed for maximum stability and cross-platform terminal compatibility. Built with modern TypeScript.

Downloads

13

Readme


🚀 Fitur Utama (Bukan Fitur Sederhana!)

Library ini dirancang untuk melampaui batas-batas scraper biasa, menawarkan kompleksitas dan keandalan tingkat tinggi:

  1. Mekanisme Multi-Tahap Canggih: Menggunakan kombinasi Web Scraping (cheerio) untuk mengekstrak parameter tersembunyi (shareid, uk, sign, timestamp) dari halaman HTML, diikuti dengan panggilan ke Internal Terabox API untuk mendapatkan direct download link yang valid.
  2. Manajemen Koneksi Powerfull: Menggunakan axios dengan custom HTTP client yang mendukung konfigurasi Proxy dan User-Agent kustom untuk menghindari rate-limiting dan blocking.
  3. Logging Terstruktur dan Menarik: Integrasi pino dan pino-pretty untuk sistem logging yang cepat, terstruktur, dan disajikan dengan indah di terminal (tanpa emoji!).
  4. Download Stream-Based dengan Progress Bar: Mendukung pengunduhan file berbasis stream yang efisien, lengkap dengan callback untuk membuat progress bar yang informatif (kecepatan, ETA, persentase) di terminal.
  5. Penanganan Error Maksimal: Setiap fungsi dikemas dalam objek ScraperResponse<T> yang secara eksplisit mengelola status success, data, dan error dengan kode kesalahan yang terperinci (E_NETWORK_FAIL, E_PARSING_FAIL, dll.).
  6. Dibangun dengan TypeScript: Memberikan type safety dan developer experience terbaik untuk proyek-proyek modern.

🛠️ Instalasi

Pastikan Anda memiliki Node.js (v18+) terinstal.

npm install @xbibzlibrary/teraboxscraper
# atau
yarn add @xbibzlibrary/teraboxscraper

📚 Dokumentasi & Cara Kerja

1. Mendapatkan Cookie (Kunci Utama)

Terabox memerlukan otentikasi untuk mengakses direct download link. Anda wajib menyediakan cookie ndus dari sesi Terabox yang sudah login.

  1. Buka Terabox di browser Anda (disarankan Chrome/Edge).
  2. Login ke akun Anda.
  3. Buka Developer Tools (F12), buka tab Application -> Storage -> Cookies.
  4. Cari cookie dengan nama ndus dan salin nilainya.
  5. Format cookie yang digunakan adalah: "lang=en; ndus=NILAI_NDUS_ANDA;"

2. Penggunaan Dasar

Berikut adalah contoh penggunaan yang kompleks namun jelas untuk mendapatkan info file dan mengunduhnya.

import { TeraboxScraper, DownloadProgress, Logger, bytesToHuman } from '@xbibzlibrary/teraboxscraper';
import * as path from 'path';

// Inisialisasi Logger untuk output terminal yang menarik
const logger = Logger.getInstance({ level: 'info', prettyPrint: true }).getLogger();

// Konfigurasi Anda
const YOUR_COOKIE = "lang=en; ndus=YOUR_NDUS_COOKIE_HERE;";
const SHARE_LINK = "https://www.terabox.app/s/xxxxxxxxxxxxxxxx";

/**
 * Fungsi progress bar kustom yang powerfull untuk terminal
 */
function customProgressBar(progress: DownloadProgress): void {
    const totalSizeHuman = bytesToHuman(progress.totalSize);
    const downloadedHuman = bytesToHuman(progress.downloaded);
    const speedHuman = bytesToHuman(progress.speedBps) + '/s';
    const eta = progress.etaSeconds === Infinity ? 'N/A' : `${progress.etaSeconds.toFixed(0)}s`;

    const barLength = 40;
    const filledLength = Math.round(barLength * progress.percentage / 100);
    const emptyLength = barLength - filledLength;
    const bar = '█'.repeat(filledLength) + '░'.repeat(emptyLength);

    process.stdout.write(
        `\r[${bar}] ${progress.percentage.toFixed(2)}% | ${downloadedHuman} / ${totalSizeHuman} | Speed: ${speedHuman} | ETA: ${eta}`
    );
}

async function startDownload() {
    try {
        // 1. Inisialisasi Scraper
        const scraper = new TeraboxScraper({
            cookie: YOUR_COOKIE,
            timeout: 60000,
            // proxy: 'http://user:pass@host:port', // Opsi Proxy
        });

        // 2. Ambil Informasi File (Tahap Scraping & API)
        logger.info(`Memproses link: ${SHARE_LINK}`);
        const infoResponse = await scraper.getFileInfo(SHARE_LINK);

        if (!infoResponse.success || !infoResponse.data) {
            logger.error('Gagal mendapatkan info file.', infoResponse.error);
            return;
        }

        const fileInfo = infoResponse.data;
        logger.info('Info File Ditemukan:', {
            Nama: fileInfo.fileName,
            Ukuran: fileInfo.fileSizeHuman,
        });

        // 3. Unduh File (Tahap Download Stream)
        const downloadDir = path.join(process.cwd(), 'downloads');
        logger.info(`Memulai pengunduhan ke: ${downloadDir}`);

        const downloadResponse = await scraper.downloadFile(
            fileInfo,
            downloadDir,
            customProgressBar // Callback progress bar
        );

        // Bersihkan baris progress bar
        process.stdout.write('\r' + ' '.repeat(100) + '\r');

        if (!downloadResponse.success || !downloadResponse.data) {
            logger.error('Pengunduhan gagal total.', downloadResponse.error);
            return;
        }

        logger.info('✅ Pengunduhan Selesai!', {
            path: downloadResponse.data.filePath,
            durasi: `${(downloadResponse.data.durationMs / 1000).toFixed(2)} detik`,
        });

    } catch (e) {
        logger.fatal('Terjadi kesalahan kritis tak terduga.', { error: e });
    }
}

startDownload();

👤 Informasi Pengembang

| Kategori | Detail | | :--- | :--- | | Author | Xbibz Official | | Telegram | t.me/XbibzOfficial | | TikTok | tiktok.com/@XbibzOfficiall | | Donasi | ko-fi.com/XbibzOfficial |


📄 Lisensi

Library ini dirilis di bawah lisensi ISC.