feat: implement TorrentClaw Go API client v0.1.0
This commit is contained in:
commit
f6f24c2c3f
39 changed files with 5067 additions and 0 deletions
56
streaming.go
Normal file
56
streaming.go
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
package torrentclaw
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// StreamingTopParams holds the parameters for a streaming top 10 request.
|
||||
type StreamingTopParams struct {
|
||||
// Service is the streaming service: "netflix", "prime", "disney", "hbo", "apple".
|
||||
Service string
|
||||
|
||||
// Country is an ISO 3166-1 country code (default "US").
|
||||
Country string
|
||||
|
||||
// ShowType is the content type: "movie" or "series" (default "movie").
|
||||
ShowType string
|
||||
|
||||
// Locale sets the language for localized titles.
|
||||
Locale string
|
||||
}
|
||||
|
||||
// StreamingTopItem represents a ranked item in a streaming top list.
|
||||
type StreamingTopItem struct {
|
||||
Rank int `json:"rank"`
|
||||
Title string `json:"title"`
|
||||
IMDbID *string `json:"imdbId,omitempty"`
|
||||
TMDbID *int `json:"tmdbId,omitempty"`
|
||||
ContentType *string `json:"contentType,omitempty"`
|
||||
Year *int `json:"year,omitempty"`
|
||||
Overview *string `json:"overview,omitempty"`
|
||||
Rating *string `json:"rating,omitempty"`
|
||||
PosterURL *string `json:"posterUrl,omitempty"`
|
||||
BackdropURL *string `json:"backdropUrl,omitempty"`
|
||||
Genres []string `json:"genres,omitempty"`
|
||||
StreamingLink *string `json:"streamingLink,omitempty"`
|
||||
ContentID *int `json:"contentId,omitempty"`
|
||||
HasTorrents bool `json:"hasTorrents"`
|
||||
MaxSeeders int `json:"maxSeeders"`
|
||||
}
|
||||
|
||||
// StreamingTop returns the top-ranked content for a streaming service.
|
||||
// The response is an array of ranked items (not a paginated wrapper).
|
||||
func (c *Client) StreamingTop(ctx context.Context, params StreamingTopParams) ([]StreamingTopItem, error) {
|
||||
q := url.Values{}
|
||||
addStringParam(q, "service", params.Service)
|
||||
addStringParam(q, "country", params.Country)
|
||||
addStringParam(q, "show_type", params.ShowType)
|
||||
addStringParam(q, "locale", params.Locale)
|
||||
|
||||
var resp []StreamingTopItem
|
||||
if err := c.doJSON(ctx, "/api/v1/streaming-top", q, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue