feat: typed anime and playback payloads
This commit is contained in:
@@ -17,8 +17,8 @@ type ThemesData = jikan.ThemesData
|
||||
type ReviewEntry = jikan.ReviewEntry
|
||||
|
||||
type AnimeService interface {
|
||||
GetCatalogSection(ctx context.Context, userID string, section string) (map[string]any, error)
|
||||
GetDiscoverSection(ctx context.Context, userID string, section string) (map[string]any, error)
|
||||
GetCatalogSection(ctx context.Context, userID string, section string) (CatalogSectionData, error)
|
||||
GetDiscoverSection(ctx context.Context, userID string, section string) (DiscoverSectionData, error)
|
||||
GetAnimeByID(ctx context.Context, id int) (Anime, error)
|
||||
SearchAdvanced(ctx context.Context, q, animeType, status, orderBy, sort string, genres []int, sfw bool, page, limit int) (jikan.SearchResult, error)
|
||||
GetGenres(ctx context.Context) ([]Genre, error)
|
||||
@@ -34,6 +34,29 @@ type AnimeService interface {
|
||||
GetReviews(ctx context.Context, id int, page int) ([]ReviewEntry, bool, error)
|
||||
}
|
||||
|
||||
type CatalogSectionData struct {
|
||||
Animes []Anime
|
||||
ContinueWatching []db.GetContinueWatchingEntriesRow
|
||||
Section string
|
||||
WatchlistMap map[int64]bool
|
||||
Fragment string
|
||||
}
|
||||
|
||||
func (d CatalogSectionData) TemplateFragment() string {
|
||||
return d.Fragment
|
||||
}
|
||||
|
||||
type DiscoverSectionData struct {
|
||||
Animes []Anime
|
||||
Section string
|
||||
WatchlistMap map[int64]bool
|
||||
Fragment string
|
||||
}
|
||||
|
||||
func (d DiscoverSectionData) TemplateFragment() string {
|
||||
return d.Fragment
|
||||
}
|
||||
|
||||
type AnimeRepository interface {
|
||||
GetUserWatchList(ctx context.Context, userID string) ([]db.GetUserWatchListRow, error)
|
||||
GetWatchListEntry(ctx context.Context, params db.GetWatchListEntryParams) (db.WatchListEntry, error)
|
||||
|
||||
@@ -6,13 +6,68 @@ import (
|
||||
)
|
||||
|
||||
type PlaybackService interface {
|
||||
BuildWatchData(ctx context.Context, animeID int, titleCandidates []string, episode string, mode string, userID string) (map[string]any, error)
|
||||
BuildWatchData(ctx context.Context, animeID int, titleCandidates []string, episode string, mode string, userID string) (WatchPageData, error)
|
||||
SaveProgress(ctx context.Context, userID string, animeID int64, episode int, timeSeconds float64) error
|
||||
CompleteAnime(ctx context.Context, userID string, animeID int64) error
|
||||
ResolveProxyToken(token string) (string, string, error)
|
||||
UpsertSkipSegmentOverride(ctx context.Context, userID string, animeID int64, episode int, skipType string, startTime, endTime float64) error
|
||||
}
|
||||
|
||||
type WatchPageData struct {
|
||||
WatchData WatchData
|
||||
Anime Anime
|
||||
Episodes []CanonicalEpisode
|
||||
CurrentEpID string
|
||||
WatchlistStatus string
|
||||
WatchlistIDs []int64
|
||||
Seasons []SeasonEntry
|
||||
User *User
|
||||
CurrentPath string
|
||||
Error string
|
||||
}
|
||||
|
||||
type WatchData struct {
|
||||
MalID int
|
||||
Title string
|
||||
CurrentEpisode string
|
||||
StartTimeSeconds float64
|
||||
Episodes []CanonicalEpisode
|
||||
Providers []ProviderData
|
||||
ModeSources map[string]ModeSource
|
||||
InitialMode string
|
||||
ModeSwitchedFrom string
|
||||
AvailableModes []string
|
||||
Segments []SkipSegment
|
||||
}
|
||||
|
||||
type SubtitleItem struct {
|
||||
Lang string `json:"lang"`
|
||||
URL string `json:"url,omitempty"`
|
||||
Referer string `json:"referer,omitempty"`
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type ModeSource struct {
|
||||
URL string `json:"url,omitempty"`
|
||||
Referer string `json:"referer,omitempty"`
|
||||
Token string `json:"token"`
|
||||
Subtitles []SubtitleItem `json:"subtitles"`
|
||||
Qualities []string `json:"qualities,omitempty"`
|
||||
}
|
||||
|
||||
type SeasonEntry struct {
|
||||
MalID int `json:"mal_id"`
|
||||
Title string `json:"title"`
|
||||
Prefix string `json:"prefix"`
|
||||
IsCurrent bool `json:"is_current"`
|
||||
}
|
||||
|
||||
type SkipSegment struct {
|
||||
Type string `json:"type"`
|
||||
Start float64 `json:"start"`
|
||||
End float64 `json:"end"`
|
||||
}
|
||||
|
||||
type ProviderStream struct {
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url"`
|
||||
|
||||
Reference in New Issue
Block a user