|
Download README.md from luci18/animebot: direct link, hf CLI and curl.
- Browser
- Download file 10.9 kB
-
https://huggingface.co/luci18/animebot/resolve/main/README.md
- Command line
-
hf download hf://luci18/animebot/README.md
-
curl -L -o README.md https://huggingface.co/luci18/animebot/resolve/main/README.md
10.9 kB
| title: Anime Encoder Bot | |
| emoji: π¬ | |
| colorFrom: blue | |
| colorTo: purple | |
| sdk: docker | |
| app_port: 5000 | |
| pinned: false | |
| # Anime Encoder Bot π¬ | |
| A hybrid Telegram bot that combines **anime downloading** (via animdl) with **advanced video encoding** (via FFmpeg). Download anime episodes and encode them with H.264/H.265, custom quality settings, audio controls, and more! | |
| ## Features | |
| ### π¬ Anime Downloading | |
| - π **Multi-site search** - Search across all anime sites at once | |
| - π **8+ supported sites** - GogoAnime, 9Anime, AnimePahe, Zoro, AnimixPlay, AllAnime, Nyaa, etc. | |
| - π₯ Download specific episodes | |
| - π₯ Direct URL downloads (yt-dlp) | |
| - πΎ MongoDB caching for fast re-access | |
| - π Download progress tracking | |
| - β³ Download queue management | |
| - π Site-specific search - Filter by preferred source | |
| ### ποΈ Video Encoding | |
| - π₯ Codecs: H.264 (libx264), H.265/HEVC (libx265) | |
| - π Quality control: CRF 16-35 | |
| - β‘ Speed presets: ultrafast to veryslow | |
| - π Resolution scaling: 1080p, 720p, 540p, 480p, 360p | |
| - π Audio: AAC, AC3, OPUS, MP3 with bitrate control | |
| - π Subtitle support | |
| - 10-bit HEVC encoding | |
| ### π Smart Renaming with Metadata | |
| - π·οΈ **Auto-rename** downloads and encodes | |
| - π **Pattern templates**: `{title}`, `{episode}`, `{quality}`, `{codec}`, etc. | |
| - π¨ **Preset patterns**: Simple, Detailed, Anime-style, With codec info | |
| - π§ **Custom patterns**: Create your own naming scheme | |
| - π **Metadata extraction**: Resolution, codec, duration from video files | |
| ### πΌοΈ Thumbnail Generation (Customizable) | |
| - π¬ Auto-generate thumbnails from any video | |
| - πΈ **Custom position** - Start (10%), Middle (50%), End (90%), etc. | |
| - π **User-defined resolution** - 1080p, 720p, 480p, 360p | |
| - οΏ½ **Custom caption template** - `{filename}`, `{resolution}`, `{position}` | |
| - πΈ **Format choice** - JPG or PNG | |
| - πΌοΈ Generated thumbnails sent with encoded videos | |
| ### π Statistics & Leaderboard | |
| - π **User Stats** - Personal download/encode history via `/mystats` | |
| - π **Leaderboard** - Top users by activity (all time, weekly, monthly) | |
| - π **Success Rates** - Track completion rates | |
| - π **Favorite Anime** - Most downloaded series per user | |
| ### π Web Admin Panel | |
| - π Secure login with password protection | |
| - π **Dashboard** - Real-time bot statistics | |
| - π₯ **User Management** - View all users and their activity | |
| - π **Task Monitoring** - Track downloads and encodes | |
| - βοΈ **Settings Control** - Adjust bot configuration | |
| - π **Leaderboard View** - See top users | |
| ### ποΈ Batch Operations | |
| - π¦ **Batch Encode** - Queue multiple videos at once | |
| - π₯ **Batch Download** - Download entire seasons | |
| ### βοΈ User Features | |
| - π§ Per-user encoding settings | |
| - π Queue status monitoring | |
| - π Download + Auto-encode workflow | |
| ## Requirements | |
| - Python 3.9+ | |
| - MongoDB (local or remote) | |
| - FFmpeg + FFprobe | |
| - animdl (`pip install animdl`) | |
| - Telegram API credentials | |
| ## Installation | |
| ### 1. Clone Repository | |
| ```bash | |
| git clone https://github.com/yourusername/anime-encoder-bot.git | |
| cd anime-encoder-bot | |
| ``` | |
| ### 2. Install Dependencies | |
| ```bash | |
| pip install -r requirements.txt | |
| pip install animdl # Must be installed separately | |
| ``` | |
| ### 3. Install FFmpeg | |
| **Ubuntu/Debian:** | |
| ```bash | |
| sudo apt-get update | |
| sudo apt-get install ffmpeg | |
| ``` | |
| **macOS:** | |
| ```bash | |
| brew install ffmpeg | |
| ``` | |
| **Windows:** Download from [FFmpeg website](https://ffmpeg.org/download.html) and add to PATH. | |
| ### 4. Setup MongoDB | |
| **Local:** | |
| ```bash | |
| # Ubuntu/Debian | |
| sudo apt-get install mongodb | |
| sudo systemctl start mongod | |
| # macOS | |
| brew install mongodb-community | |
| brew services start mongodb-community | |
| # Docker | |
| docker run -d -p 27017:27017 --name mongodb mongo:latest | |
| ``` | |
| **MongoDB Atlas:** Use connection string in `.env` | |
| ### 5. Configure Bot | |
| Copy `.env.example` to `.env` and fill in your values: | |
| ```bash | |
| cp .env.example .env | |
| ``` | |
| Edit `.env`: | |
| ```env | |
| # Telegram API credentials - Get from https://my.telegram.org | |
| API_ID=your_api_id | |
| API_HASH=your_api_hash | |
| BOT_TOKEN=your_bot_token_from_botfather | |
| # Owner settings | |
| OWNER_ID=your_telegram_user_id | |
| # MongoDB | |
| MONGO_URI=mongodb://localhost:27017/anime_encoder_bot | |
| # Optional: Log channel | |
| LOG_CHANNEL=-1001234567890 | |
| ``` | |
| ### 6. Run Bot | |
| ```bash | |
| python -m bot.main | |
| ``` | |
| ## Commands | |
| | Command | Description | | |
| |---------|-------------| | |
| | `/start` | Start the bot with menu buttons | | |
| | `/help` | Show help | | |
| | `/sites` | List available anime sites | | |
| | `/anime <query>` | Search all anime sites | | |
| | `/anime <query> <site>` | Search specific site (e.g., `/anime naruto gogoanime`) | | |
| | `/download <url> <ep>` | Download specific episode | | |
| | `/ddl <url>` | Download from direct URL | | |
| | `/encode` | Reply to a video to encode it | | |
| | `/batchencode` | Reply to multiple videos to batch encode | | |
| | `/thumb` | Reply to a video to generate thumbnail | | |
| | `/settings` | Configure encoding & rename preferences | | |
| | `/status` | View queue status | | |
| | `/mystats` | View your personal statistics | | |
| | `/stats` | Admin statistics | | |
| ## Button Interface | |
| The bot features an intuitive **button-based interface**: | |
| ### Main Menu (via `/start`) | |
| - π **Search Anime** - Opens search options | |
| - π **Sites** - Lists all available anime sites | |
| - βοΈ **Settings** - Configure encoding preferences | |
| - π **Status** - View queue status | |
| - β **Help** - Show commands | |
| ### Search Options | |
| - π **Search All Sites** - Search across all anime sites | |
| - π― **Search Specific Site** - Choose a site to search | |
| ### Episode Selection | |
| - Episode buttons (1-25 shown at a time) | |
| - π₯ **Download All** - Queue all episodes at once (limit 50) | |
| - **Range buttons** - For series with >25 episodes (e.g., "Ep 26-50") | |
| - β¬ οΈ **Previous** / β‘οΈ **Next** - Navigate episode ranges | |
| ### Site Filter Buttons | |
| When searching all sites, results show filter buttons to narrow down by specific sites. | |
| ### Settings - Renaming (βοΈ β π Rename Pattern) | |
| - π **Pattern Presets** - Simple, Detailed, With Codec, With Site, Anime Style, Minimal | |
| - π **Toggle Auto Rename** - Enable/disable automatic renaming | |
| - βοΈ **Custom Pattern** - Create your own naming scheme | |
| - π **Pattern Help** - View all available variables | |
| ### Settings - Thumbnails (βοΈ β πΌοΈ Thumbnail Settings) | |
| - π **Resolution** - 1080p, 720p, 480p, 360p | |
| - π **Position** - Where to capture in the video (10%, 25%, 50%, 75%) | |
| - πΈ **Format** - JPG or PNG | |
| - π¬ **Caption Template** - Customize the thumbnail caption | |
| ### Thumbnail Caption Variables | |
| | Variable | Description | | |
| |----------|-------------| | |
| | `{filename}` | Original video filename | | |
| | `{resolution}` | Thumbnail resolution | | |
| | `{position}` | Timestamp position (e.g., 25%) | | |
| ## Supported Sites | |
| - **GogoAnime** - `gogoanime` (most reliable) | |
| - **9Anime** - `9anime` | |
| - **AnimePahe** - `animepahe` | |
| - **Zoro.to** - `zoro` | |
| - **AnimixPlay** - `animixplay` | |
| - **AllAnime** - `allanime` | |
| - **Nyaa.si** - `nyaa` (torrents) | |
| - **Crunchyroll** - `crunchyroll` (requires auth) | |
| ## Encoding Settings | |
| Users can customize their encoding preferences: | |
| - **Codec**: libx264 (H.264) or libx265 (H.265/HEVC) | |
| - **CRF**: 16-35 (lower = better quality) | |
| - **Preset**: ultrafast to veryslow (encoding speed) | |
| - **Resolution**: Scale to 1080p/720p/540p/480p/360p or keep original | |
| - **Audio Codec**: AAC, AC3, OPUS, MP3 | |
| - **Audio Bitrate**: 96k-320k | |
| ## Renaming Patterns | |
| Configure automatic file renaming in `/settings` β `π Rename Pattern`: | |
| ### Available Variables | |
| | Variable | Description | | |
| |----------|-------------| | |
| | `{title}` | Anime title | | |
| | `{episode}` | Episode number (02, 03, etc.) | | |
| | `{season}` | Season number | | |
| | `{quality}` | Video resolution (1920x1080) | | |
| | `{codec}` | Video codec (H.264, HEVC) | | |
| | `{audio_codec}` | Audio codec (AAC, AC3) | | |
| | `{duration}` | Video duration | | |
| | `{source_site}` | Download source site | | |
| ### Pattern Presets | |
| - **simple**: `{title} - Ep{episode}` | |
| - **detailed**: `{title} - S{season}E{episode} [{quality}]` | |
| - **with_codec**: `{title} - Ep{episode} [{quality}] [{codec}]` | |
| - **with_site**: `[{source_site}] {title} - Ep{episode} [{quality}]` | |
| - **anime_style**: `[{studio}] {title} - {episode} [{quality}]` | |
| ### Example Output | |
| Pattern: `{title} - Episode {episode} [{quality}]` | |
| Result: `Attack on Titan - Episode 05 [1920x1080].mp4` | |
| ## Web Admin Panel | |
| The bot includes a web-based admin panel for easy management. | |
| ### Running the Panel | |
| ```bash | |
| python web_panel.py | |
| ``` | |
| Access at `http://localhost:5000` | |
| ### Default Login | |
| - **Username**: `admin` | |
| - **Password**: `admin` (β οΈ change in production!) | |
| ### Panel Features | |
| - π **Dashboard** - Real-time bot statistics, queue status, popular anime | |
| - π₯ **Users** - View all users and their download/encode stats | |
| - π **Tasks** - Monitor recent downloads and encodes | |
| - π **Leaderboard** - View top users by activity (all time/weekly/monthly) | |
| - βοΈ **Settings** - View and manage bot configuration | |
| ### Environment Variables | |
| ```env | |
| ADMIN_USERNAME=admin | |
| ADMIN_PASSWORD_HASH=<bcrypt_hash> | |
| FLASK_SECRET_KEY=your-secret-key | |
| ``` | |
| ## Architecture | |
| ``` | |
| βββββββββββββββ | |
| β Telegram β | |
| β User β | |
| ββββββββ¬βββββββ | |
| β | |
| ββββββββΌβββββββ βββββββββββββββ βββββββββββββββ | |
| β Bot Client ββββββΆβ Task Queue ββββββΆβ MongoDB β | |
| β (Pyrogram) β β β β (Queue DB) β | |
| ββββββββ¬βββββββ βββββββββββββββ βββββββββββββββ | |
| β | |
| ββββββββΌβββββββ βββββββββββββββ | |
| β Workers β β FFmpeg β | |
| β - Download ββββββΆβ Encoder β | |
| β - Encode β β β | |
| βββββββββββββββ βββββββββββββββ | |
| β | |
| βΌ | |
| βββββββββββββββ | |
| β animdl / β | |
| β yt-dlp β | |
| βββββββββββββββ | |
| ``` | |
| ## Troubleshooting | |
| **Bot won't start:** | |
| - Check `.env` has all required values | |
| - Verify MongoDB is running | |
| - Ensure FFmpeg is installed and in PATH | |
| **Downloads fail:** | |
| - Check animdl installation: `animdl --version` | |
| - Verify source site is accessible | |
| - Check download directory permissions | |
| **Encoding fails:** | |
| - Verify FFmpeg installation: `ffmpeg -version` | |
| - Check encode directory permissions | |
| - Review `bot.log` for errors | |
| ## License | |
| MIT License | |
| ## Credits | |
| - [animdl](https://github.com/justfoolingaround/animdl) - Anime downloader | |
| - [Pyrogram](https://pyrogram.org) - Telegram MTProto client | |
| - [FFmpeg](https://ffmpeg.org) - Video encoding | |
| - [yt-dlp](https://github.com/yt-dlp/yt-dlp) - Direct URL downloader | |