# ⚡ ANILINK-TUI

<div align="center">

```
                                  anilink

                                     ⚡
                    ███  █ █  ███  █    ███  █ █  █ █
                    █ █  ███   █   █     █   ███  ██ 
                    ███  ███   █   █     █   ███  ██ 
                    █ █  █ █  ███  ███  ███  █ █  █ █

           A curated, terminal-native anime torrent streamer.
                   trending  ·  seasonal  ·  top rated  ·  movies
```

[![npm version](https://img.shields.io/npm/v/anilink-tui.svg?style=flat-square&color=a855f7)](https://www.npmjs.com/package/anilink-tui)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-3178c6.svg?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![Node.js](https://img.shields.io/badge/Node.js-18+-339933.svg?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org/)

**A modern, terminal-native anime streaming TUI in TypeScript.**  
Stream anime directly over BitTorrent sequentially **without waiting for full downloads or leaving permanent residue on disk**.

</div>

---

## 🌟 Key Features

- **⚡ Instant Sequential Streaming**: Watch anime instantly without waiting for gigabytes to download. Pieces are requested and buffered on demand directly from the swarm.
- **🗑️ Zero Disk Clutter**: Ephemeral chunks are buffered in a temporary directory and **automatically destroyed upon exiting**.
- **🎨 Modern Minimalist TUI**: Built with React & Ink featuring block fonts, neon purple borders, responsive card layout, and smooth navigation.
- **🔍 AniList GraphQL Discovery**: Browse Trending, Seasonal, Top Rated anime, or Movies with detailed synopses, AniList scores, genres, and fuzzy search.
- **🌊 Multi-Source & Dedicated ToonsHub + AniLink OG Engine**:
  - **Nyaa.si (Default)**: Comprehensive coverage across all anime releases.
  - **⚡ AniLink OG**: Ultra-fast, zero-seeder **Direct HLS M3U8 streams** (1080p FHD & 720p HD with English & Japanese audio tracks).
  - **ToonsHub Provider**: Dedicated specialized provider on Nyaa for **Hindi Dubs** and Multi-Audio anime releases from Crunchyroll, Netflix, Amazon Prime, and bilibili.
  - **AnimeTosho**: Mirror and DDL fallback index.
  - **Auto Multi-Source Aggregator**: Queries Nyaa, AniLink OG, ToonsHub, and AnimeTosho in parallel and merges sources.
  - **Season-Aware Ranking**: Prevents Season 3/2 batch torrents from overtaking Season 1 when searching for initial seasons.
  - **Batch Extraction**: Automatically extracts and streams individual episodes directly out of full season batch releases.
- **🎧 Multi-Audio & Hindi Dub Support**:
  - Full support for dual audio and multi-language anime releases (Japanese original, English dub, **Hindi dub**, and multi-language audio streams).
  - Automatically loads your preferred audio language (`Japanese`, `English Dub`, `Hindi Dub`, or `Auto`) with synchronized subtitles.
  - Dedicated Audio Tracks popover (`🎧`) in the Web Player with EQ Gain Boost (100%, 150%, 200%) and instant stream switcher.
  - Switch audio tracks on the fly with a single keystroke (`a`) in both MPV and the Web Player.
- **⚡ 4K Ultra HD & Multi-Quality Selector**:
  - Full support for resolutions up to **4K (2160p UHD)**, 1080p FHD, 720p HD, and 480p SD.
  - Smart quality filtering and badge tags (`[4K]`, `[HINDI]`, `[DUAL]`, `[1080P]`, `[BATCH]`).
- **⚡ Next-Gen Web Player**:
  - **2-Column Sidebar Layout**: Full-width cinematic canvas on the left and sticky anime showcase (HD Poster, AniList Score, Status, Genres, Synopsis, Tech Specs) on the right.
  - **⏭ Smart AniSkip Integration**: Floating skip buttons (`[ ⏭ Skip Intro ]` / `[ ⏭ Skip Outro ]`) appear strictly during the exact opening/ending timestamp window and auto-disappear. Includes one-click `Auto-Skip` mode.
  - **💬 Gandhi Sans Custom Subtitle Engine**: Auto-extracts and renders embedded `.ass` / `.ssa` subtitles, parses anime dialogue cues, and supports real-time customization (Gandhi Sans, Trebuchet, Inter, Roboto, Arial, 4 size scales, 4 color palettes, ±250ms sync).
  - **🎛 Video & Audio Controls**: Audio track selector, Audio Gain Boost, Ambient Glow, Video Enhancement (Anime Color Boost / Contrast), Aspect Ratio (16:9 Fit / Cover), Playback Speeds (0.5x to 2x), Theater Mode, and Picture-in-Picture.
  - **💻 MPV One-Click Command**: Easily copy the direct stream URL for local hardware playback (`mpv http://127.0.0.1:12478/stream.mkv`).
- **⏩ 1000+ Episode Quick Paging**: Effortlessly navigate long-running anime like *One Piece* using `Page Up` / `Page Down` (±10 eps), `[` / `]` (±50 eps), or `Home` / `End`.
- **🎬 External Player Support**: Full IPC integration with [MPV](https://mpv.io/) and VLC.

---

## 🚀 Quick Start

### Run Instantly via `npx` (No installation needed)
```bash
npx anilink-tui
```

### Or Install Globally
```bash
npm install -g anilink-tui
```

Once installed, simply run:
```bash
anilink
# or
anilink-tui
```

### Direct CLI Search & Episode Playback
```bash
anilink "Frieren" -e 1
```

---

## 🎮 Keyboard Navigation & Controls

### Global Navigation
| Key | Action |
| --- | --- |
| `↑` / `↓` | Navigate anime list / episodes / torrent releases |
| `Enter` | Select anime / Choose episode / Start stream |
| `/` | Focus search bar from Home |
| `s` | Open Settings menu |
| `Tab` / `←` / `→` | Switch tabs (Continue Watching ⇄ Trending) |
| `Esc` | Go back to previous screen |
| `Ctrl+C` or `q` | Instant clean quit |

### Episode Selector Controls (Long Anime Navigation)
| Key | Action |
| --- | --- |
| `↑` / `↓` | Navigate ±1 episode |
| `Page Up` / `Page Down` | Jump ±10 episodes |
| `[` / `]` | Jump ±50 episodes |
| `Home` / `End` | Jump to Episode 1 / Latest Episode |

### Streaming Dashboard Controls
| Key | Action |
| --- | --- |
| `Space` | Toggle Pause / Resume (MPV IPC) |
| `←` / `→` | Seek backward / forward 10 seconds |
| `a` | Cycle Audio Track (Japanese ⇄ English Dub in MPV) |
| `o` | Re-open Web Player in default browser |
| `q` or `Esc` | Stop streaming, destroy temp files, and return to episode list |

---

## ⚙️ Configuration & Settings

Press `Tab` (or `Ctrl+S`) on the Home screen to customize:
1. **Preferred Player**: Select `MPV`, `Web Browser`, or `VLC`.
2. **Audio Language**: Choose between `JAPANESE (ORIGINAL)`, `ENGLISH (DUB)`, `HINDI (DUB)`, or `AUTO`.
3. **Torrent Source**: Choose between `Nyaa.si (Default)`, `ToonsHub (Hindi & Multi-Audio Dubs)`, `AnimeTosho`, or `Auto (Combined Multi-Source)`.
4. **Preferred Quality**: Choose `4k`, `1080p`, `720p`, `480p`, or `auto`.
5. **Auto-Play Best Source**:
   - `ENABLED`: Instantly streams the highest-seeded release without prompting.
   - `DISABLED`: Lets you manually inspect all available release groups and seed counts.
6. **1-Click MPV Installer**: Press Enter on Windows to install MPV automatically via `winget`.

Configuration and watch history are stored locally in `~/.anistream/config.json`.

---

## 🧪 Testing

ANILINK includes full automated test suites covering AniList GraphQL queries, Nyaa & AnimeTosho scrapers, Season-Aware Ranking, and Streamer teardown:

```bash
npm test
```

---

## 📄 License

MIT License © 2026 [thor-op](https://github.com/thor-op)
