extractors

package
v0.0.0-...-c3a6988 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCreatorIDRequired = errors.New("creator id is required")

ErrCreatorIDRequired is returned when no producer/studio identifier is provided.

View Source
var ErrCreatorPageOutOfRange = errors.New("creator page exceeds available pages")

ErrCreatorPageOutOfRange is returned when the requested page is larger than the number of available pages for a producer/studio listing.

Functions

func ExtractNextEpisodeSchedule

func ExtractNextEpisodeSchedule(id string, baseURL string) (string, error)

ExtractNextEpisodeSchedule extracts next episode schedule information. It loads the watch page and reads `.schedule-alert > .alert.small > span:last` data-value attribute, which contains the next episode timestamp.

func ExtractRandomID

func ExtractRandomID(baseURL string) (string, error)

func ResolveStreamingLinkForTest

func ResolveStreamingLinkForTest(fullEpisodeID, episodeIDOnly, serverID, serverName, typ string, fallback bool) (parsers.DecryptedSources, error)

ResolveStreamingLinkForTest exposes resolveStreamingLink for unit tests.

func SetExtractPageFuncForTest

func SetExtractPageFuncForTest(fn func(int, string, string) ([]scrape.ExtractedItem, int, error)) func()

SetExtractPageFuncForTest allows tests to replace the scraping function and returns a restore callback to reinstate the default behavior.

func SetStreamDecryptorsForTest

func SetStreamDecryptorsForTest(
	megacloud func(string, string, string) (parsers.DecryptedSources, error),
	legacy func(string, string, string, string, bool) (parsers.DecryptedSources, error),
) func()

SetStreamDecryptorsForTest overrides the decryptor functions and returns a restore callback. Intended for use in unit tests located outside this package.

Types

type AnimeInfo

type AnimeInfo struct {
	AdultContent          bool                    `json:"adultContent"`
	DataID                string                  `json:"data_id"`
	ID                    string                  `json:"id"`
	AnilistID             string                  `json:"anilistId"`
	MalID                 string                  `json:"malId"`
	Title                 string                  `json:"title"`
	JapaneseTitle         string                  `json:"japanese_title"`
	Synonyms              string                  `json:"synonyms"`
	Poster                string                  `json:"poster"`
	ShowType              string                  `json:"showType"`
	AnimeInfo             map[string]interface{}  `json:"animeInfo"`
	TVInfo                map[string]string       `json:"tvInfo"`
	Trailers              []Trailer               `json:"trailers"`
	CharactersVoiceActors []CharactersVoiceActors `json:"charactersVoiceActors"`
	RecommendedData       []RecommendItem         `json:"recommended_data"`
	RelatedData           []SidebarItem           `json:"related_data"`
	PopularData           []SidebarItem           `json:"popular_data"`
}

func ExtractAnimeInfo

func ExtractAnimeInfo(id, baseURL string) (AnimeInfo, error)

func ExtractRandom

func ExtractRandom(baseURL string) (AnimeInfo, error)

ExtractRandom fetches a random anime ID and returns its full info.

type CategoryResult

type CategoryResult struct {
	Data       []scrape.ExtractedItem `json:"data"`
	TotalPages int                    `json:"totalPages"`
}

func ExtractCategory

func ExtractCategory(path string, page int, baseURL string) (CategoryResult, error)

func ExtractProducer

func ExtractProducer(id string, page int, baseURL string) (CategoryResult, error)

ExtractProducer extracts producer information, returning the paginated list of anime for a given producer slug.

func ExtractStudio

func ExtractStudio(id string, page int, baseURL string) (CategoryResult, error)

ExtractStudio extracts studio information (same layout as producer pages).

type CharacterData

type CharacterData struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Profile      string `json:"profile"`
	JapaneseName string `json:"japaneseName"`
	About        struct {
		Description string `json:"description"`
		Style       string `json:"style"`
	} `json:"about"`
	VoiceActors []struct {
		Name     string `json:"name"`
		Profile  string `json:"profile"`
		Language string `json:"language"`
		ID       string `json:"id"`
	} `json:"voiceActors"`
	Animeography []struct {
		Title         string `json:"title"`
		JapaneseTitle string `json:"japanese_title"`
		ID            string `json:"id"`
		Role          string `json:"role"`
		Type          string `json:"type"`
		Poster        string `json:"poster"`
	} `json:"animeography"`
}

type CharacterResult

type CharacterResult struct {
	Success bool `json:"success"`
	Results struct {
		Data []CharacterData `json:"data"`
	} `json:"results"`
}

func ExtractCharacter

func ExtractCharacter(id string, baseURL string) (CharacterResult, error)

type CharactersVoiceActors

type CharactersVoiceActors struct {
	Character struct {
		ID     string `json:"id"`
		Poster string `json:"poster"`
		Name   string `json:"name"`
		Cast   string `json:"cast"`
	} `json:"character"`
	VoiceActors []struct {
		ID     string `json:"id"`
		Poster string `json:"poster"`
		Name   string `json:"name"`
	} `json:"voiceActors"`
}

type EpisodeEntry

type EpisodeEntry struct {
	EpisodeNo     int    `json:"episode_no"`
	ID            string `json:"id"`
	Title         string `json:"title"`
	JapaneseTitle string `json:"japanese_title"`
	Filler        bool   `json:"filler"`
}

type EpisodeHTMLResponse

type EpisodeHTMLResponse struct {
	Status bool   `json:"status"`
	HTML   string `json:"html"`
}

type EpisodeList

type EpisodeList struct {
	TotalEpisodes int            `json:"totalEpisodes"`
	Episodes      []EpisodeEntry `json:"episodes"`
}

func ExtractEpisodeList

func ExtractEpisodeList(id string, baseURL string) (EpisodeList, error)

type FilterResult

type FilterResult struct {
	TotalPage int                      `json:"totalPage"`
	Data      []map[string]interface{} `json:"data"`
	Page      int                      `json:"page"`
	HasNext   bool                     `json:"hasNext"`
}

func ExtractFilter

func ExtractFilter(params map[string]string, baseURL string) (FilterResult, error)

type QtipData

type QtipData struct {
	Title         string   `json:"title"`
	Rating        string   `json:"rating"`
	Quality       string   `json:"quality"`
	SubCount      string   `json:"subCount"`
	DubCount      string   `json:"dubCount"`
	EpisodeCount  string   `json:"episodeCount"`
	Type          string   `json:"type"`
	Description   string   `json:"description"`
	JapaneseTitle string   `json:"japaneseTitle"`
	Synonyms      string   `json:"Synonyms"`
	AiredDate     string   `json:"airedDate"`
	Status        string   `json:"status"`
	Genres        []string `json:"genres"`
	WatchLink     string   `json:"watchLink"`
}

func ExtractQtip

func ExtractQtip(id string, baseURL string) (QtipData, error)

type RecommendItem

type RecommendItem struct {
	DataID        string            `json:"data_id"`
	ID            string            `json:"id"`
	Title         string            `json:"title"`
	JapaneseTitle string            `json:"japanese_title"`
	Poster        string            `json:"poster"`
	TVInfo        map[string]string `json:"tvInfo"`
	AdultContent  bool              `json:"adultContent"`
}

func ExtractRecommendedData

func ExtractRecommendedData(id, baseURL string) ([]RecommendItem, error)

type Role

type Role struct {
	Anime struct {
		ID     string `json:"id"`
		Title  string `json:"title"`
		Poster string `json:"poster"`
		Type   string `json:"type"`
		Year   string `json:"year"`
	} `json:"anime"`
	Character struct {
		ID      string `json:"id"`
		Name    string `json:"name"`
		Profile string `json:"profile"`
		Role    string `json:"role"`
	} `json:"character"`
}

type ScheduleItem

type ScheduleItem struct {
	ID            string `json:"id"`
	DataID        string `json:"data_id"`
	Title         string `json:"title"`
	JapaneseTitle string `json:"japanese_title"`
	ReleaseDate   string `json:"releaseDate"`
	Time          string `json:"time"`
	EpisodeNo     string `json:"episode_no"`
}

func ExtractSchedule

func ExtractSchedule(date string, tzOffset int, baseURL string) ([]ScheduleItem, error)

type SearchResult

type SearchResult struct {
	TotalPage int                      `json:"totalPage"`
	Data      []map[string]interface{} `json:"data"`
}

func ExtractSearch

func ExtractSearch(params map[string]string, baseURL string) (SearchResult, error)

type SeasonItem

type SeasonItem struct {
	ID           string `json:"id"`
	DataNumber   int    `json:"data_number"`
	DataID       int    `json:"data_id"`
	Season       string `json:"season"`
	Title        string `json:"title"`
	SeasonPoster string `json:"season_poster"`
}

func ExtractSeasons

func ExtractSeasons(id, baseURL string) ([]SeasonItem, error)

type ServerItem

type ServerItem struct {
	Type       string `json:"type"`
	DataID     string `json:"data_id"`
	ServerID   string `json:"server_id"`
	ServerName string `json:"serverName"`
}

func ExtractServers

func ExtractServers(episodeID string, baseURL string) ([]ServerItem, error)

func FindServerMatchByTypeForTest

func FindServerMatchByTypeForTest(servers []ServerItem, name, typ string) *ServerItem

FindServerMatchByTypeForTest exposes findServerMatchByType for tests.

func FindServerMatchForTest

func FindServerMatchForTest(servers []ServerItem, target string) *ServerItem

FindServerMatchForTest exposes findServerMatch for black-box tests.

type SidebarItem

type SidebarItem struct {
	DataID        string            `json:"data_id"`
	ID            string            `json:"id"`
	Title         string            `json:"title"`
	JapaneseTitle string            `json:"japanese_title"`
	Poster        string            `json:"poster"`
	TVInfo        map[string]string `json:"tvInfo"`
	AdultContent  bool              `json:"adultContent"`
}

func ExtractPopularData

func ExtractPopularData(id, baseURL string) ([]SidebarItem, error)

ExtractPopularData scrapes "Most Popular" sidebar for a given anime page id

func ExtractRelatedData

func ExtractRelatedData(id, baseURL string) ([]SidebarItem, error)

type SpotlightItem

type SpotlightItem struct {
	ID            string                 `json:"id"`
	DataID        string                 `json:"data_id"`
	Poster        string                 `json:"poster"`
	Title         string                 `json:"title"`
	JapaneseTitle string                 `json:"japanese_title"`
	Description   string                 `json:"description"`
	TVInfo        map[string]interface{} `json:"tvInfo"`
}

func ExtractSpotlights

func ExtractSpotlights(baseURL string) ([]SpotlightItem, error)

type StreamingInfo

type StreamingInfo struct {
	StreamingLink parsers.DecryptedSources `json:"streamingLink"`
	Servers       []ServerItem             `json:"servers"`
}

func ExtractStreamingInfo

func ExtractStreamingInfo(fullID, name, typ string, fallback bool, baseURL string) (StreamingInfo, error)

type SuggestionItem

type SuggestionItem struct {
	ID            string `json:"id"`
	DataID        string `json:"data_id"`
	Poster        string `json:"poster"`
	Title         string `json:"title"`
	JapaneseTitle string `json:"japanese_title"`
	ReleaseDate   string `json:"releaseDate"`
	ShowType      string `json:"showType"`
	Duration      string `json:"duration"`
}

func ExtractSuggestions

func ExtractSuggestions(keyword, baseURL string) ([]SuggestionItem, error)

type TopSearchItem

type TopSearchItem struct {
	Title string `json:"title"`
	Link  string `json:"link"`
}

func ExtractTopSearch

func ExtractTopSearch(baseURL string) ([]TopSearchItem, error)

type TopTenItem

type TopTenItem struct {
	ID            string            `json:"id"`
	DataID        string            `json:"data_id"`
	Number        string            `json:"number"`
	Title         string            `json:"title"`
	JapaneseTitle string            `json:"japanese_title"`
	Poster        string            `json:"poster"`
	TVInfo        map[string]string `json:"tvInfo"`
}

type TopTenResult

type TopTenResult map[string][]TopTenItem

func ExtractTopTen

func ExtractTopTen(baseURL string) (TopTenResult, error)

type Trailer

type Trailer struct {
	Title     string `json:"title"`
	URL       string `json:"url"`
	Thumbnail string `json:"thumbnail"`
}

type TrendingItem

type TrendingItem struct {
	ID            string `json:"id"`
	DataID        string `json:"data_id"`
	Number        string `json:"number"`
	Poster        string `json:"poster"`
	Title         string `json:"title"`
	JapaneseTitle string `json:"japanese_title"`
}

func ExtractTrending

func ExtractTrending(baseURL string) ([]TrendingItem, error)

type VoiceActorData

type VoiceActorData struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Profile      string `json:"profile"`
	JapaneseName string `json:"japaneseName"`
	About        struct {
		Description string `json:"description"`
		Style       string `json:"style"`
	} `json:"about"`
	Roles []Role `json:"roles"`
}

type VoiceActorPageResult

type VoiceActorPageResult struct {
	TotalPages            int                     `json:"totalPages"`
	CharactersVoiceActors []CharactersVoiceActors `json:"charactersVoiceActors"`
}

func ExtractVoiceActorPage

func ExtractVoiceActorPage(id string, page int, baseURL string) (VoiceActorPageResult, error)

type VoiceActorResult

type VoiceActorResult struct {
	Success bool `json:"success"`
	Results struct {
		Data []VoiceActorData `json:"data"`
	} `json:"results"`
}

func ExtractVoiceActor

func ExtractVoiceActor(id string, baseURL string) (VoiceActorResult, error)

type WatchlistItem

type WatchlistItem struct {
	ID       string `json:"id"`
	Title    string `json:"title"`
	Poster   string `json:"poster"`
	Duration string `json:"duration"`
	Type     string `json:"type"`
	SubCount string `json:"subCount"`
	DubCount string `json:"dubCount"`
	Link     string `json:"link"`
	ShowType string `json:"showType"`
	TVInfo   struct {
		ShowType string `json:"showType"`
		Duration string `json:"duration"`
		Sub      string `json:"sub"`
		Dub      string `json:"dub"`
	} `json:"tvInfo"`
}

type WatchlistResult

type WatchlistResult struct {
	Watchlist  []WatchlistItem `json:"watchlist"`
	TotalPages int             `json:"totalPages"`
}

func ExtractWatchlist

func ExtractWatchlist(userID string, page int, baseURL string) (WatchlistResult, error)

Jump to

Keyboard shortcuts

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