api

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package api provides enhanced episode URL fetching with AllAnime navigation support

Package api provides enhanced anime search and streaming capabilities

Package api provides episode data fetching from multiple sources with fallback support. This enables robust episode information retrieval even when primary APIs are unavailable.

Index

Constants

This section is empty.

Variables

View Source
var ErrBackToSearch = errors.New("back to search requested")

ErrBackToSearch is returned when user selects the back option to search again

Functions

func CleanTitle added in v1.0.9

func CleanTitle(title string) string

func DownloadAllAnimeSmartRange added in v1.6.0

func DownloadAllAnimeSmartRange(anime *models.Anime, startEp, endEp int, quality string) error

DownloadAllAnimeSmartRange downloads a range of episodes exclusively for AllAnime. It prioritizes high-quality mirrors and writes AniSkip sidecar files for intro/outro skipping.

func DownloadEpisodeEnhanced added in v1.6.0

func DownloadEpisodeEnhanced(anime *models.Anime, episodeNum int, quality string) error

Enhanced download support

func DownloadEpisodeRangeEnhanced added in v1.6.0

func DownloadEpisodeRangeEnhanced(anime *models.Anime, startEp, endEp int, quality string) error

Enhanced range download support

func FetchAnimeData added in v1.1.0

func FetchAnimeData(animeID int, episodeNo int, anime *models.Anime) error

Unified function to fetch anime data from Jikan API

func FetchAnimeDetails added in v1.0.9

func FetchAnimeDetails(anime *models.Anime) error

FetchAnimeDetails retrieves additional information for the selected anime

func FetchAnimeFromAniList added in v1.0.9

func FetchAnimeFromAniList(animeName string) (*models.AniListResponse, error)

func GetAllAnimeEpisodeURLDirect added in v1.6.0

func GetAllAnimeEpisodeURLDirect(anime *models.Anime, episodeNumber string, quality string) (string, map[string]string, error)

GetAllAnimeEpisodeURLDirect gets streaming URL directly without circular dependencies

func GetAndParseAniSkipData added in v1.0.9

func GetAndParseAniSkipData(animeMalId int, episodeNum int, episode *models.Episode) error

GetAndParseAniSkipData fetches and parses skip times for a given anime ID and episode

func GetAniSkipData added in v1.0.9

func GetAniSkipData(animeMalId int, episode int) (string, error)

GetAniSkipData fetches skip times data for a given anime ID and episode

func GetAnimeEpisodes

func GetAnimeEpisodes(animeURL string) ([]models.Episode, error)

GetAnimeEpisodes fetches and parses the list of episodes for a given anime. It returns a sorted slice of Episode structs, ordered by episode number.

Parameters: - animeURL: the URL of the anime's page.

Returns: - []models.Episode: a slice of Episode structs, sorted by episode number. - error: an error if the process fails at any step.

func GetAnimeEpisodesEnhanced added in v1.6.0

func GetAnimeEpisodesEnhanced(anime *models.Anime) ([]models.Episode, error)

Enhanced episode fetching that works with different sources

func GetAnimeEpisodesWithSource added in v1.6.0

func GetAnimeEpisodesWithSource(anime *models.Anime) ([]models.Episode, error)

func GetEpisodeData added in v1.0.9

func GetEpisodeData(animeID int, episodeNo int, anime *models.Anime) error

GetEpisodeData fetches episode data using multiple providers with fallback support. It tries Jikan (MyAnimeList) first, then falls back to AniList and Kitsu if needed. This provides robust episode data retrieval even when primary APIs are unavailable.

func GetEpisodeDataWithFallback added in v1.6.0

func GetEpisodeDataWithFallback(animeID int, episodeNo int, anime *models.Anime) error

GetEpisodeDataWithFallback fetches episode data trying multiple providers

func GetEpisodeStreamURL added in v1.6.0

func GetEpisodeStreamURL(episode *models.Episode, anime *models.Anime, quality string) (string, error)

Enhanced episode URL fetching with improved source detection

func GetEpisodeStreamURLEnhanced added in v1.6.0

func GetEpisodeStreamURLEnhanced(episode *models.Episode, anime *models.Anime, quality string) (string, error)

GetEpisodeStreamURLEnhanced gets streaming URL with AllAnime navigation support

func GetFlixHQEpisodes added in v1.6.0

func GetFlixHQEpisodes(media *models.Anime) ([]models.Episode, error)

GetFlixHQEpisodes handles episodes/content for FlixHQ movies and TV shows

func GetFlixHQStreamURL added in v1.6.0

func GetFlixHQStreamURL(media *models.Anime, episode *models.Episode, quality string) (string, []models.Subtitle, error)

GetFlixHQStreamURL gets the stream URL for FlixHQ content

func GetMovieData added in v1.0.9

func GetMovieData(animeID int, anime *models.Anime) error

GetMovieData fetches movie/OVA data for a given anime ID from Jikan API

func IsDisallowedIP

func IsDisallowedIP(hostIP string) bool

IsDisallowedIP checks if the given IP address falls under a disallowed category. It returns true if the IP address is multicast, unspecified, loopback, or private.

Parameters: - hostIP: a string representing the IP address to check.

Returns: - bool: true if the IP address is disallowed, false otherwise.

func IsSeries

func IsSeries(animeURL string) (bool, int, error)

IsSeries checks if the given anime URL corresponds to a series (multiple episodes). It returns a boolean indicating if the anime has more than one episode, the total number of episodes, and an error if any issues occur.

Parameters: - animeURL: the URL of the anime's page.

Returns: - bool: true if the anime has more than one episode (i.e., is a series), false otherwise. - int: the total number of episodes found. - error: an error if the process of retrieving episodes fails.

func IsSeriesEnhanced added in v1.6.0

func IsSeriesEnhanced(anime *models.Anime) (bool, int, error)

IsSeriesEnhanced checks if the given anime corresponds to a series using enhanced API

func ParseAniSkipResponse added in v1.0.9

func ParseAniSkipResponse(responseText string, episode *models.Episode, timePrecision int) error

ParseAniSkipResponse parses the response text from the AniSkip API and updates the Episode struct

func ParseAnimes added in v1.0.7

func ParseAnimes(doc *goquery.Document) []models.Anime

func RoundTime added in v1.0.9

func RoundTime(timeValue float64, precision int) float64

RoundTime rounds a time value to the specified precision

func SafeGet

func SafeGet(url string) (*http.Response, error)

SafeGet performs an HTTP GET request to the specified URL using a custom HTTP client with a timeout. The function returns the response or an error if the request fails.

Parameters: - url: the URL to send the GET request to.

Returns: - *http.Response: a pointer to the HTTP response object containing the server's response. - error: an error if the request fails or if there is a problem during the request.

func SafeTransport

func SafeTransport(timeout time.Duration) *http.Transport

SafeTransport returns an http.Transport with custom dial functions for both regular and TLS connections. The transport is configured with a specified timeout and ensures that all TLS connections use a minimum version of TLS 1.2.

Parameters: - timeout: the duration for both the connection timeout and the TLS handshake timeout.

Returns: - *http.Transport: a pointer to an http.Transport configured with custom dial functions and security settings.

func SearchAnime

func SearchAnime(animeName string) (*models.Anime, error)

func SearchAnimeEnhanced added in v1.6.0

func SearchAnimeEnhanced(name string, source string) (*models.Anime, error)

Enhanced search that supports multiple sources - always searches both Animefire.io and allanime simultaneously

func SearchAnimeWithSource added in v1.6.0

func SearchAnimeWithSource(name string, source string) (*models.Anime, error)

Legacy wrapper functions to maintain compatibility

func WriteAniSkipSidecar added in v1.6.0

func WriteAniSkipSidecar(videoPath string, ep *models.Episode) error

WriteAniSkipSidecar is an exported wrapper to write AniSkip sidecar files. It delegates to the internal writeAniSkipSidecar and exists to allow other packages (e.g., player) to generate the sidecar after downloads.

Types

type AniListProvider added in v1.6.0

type AniListProvider struct{}

AniListProvider fetches episode data from AniList GraphQL API

func (*AniListProvider) FetchEpisodeData added in v1.6.0

func (p *AniListProvider) FetchEpisodeData(animeID int, episodeNo int, anime *models.Anime) error

func (*AniListProvider) Name added in v1.6.0

func (p *AniListProvider) Name() string

type EpisodeDataProvider added in v1.6.0

type EpisodeDataProvider interface {
	Name() string
	FetchEpisodeData(animeID int, episodeNo int, anime *models.Anime) error
}

EpisodeDataProvider defines an interface for fetching episode data from various sources

type JikanProvider added in v1.6.0

type JikanProvider struct{}

JikanProvider fetches episode data from Jikan (MyAnimeList) API

func (*JikanProvider) FetchEpisodeData added in v1.6.0

func (p *JikanProvider) FetchEpisodeData(animeID int, episodeNo int, anime *models.Anime) error

func (*JikanProvider) Name added in v1.6.0

func (p *JikanProvider) Name() string

type KitsuProvider added in v1.6.0

type KitsuProvider struct{}

KitsuProvider fetches episode data from Kitsu API

func (*KitsuProvider) FetchEpisodeData added in v1.6.0

func (p *KitsuProvider) FetchEpisodeData(animeID int, episodeNo int, anime *models.Anime) error

func (*KitsuProvider) Name added in v1.6.0

func (p *KitsuProvider) Name() string

Directories

Path Synopsis
Package movie provides media enrichment functions for movies and TV shows
Package movie provides media enrichment functions for movies and TV shows

Jump to

Keyboard shortcuts

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