api

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIEpisode

type APIEpisode struct {
	ID     string `json:"id"`
	Number int    `json:"number"`
	Title  string `json:"title"`
	URL    string `json:"url,omitempty"`    // Contains mediaID for some providers (e.g., SFlix)
	Season int    `json:"season,omitempty"` // Some providers include season info
}

APIEpisode represents an episode in the API response

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles communication with the streaming API server

func NewClient

func NewClient(cfg *config.Config, logger *slog.Logger) *Client

NewClient creates a new API client

func (*Client) GetInfo

func (c *Client) GetInfo(ctx context.Context, mediaType, provider, id string) (*InfoResponse, error)

GetInfo retrieves detailed information about a media item

func (*Client) GetMangaPages

func (c *Client) GetMangaPages(ctx context.Context, mediaType, provider, chapterID string) (*MangaPagesResponse, error)

GetMangaPages retrieves pages for a manga chapter

func (*Client) GetServers

func (c *Client) GetServers(ctx context.Context, mediaType, provider, episodeID string) ([]Server, error)

GetServers retrieves available streaming servers for an episode This is optional - not all providers use it

func (*Client) GetSources

func (c *Client) GetSources(ctx context.Context, mediaType, provider, episodeID string) (*SourcesResponse, error)

GetSources retrieves video sources for an episode

func (*Client) GetSourcesWithMediaID

func (c *Client) GetSourcesWithMediaID(ctx context.Context, mediaType, provider, episodeID, mediaID string) (*SourcesResponse, error)

GetSourcesWithMediaID retrieves video sources for an episode with optional mediaID

func (*Client) GetSourcesWithParams

func (c *Client) GetSourcesWithParams(ctx context.Context, mediaType, provider, episodeID string, params map[string]string) (*SourcesResponse, error)

GetSourcesWithParams retrieves video sources with custom parameters (for HiAnime server/category)

func (*Client) HealthCheck

func (c *Client) HealthCheck(ctx context.Context, provider, mediaType string) error

HealthCheck checks if a provider is available

func (*Client) Search

func (c *Client) Search(ctx context.Context, mediaType, provider, query string) (*SearchResponse, error)

Search performs a search query on the API mediaType: "anime" or "movies" provider: provider name (e.g., "allanime", "hianime", "sflix", "flixhq")

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse represents an API error response

type InfoCache

type InfoCache struct {
	// contains filtered or unexported fields
}

InfoCache caches media info responses to avoid redundant API calls

func NewInfoCache

func NewInfoCache() *InfoCache

NewInfoCache creates a new InfoCache

func (*InfoCache) Get

func (c *InfoCache) Get(key string) (*InfoResponse, bool)

Get retrieves a cached response

func (*InfoCache) Set

func (c *InfoCache) Set(key string, val *InfoResponse)

Set stores a response in the cache

type InfoResponse

type InfoResponse struct {
	ID            string         `json:"id"`
	Title         string         `json:"title"`
	URL           string         `json:"url"`
	Image         string         `json:"image"`
	Description   string         `json:"description"`
	Genres        []string       `json:"genres"`
	Status        string         `json:"status"`
	TotalEpisodes int            `json:"totalEpisodes"`
	Episodes      []APIEpisode   `json:"episodes"`
	Chapters      []MangaChapter `json:"chapters,omitempty"` // For manga providers
	ReleaseDate   string         `json:"releaseDate,omitempty"`
	Rating        string         `json:"rating,omitempty"`     // IMDB rating (e.g., "7.5")
	Type          string         `json:"type,omitempty"`       // For movies: "Movie" or "TV Series"
	LastSeason    int            `json:"lastSeason,omitempty"` // For TV shows: last season number
}

InfoResponse represents the API's info/details response

type MangaChapter

type MangaChapter struct {
	ID     string `json:"id"`
	Number string `json:"number"` // Can be "1", "1.5", etc.
	Title  string `json:"title"`
}

MangaChapter represents a manga chapter in the API response

type MangaPage

type MangaPage struct {
	URL   string `json:"url"`
	Index int    `json:"index"`
}

MangaPage represents a single page of a manga chapter

type MangaPagesResponse

type MangaPagesResponse struct {
	Pages []MangaPage `json:"pages"`
}

MangaPagesResponse represents the API's manga pages response

type SearchResponse

type SearchResponse struct {
	Results []SearchResult `json:"results"`
}

SearchResponse represents the API's search response

type SearchResult

type SearchResult struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Image       string `json:"image"`
	URL         string `json:"url"`         // Can contain type info (e.g., /movie/ or /tv/)
	ReleaseDate string `json:"releaseDate"` // Release date from API (YYYY-MM-DD format)
	Type        string `json:"type"`        // "Movie" or "TV Series"
}

SearchResult represents a single search result from the API

type Server

type Server struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

Server represents a streaming server option

type Source

type Source struct {
	URL     string `json:"url"`
	Quality string `json:"quality"`
	IsM3U8  bool   `json:"isM3U8"`
	Referer string `json:"referer,omitempty"` // Optional referer from source (HiAnime)
	Origin  string `json:"origin,omitempty"`  // Optional origin from source
}

Source represents a video source

type SourceHeaders

type SourceHeaders struct {
	Referer string `json:"Referer,omitempty"`
	Origin  string `json:"Origin,omitempty"`
}

SourceHeaders contains headers required for video playback

type SourcesResponse

type SourcesResponse struct {
	Sources   []Source       `json:"sources"`
	Subtitles []Subtitle     `json:"subtitles"`
	Headers   *SourceHeaders `json:"headers,omitempty"`
}

SourcesResponse represents the API's sources response

type Subtitle

type Subtitle struct {
	URL  string `json:"url"`
	Lang string `json:"lang"`
}

Subtitle represents a subtitle track

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL