feat: implement TorrentClaw Go API client v0.1.0
Some checks failed
CI / Test (push) Failing after 1s
CI / Test-1 (push) Failing after 1s
CI / Test-2 (push) Failing after 1s
CI / Lint (push) Failing after 1s
CI / Vet (push) Failing after 1s

This commit is contained in:
Deivid Soto 2026-03-28 11:28:48 +01:00
commit f6f24c2c3f
39 changed files with 5067 additions and 0 deletions

47
stats.go Normal file
View file

@ -0,0 +1,47 @@
package torrentclaw
import "context"
// ContentStats contains counts for movies, shows, and TMDB enrichment.
type ContentStats struct {
Movies int `json:"movies"`
Shows int `json:"shows"`
TMDbEnriched int `json:"tmdbEnriched"`
}
// TorrentStats contains aggregate torrent statistics.
type TorrentStats struct {
Total int `json:"total"`
WithSeeders int `json:"withSeeders"`
Orphans int `json:"orphans"`
DailyAverage int `json:"dailyAverage"`
BySource map[string]int `json:"bySource"`
}
// IngestionRecord represents a recent data ingestion event.
type IngestionRecord struct {
Source string `json:"source"`
Status string `json:"status"`
StartedAt string `json:"startedAt"`
CompletedAt *string `json:"completedAt,omitempty"`
Fetched int `json:"fetched"`
New int `json:"new"`
Updated int `json:"updated"`
}
// StatsResponse contains aggregator statistics.
type StatsResponse struct {
Content ContentStats `json:"content"`
Torrents TorrentStats `json:"torrents"`
RecentIngestions []IngestionRecord `json:"recentIngestions"`
}
// Stats returns aggregator statistics including content counts, torrent
// counts by source, and recent ingestion history.
func (c *Client) Stats(ctx context.Context) (*StatsResponse, error) {
var resp StatsResponse
if err := c.doJSON(ctx, "/api/v1/stats", nil, &resp); err != nil {
return nil, err
}
return &resp, nil
}