<div align="center">
  <a href="https://subz.lk">
    <img src="https://subz.lk/wp-content/themes/subz/img/subzlk-logo.png" alt="subz.lk Logo" width="250" height="auto" />
  </a>

  <p>
    <strong>An ultra-fast, lightweight Node.js professional scraper designed for extracting Sinhala subtitles, movie metadata, and high-quality torrent links from subz.lk.</strong>
  </p>

  <p>
    <a href="https://www.npmjs.com/package/subz.lk">
      <img src="https://img.shields.io/npm/v/subz.lk.svg?style=flat-square&color=success" alt="NPM version" />
    </a>
    <a href="#license">
      <img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="License" />
    </a>
    <img src="https://img.shields.io/badge/engine-nexara-orange.svg?style=flat-square" alt="Powered by nexara" />
  </p>
  <br />
</div>

---

## 🚀 Overview

This package is engineered for developers building applications (like movie streaming apps or media centers) that require reliable access to Sinhala subtitles. It bypasses the need for heavy, slow headless browsers by utilizing advanced HTML parsing techniques, ensuring lightning-fast performance and low server resource usage.

### ✨ Key Features

* ⚡ **Blazing Fast Performance:** Built on the optimized `nexara` engine for rapid data retrieval.
* 🔍 **Smart Search:** Instantly search movies and TV shows with accurate categorization and TV episode detection.
* 📥 **Direct Subtitle Downloads:** Extracts the final, direct download URL for subtitle files, skipping intermediate pages.
* 💎 **High-Quality Torrent Extraction:** Automatically identifies and categorizes available torrent links (720p, 1080p, 3D, 4K Web/Bluray) along with their file sizes.
* 🖼️ **Advanced Image Resolving:** Intelligently bypasses lazy-loaders to fetch high-resolution poster images.
* 🛡️ **Robust & Reliable:** Includes built-in mechanisms to handle network variations and site structure changes.

---

## 📦 Installation

Install the package easily via npm:

```bash
npm install subz.lk
```

---

## 💻 Usage Examples

### 1️⃣ Search for Movies or TV Shows

Search subz.lk for any keyword and get a list of matching results with basic details.

```javascript
const SubzLK = require('subz.lk');

async function runSearch() {
    console.log('⏳ Searching subz.lk...');
    try {
        // Search for "Jurassic"
        const results = await SubzLK.search('Jurassic');
        console.log(`✅ Found ${results.length} results!`);
        // See output below for the result structure
        console.log(JSON.stringify(results.slice(0, 3), null, 2));
    } catch (error) {
        console.error('❌ Search Error:', error.message);
    }
}

runSearch();

```

<details>
<summary>⬇️ <strong>Click here to view Search Output Example</strong></summary>

```json
[
  {
    "title": "Jurassic World Rebirth (2025) Sinhala Subtitle",
    "url": "https://subz.lk/jurassic-world-rebirth-2025-sinhala-subtitle/",
    "image": "https://subz.lk/wp-content/uploads/2025/08/Jurassic-World-Rebirth-2025-Sinhala-Subtitle_SubzLK.jpg",
    "category": "English Movies",
    "isTvShow": false,
    "episodeInfo": null
  },
  {
    "title": "Jurassic World: Fallen Kingdom (2018) Sinhala Subtitle",
    "url": "https://subz.lk/jurassic-world-fallen-kingdom-2018-sinhala-subtitle/",
    "image": "https://subz.lk/wp-content/uploads/2020/10/Jurassic_World_Fallen_Kingdom_2018_Sinhala_Subtitle_SubzLK_1.jpg",
    "category": "English Movies",
    "isTvShow": false,
    "episodeInfo": null
  },
  {
    "title": "Jurassic World (2015)  Sinhala Subtitle",
    "url": "https://subz.lk/jurassic-world-2015-sinhala-subtitle/",
    "image": "https://subz.lk/wp-content/uploads/2025/06/Jurassic-World-2015-Sinhala-Subtitle_SubzLK.jpg",
    "category": "English Movies",
    "isTvShow": false,
    "episodeInfo": null
  }
]

```

</details>

### 2️⃣ Get Full Movie Details & Download Links

Fetch comprehensive details for a specific movie URL, including the direct subtitle link and all available torrent options.

```javascript
const SubzLK = require('subz.lk');

async function fetchDetails() {
    const movieUrl = 'https://subz.lk/jurassic-world-fallen-kingdom-2018-sinhala-subtitle/';
    console.log(`⏳ Fetching details for: ${movieUrl}`);

    try {
        const movieDetails = await SubzLK.getMovie(movieUrl);
        console.log('✅ Details fetched successfully!');
        // Accessing specific data points:
        console.log('🎬 Title:', movieDetails.title);
        console.log('⬇️ Subtitle Link:', movieDetails.downloads.subtitle);
        console.log('💿 Torrents Found:', movieDetails.downloads.torrents.length);
        
        // See output below for the full JSON structure
    } catch (error) {
        console.error('❌ Fetch Error:', error.message);
    }
}

fetchDetails();

```

<details>
<summary>⬇️ <strong>Click here to view Movie Details Output Example</strong></summary>

```json
{
  "title": "Jurassic World: Fallen Kingdom (2018) Sinhala Subtitle",
  "url": "https://subz.lk/jurassic-world-fallen-kingdom-2018-sinhala-subtitle/",
  "image": "[https://subz.lk/wp-content/uploads/2020/10/Jurassic_World_Fallen_Kingdom_2018_Sinhala_Subtitle_SubzLK_1.jpg",
  "author": "Dinusha Rukshan",
  "publishDate": "2018/08/12 at 6:34 pm",
  "description": "සියළුම දෙනාට ජය වේවා! ඉතින් මේ වතාවෙ අරගෙන ආවෙ ඔයාල බලාපොරොත්තුවෙන් හිටිය ෆිල්ම් එකක්... [Description Truncated for brevity] ...තවත් උපසිරැසියකින් හමුවෙන තුරු සියළුම දෙනාට ජයෙන් ජය!!",
  "downloads": {
    "subtitle": "https://subz.lk/wp-admin/admin-ajax.php?action=sub_download&sub_id=30016&nonce=5da23a9c4b",
    "torrents": [
      {
        "quality": "3D (bluray)",
        "size": "2.06 GB",
        "url": "https://yts.bz/torrent/download/3976A9658D79BCAC36A511D298D649CE9A670288"
      },
      {
        "quality": "720p (bluray)",
        "size": "1.08 GB",
        "url": "https://yts.bz/torrent/download/1C6BAAAA3769615ADADA00879FFFB0ACDA9104A1"
      },
      {
        "quality": "1080p (bluray)",
        "size": "2.06 GB",
        "url": "https://yts.bz/torrent/download/A7E089442821593CFA6C36A43C2858102972D87F"
      },
      {
        "quality": "2160p (bluray)",
        "size": "5.8 GB",
        "url": "https://yts.bz/torrent/download/D13D0312B25BA88A793BB0867DB3AC2468FE1437"
      },
      {
        "quality": "720p (web)",
        "size": "1.07 GB",
        "url": "https://yts.bz/torrent/download/17B557452B58D7EE14FF45CA8CD1F1C55D60070A"
      },
      {
        "quality": "1080p (web)",
        "size": "2.06 GB",
        "url": "https://yts.bz/torrent/download/28B81D6DB2F32D940BE7AB812DDAC592ABB2FC35"
      }
    ]
  }
}

```

</details>

### Example: Handling TV Shows with No Torrents

The scraper intelligently handles TV show episodes where torrent links might not be available on the page.

<details>
<summary>⬇️ <strong>Click here to view TV Show Output Example</strong></summary>

```json
{
  "title": "Fauda (2015) [S03 : E11] Sinhala Subtitle",
  "url": "https://subz.lk/fauda-2015-s03-e11-sinhala-subtitle/",
  "image": "https://subz.lk/wp-content/uploads/2020/07/Fauda_2015_S01__E01_Sinhala_Subtitle_SubzLK.jpg",
  "downloads": {
    "subtitle": "https://subz.lk/wp-admin/admin-ajax.php?action=sub_download&sub_id=46139&nonce=5da23a9c4b",
    "torrents": [] 
  }
  // ... other details
}

```

*(Note: `torrents` array is empty, not undefined/null)*

</details>

---

## ⚙️ API Reference

| Method | Description | Returns |
| --- | --- | --- |
| `SubzLK.search(query)` | Searches for movies/TV shows by keyword. | `Promise<Array>` |
| `SubzLK.getMovie(url)` | Fetches detailed info, direct subtitle link, and torrents for a specific URL. | `Promise<Object>` |

---

## 👨‍💻 Author & License

Developed and maintained by **Nimesh Piyumal**.

This project is licensed under the **MIT License** - see the [LICENSE](https://www.google.com/search?q=LICENSE) file for details.

<sub>Made with ❤️ by Nimesh Piyumal for the Sri Lankan community.</sub>