A Go client library for interacting with the Autobrr API.
- Filter Management: Create, read, update, and delete filters
- Filter Control: Enable/disable filters
- Connection Testing: Verify API connectivity
- Full Filter Support: All filter options including actions, external filters, and advanced criteria
To install the package, run:
go get github.com/cehbz/autobrrimport (
"github.com/cehbz/autobrr"
)client, err := autobrr.NewClient("your-api-key", "localhost", "10798")
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}apiKey: Your Autobrr API keyaddr: The address where Autobrr is running (e.g.,"127.0.0.1")port: The port number of the Autobrr API (e.g.,"10798")
filters, err := client.GetFilters()
if err != nil {
log.Fatalf("Failed to get filters: %v", err)
}
for _, filter := range filters {
fmt.Printf("Filter: %s (ID: %d, Enabled: %v)\n", filter.Name, filter.ID, filter.Enabled)
}filter, err := client.GetFilter(123)
if err != nil {
log.Fatalf("Failed to get filter: %v", err)
}
fmt.Printf("Filter: %s\n", filter.Name)
fmt.Printf("Shows: %v\n", filter.Shows)
fmt.Printf("Resolutions: %v\n", filter.Resolutions)newFilter := &autobrr.Filter{
Name: "New TV Show Filter",
Enabled: true,
Priority: 100,
SmartEpisode: true,
Shows: []string{"The Matrix"},
Resolutions: []string{"1080p", "2160p"},
Sources: []string{"WEB-DL", "WEBRip"},
MatchReleaseGroups: "NTb|FLUX",
Years: "2023-2024",
Actions: []autobrr.Action{
{
Name: "qBittorrent",
Type: "QBITTORRENT",
Enabled: true,
ClientID: 1,
Category: "tv-shows",
SavePath: "/downloads/tv",
},
},
}
createdFilter, err := client.CreateFilter(newFilter)
if err != nil {
log.Fatalf("Failed to create filter: %v", err)
}
fmt.Printf("Created filter with ID: %d\n", createdFilter.ID)filter.Resolutions = append(filter.Resolutions, "720p")
filter.Priority = 150
updatedFilter, err := client.UpdateFilter(filter.ID, filter)
if err != nil {
log.Fatalf("Failed to update filter: %v", err)
}err := client.DeleteFilter(123)
if err != nil {
log.Fatalf("Failed to delete filter: %v", err)
}// Enable a filter
err := client.ToggleFilterEnabled(123, true)
if err != nil {
log.Fatalf("Failed to enable filter: %v", err)
}
// Disable a filter
err = client.ToggleFilterEnabled(123, false)
if err != nil {
log.Fatalf("Failed to disable filter: %v", err)
}err := client.TestConnection()
if err != nil {
log.Fatalf("Connection test failed: %v", err)
}
fmt.Println("Successfully connected to Autobrr")The Filter struct supports all Autobrr filter options:
- Basic: Name, enabled status, priority
- Content Matching: Shows, movies, resolutions, sources, codecs, containers
- Advanced Matching: Release groups, uploaders, categories, languages
- Size Limits: Min/max size constraints
- Special Options: Freeleech, scene releases, smart episode detection
- Actions: Download client actions, webhooks, custom commands
Supported action types include:
QBITTORRENT: qBittorrent download clientDELUGE: Deluge download clientTRANSMISSION: Transmission download clientRADARR: Radarr integrationSONARR: Sonarr integrationLIDARR: Lidarr integrationWHISPARR: Whisparr integrationWEBHOOK: Custom webhooksEXEC: Execute custom commandsWATCH_FOLDER: Watch folder for .torrent files
The client returns detailed errors for various failure scenarios:
filter, err := client.GetFilter(999)
if err != nil {
// Handle specific error cases
if strings.Contains(err.Error(), "404") {
log.Fatal("Filter not found")
} else if strings.Contains(err.Error(), "401") {
log.Fatal("Invalid API key")
} else {
log.Fatalf("Error: %v", err)
}
}This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.