A Telegram bot to send anime directly to your inbox. This bot uses animdl for searching and downloading anime files, and stores them in MongoDB for faster subsequent access.
- 🎬 Download anime episodes on demand
- 💾 Cache downloaded episodes in MongoDB for instant access
- 📱 Send videos directly to Telegram users
- 🔍 Search and download from multiple anime sources via animdl
- ⚡ Fast response times for cached content
- Python 3.9 or higher
- MongoDB (local or remote instance)
- FFmpeg (for video conversion)
- Telegram Bot Token
- Telegram API credentials (api_id, api_hash) from my.telegram.org
git clone https://github.com/yourusername/Meido.git
cd MeidoUsing pip:
pip install -r requirements.txtUsing pipenv:
pipenv installUbuntu/Debian:
sudo apt-get update
sudo apt-get install ffmpegmacOS:
brew install ffmpegWindows: Download from FFmpeg official website and add to PATH.
pip install animdlOr install from source:
pip install git+https://github.com/justfoolingaround/animdl.gitLocal Installation:
# Ubuntu/Debian
sudo apt-get install mongodb
# macOS
brew install mongodb-community
# Start MongoDB service
sudo systemctl start mongod # Linux
brew services start mongodb-community # macOSDocker:
docker run -d -p 27017:27017 --name mongodb mongo:latestRemote MongoDB:
Set the MONGO_DB_URL environment variable:
export MONGO_DB_URL="mongodb://username:password@host:port/"Create bot/config/botConfig.json from the example:
cp bot/config/exampleConfig.json bot/config/botConfig.jsonEdit bot/config/botConfig.json:
{
"bot_token": "YOUR_BOT_TOKEN_FROM_BOTFATHER",
"agent_user_id": YOUR_TELEGRAM_USER_ID
}To get your bot token:
- Open Telegram and search for @BotFather
- Send
/newbotand follow instructions - Copy the token provided
To get your user ID:
- Search for @userinfobot on Telegram
- Start a conversation to get your user ID
Create uploaderService/config/agentConfig.json from the example:
cp uploaderService/config/Example_agentConfig.json uploaderService/config/agentConfig.jsonEdit uploaderService/config/agentConfig.json:
{
"entity": "session_name",
"api_id": "YOUR_API_ID",
"api_hash": "YOUR_API_HASH",
"phone": "+1234567890",
"bot_name": "@your_bot_username"
}To get your API credentials:
- Go to my.telegram.org
- Log in with your phone number
- Go to "API development tools"
- Create a new application and copy
api_idandapi_hash
Important: The bot_name should be your bot's username (e.g., @myanimebot)
From the project root directory:
python bot/bot.pyOr using pipenv:
pipenv run python bot/bot.py/start- Start the bot and see welcome message/help- Show help message with available commands/getanime <anime_name>, <season>, <episode>- Download and send anime episode
Example:
/getanime Death Note, 1, 3
This will:
- Check if the episode exists in the database
- If found, send it immediately
- If not found, download it, convert to MP4, upload to Telegram, and send it to you
Meido/
├── bot/
│ ├── bot.py # Main bot application
│ ├── botUtils.py # Utility functions
│ ├── database.py # MongoDB operations
│ └── config/
│ ├── botConfig.json # Bot configuration (create from example)
│ └── exampleConfig.json
├── downloaderService/
│ └── main.py # Anime download service
├── uploaderService/
│ ├── main.py # Telegram upload service
│ └── config/
│ ├── agentConfig.json # Uploader config (create from example)
│ └── Example_agentConfig.json
├── docs/
│ ├── architechture.md # Architecture documentation
│ └── databaseSchema.md # Database schema
├── requirements.txt # Python dependencies
├── Pipfile # Pipenv dependencies
└── README.md # This file
- User Request: User sends
/getanimecommand with anime details - Database Check: Bot checks MongoDB for existing file_id
- Cache Hit: If found, bot sends video immediately using file_id
- Cache Miss: If not found:
- Downloads anime using animdl
- Converts .ts to .mp4 using FFmpeg
- Uploads to Telegram via Telethon (agent account)
- Bot receives file_id and stores in database
- Bot sends video to user
- Future Requests: Subsequent requests for the same episode are instant
- Config file not found: Ensure
botConfig.jsonexists inbot/config/ - Invalid token: Verify your bot token is correct
- MongoDB connection error: Check if MongoDB is running and accessible
# Test MongoDB connection mongosh
- animdl not installed: Install animdl as shown in installation steps
- FFmpeg not found: Ensure FFmpeg is installed and in PATH
ffmpeg -version # Should show version info
- Telegram API error: Verify your API credentials in
agentConfig.json - Session not authorized: On first run, you'll need to enter the verification code
- File not found: Ensure the download completed successfully
- Connection timeout: Check MongoDB is running
- Authentication error: Verify MongoDB URL if using remote instance
- Collection not found: The collection will be created automatically on first use
MONGO_DB_URL: MongoDB connection string (default:mongodb://localhost:27017/)
Example:
export MONGO_DB_URL="mongodb://user:pass@localhost:27017/"- Never commit
botConfig.jsonoragentConfig.jsonto version control - These files are in
.gitignoreby default - Use environment variables for sensitive data in production
- Keep your API credentials secure
The project follows PEP 8 Python style guidelines. Consider using:
blackfor code formattingflake8for lintingmypyfor type checking
The project includes a comprehensive test suite using pytest. To run tests:
Install test dependencies:
pip install -r requirements.txtRun all tests:
pytest tests/ -vOr use the test runner script:
./run_tests.shRun specific test files:
pytest tests/test_botUtils.py -v
pytest tests/test_database.py -v
pytest tests/test_bot_commands.py -v
pytest tests/test_integration.py -vRun with coverage:
pytest tests/ --cov=bot --cov=downloaderService --cov=uploaderService --cov-report=htmlTest Structure:
tests/test_botUtils.py- Tests for utility functions (parsing, file operations)tests/test_database.py- Tests for MongoDB operationstests/test_bot_commands.py- Tests for bot commands (/start, /help, /getanime)tests/test_integration.py- Integration tests for complete workflows
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new features
- Ensure all tests pass
- Submit a pull request
See LICENSE file for details.
✅ Core functionality working ✅ MongoDB integration ✅ Error handling improved ✅ Modern dependencies 🔄 Pre-caching popular anime (planned) 🔄 Subscription feature (planned) 🔄 Watch list (planned) 🔄 Recommendations (planned)
If you encounter any issues or have questions:
- Open an issue on GitHub
- Check existing issues for solutions
- Review the troubleshooting section above
- animdl for anime downloading
- python-telegram-bot for Telegram bot framework
- Telethon for Telegram client library
Note: This bot is for educational purposes. Ensure you comply with copyright laws and terms of service when using this software.

