# Arr Suite Language Configuration - Trash Guides Implementation

## Overview
Implemented Trash Guides recommendations for language preferences in Radarr and Sonarr to optimize content selection based on language preferences while maintaining flexibility for international content.

**Implementation Date:** 2025-02-12  
**Services Modified:** Radarr, Sonarr  
**Configuration Method:** API-based custom formats and quality profile updates  

## Objectives
- **Always prefer English content** for general media consumption
- **Accept Japanese and dual audio for anime** to support anime viewing preferences
- **Allow foreign films in their original language** (e.g., "Cold War" in Polish)
- **Prioritize multi-language releases** when available

## Custom Formats Implemented

### 1. Language: Not English
- **Score:** -10000 (strongly discourage non-English content)
- **Purpose:** Ensures English content is always preferred over non-English alternatives
- **Implementation:** 
  - Field: `language` (negated)
  - Value: English (ID: 1)
  - Applied to both Radarr and Sonarr

### 2. Anime Dual Audio
- **Score:** +500 (prefer dual audio anime)
- **Purpose:** Prioritizes anime releases with both English and Japanese audio tracks
- **Implementation:**
  - Field 1: `releaseTitle` with regex `\b(dual.audio|dual.lang|dual.language|multi.audio|multi.lang|multi.language)\b`
  - Field 2: `language` requiring English (ID: 1)
  - Field 3: `language` allowing Japanese (ID: 8, negated for optional)
  - Applied to both Radarr and Sonarr

### 3. Multi
- **Score:** +500 (prefer multi-language releases)
- **Purpose:** Prioritizes releases with multiple language tracks
- **Implementation:**
  - Field: `releaseTitle` with regex `\b(MULTi)(\b|\d)`
  - Applied to both Radarr and Sonarr

### 4. Language: Not Original
- **Score:** 0 (neutral)
- **Purpose:** Allows foreign films in their original language without penalty
- **Implementation:**
  - Field: `language` (negated)
  - Value: Original (ID: -2)
  - Applied to both Radarr and Sonarr

## Quality Profile Changes

### Radarr "Any" Profile (ID: 1)
- **Language preference:** Changed from "English" to "Any" to allow foreign films
- **Custom format scores:** Applied as specified above
- **Result:** Enables downloading of foreign films like "Cold War" in Polish while maintaining English preference

### Sonarr "Any" Profile (ID: 1)
- **Custom format scores:** Applied as specified above
- **Language preference:** Maintained existing configuration
- **Result:** Supports international TV content with proper language prioritization

## Expected Behavior

| Content Type | Behavior | Score Impact |
|--------------|----------|--------------|
| **English Content** | Always preferred | Non-English gets -10000 penalty |
| **Anime (Dual Audio)** | Preferred over Japanese-only | +500 bonus for dual audio |
| **Anime (Japanese-only)** | Acceptable if no English available | No penalty due to anime exception |
| **Foreign Films** | Original language acceptable | 0 penalty for "Not Original" |
| **Multi-language Releases** | Preferred when available | +500 bonus |

## Technical Implementation Details

### API Endpoints Used
- `POST /api/v3/customformat` - Create custom formats
- `PUT /api/v3/qualityprofile/{id}` - Update quality profiles with scoring

### Configuration Files Modified
- **Radarr:** Quality Profile ID 1 ("Any")
- **Sonarr:** Quality Profile ID 1 ("Any")
- **Custom Formats:** 4 new formats added to each service

### Service Configuration Locations
- **Radarr Config:** `/volume2/metadata/docker2/radarr:/config`
- **Sonarr Config:** `/volume2/metadata/docker2/sonarr:/config`
- **Container Network:** `media2_net` (172.24.0.0/24)
- **Radarr IP:** 172.24.0.8:7878
- **Sonarr IP:** 172.24.0.7:8989

## Validation and Testing

### Verification Commands
```bash
# Check custom formats
curl -s -H "X-Api-Key: API_KEY" "http://localhost:7878/api/v3/customformat"
curl -s -H "X-Api-Key: API_KEY" "http://localhost:8989/api/v3/customformat"

# Check quality profile scores
curl -s -H "X-Api-Key: API_KEY" "http://localhost:7878/api/v3/qualityprofile/1"
curl -s -H "X-Api-Key: API_KEY" "http://localhost:8989/api/v3/qualityprofile/1"
```

### Test Cases
1. **English Movie:** Should be preferred over non-English versions
2. **Foreign Film (e.g., "Cold War"):** Should download in Polish without penalty
3. **Anime with Dual Audio:** Should prefer dual audio over Japanese-only
4. **Multi-language Release:** Should get priority over single-language versions

## Maintenance and Updates

### Backup Considerations
- Custom formats are stored in service databases within config volumes
- Quality profiles are part of the service configuration
- Changes persist through container restarts due to volume mounts

### Future Enhancements
- Consider adding more specific anime detection patterns
- Implement region-specific language preferences
- Add custom formats for specific quality groups or release patterns

## References
- [Trash Guides](https://trash-guides.info/) - Source of configuration recommendations
- [Radarr Custom Formats Documentation](https://wiki.servarr.com/radarr/settings#custom-formats-2)
- [Sonarr Custom Formats Documentation](https://wiki.servarr.com/sonarr/settings#custom-formats-2)
- [Servarr API Documentation](https://wiki.servarr.com/radarr/api)

## Troubleshooting

### Common Issues
1. **Custom formats not applying:** Check API keys and service accessibility
2. **Scoring not working:** Verify quality profile has been updated with format scores
3. **Foreign films not downloading:** Ensure "Language: Not Original" score is 0 or positive

### Rollback Procedure
1. Remove custom formats via API: `DELETE /api/v3/customformat/{id}`
2. Reset quality profile language preference to "English"
3. Clear custom format scores from quality profiles

---
*This configuration implements Trash Guides best practices for language handling in the arr suite, balancing English preference with international content flexibility.*