-
-
Notifications
You must be signed in to change notification settings - Fork 3
Development Guide
Christian Blank edited this page Nov 8, 2024
·
1 revision
- Python 3.7 or higher
- Git
- pip
- Virtual environment (recommended)
- Fork and clone the repository:
git clone https://github.com/YOUR-USERNAME/Addarr.git
cd Addarr- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
.\venv\Scripts\activate # Windows- Install development dependencies:
pip install -r requirements.txt
pip install -r requirements-dev.txtAddarr/
├── addarr/
│ ├── __init__.py
│ ├── bot.py # Main bot logic
│ ├── config.py # Configuration handling
│ ├── sonarr.py # Sonarr integration
│ ├── radarr.py # Radarr integration
│ └── utils/ # Utility functions
├── tests/ # Test files
├── docs/ # Documentation
├── requirements.txt # Production dependencies
└── requirements-dev.txt # Development dependencies
git checkout -b feature/your-feature-name
# or
git checkout -b bugfix/issue-number- Follow PEP 8 guidelines
- Use meaningful variable names
- Add docstrings to functions
- Comment complex logic
Example:
def search_media(query: str, media_type: str) -> List[Dict]:
"""
Search for media in Sonarr or Radarr.
Args:
query (str): Search term
media_type (str): Either 'movie' or 'tv'
Returns:
List[Dict]: List of search results
"""
# Implementation# Run all tests
pytest
# Run specific test file
pytest tests/test_bot.py
# Run with coverage
pytest --cov=addarrdef test_search_media():
"""Test media search functionality."""
result = search_media("Breaking Bad", "tv")
assert isinstance(result, list)
assert len(result) > 0
assert "title" in result[0]def add_series(title: str, tvdb_id: int) -> Dict:
"""Add a new series to Sonarr."""
payload = {
"title": title,
"tvdbId": tvdb_id,
"qualityProfileId": 1,
"rootFolderPath": "/tv",
"monitored": True
}
response = requests.post(f"{SONARR_URL}/api/series", json=payload)
return response.json()def add_movie(title: str, tmdb_id: int) -> Dict:
"""Add a new movie to Radarr."""
payload = {
"title": title,
"tmdbId": tmdb_id,
"qualityProfileId": 1,
"rootFolderPath": "/movies",
"monitored": True
}
response = requests.post(f"{RADARR_URL}/api/movie", json=payload)
return response.json()@bot.message_handler(commands=['tv'])
def handle_tv_search(message):
"""Handle TV show search command."""
query = message.text.replace('/tv', '').strip()
if not query:
bot.reply_to(message, "Please provide a show name")
return
results = search_media(query, 'tv')
# Process results and send response- Update relevant wiki pages
- Add docstrings to new functions
- Update README.md if needed
- Document configuration changes
class MediaManager:
"""
Manages media operations for Sonarr and Radarr.
Attributes:
config (Config): Configuration instance
sonarr (SonarrAPI): Sonarr API client
radarr (RadarrAPI): Radarr API client
"""
def __init__(self, config: Config):
"""
Initialize MediaManager.
Args:
config (Config): Configuration instance
"""
self.config = config- Update Documentation
- Add/Update Tests
- Run Tests Locally
- Create Pull Request
- Describe changes
- Reference issues
- Add screenshots if UI changes
import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)[general]
debug = true
log_level = DEBUG- Create command handler
- Add to help message
- Document in wiki
- Add tests
- Update README
- Create regression test
- Fix the bug
- Verify fix
- Update documentation
- Check existing issues
- Join development discussions
- Read the wiki
- Ask questions in pull requests