From 857bd85b4ffb37f767ae4c63e09fa24734713a2a Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 12 May 2026 12:34:39 +0200 Subject: [PATCH] refactor: remove unused playback methods and source resolution --- api/playback/allanime_client.go | 87 --------------------------------- api/playback/service_base.go | 9 ---- api/playback/service_sources.go | 19 ------- 3 files changed, 115 deletions(-) diff --git a/api/playback/allanime_client.go b/api/playback/allanime_client.go index eaa2553..87a2192 100644 --- a/api/playback/allanime_client.go +++ b/api/playback/allanime_client.go @@ -562,57 +562,6 @@ func (c *allAnimeClient) Search(ctx context.Context, query string, mode string) return out, nil } -// GetEpisodes returns the list of available episode strings for a show and mode. -func (c *allAnimeClient) GetEpisodes(ctx context.Context, showID string, mode string) ([]string, error) { - graphqlQuery := `query($showId: String!) { - show(_id: $showId) { - availableEpisodesDetail - } - }` - - result, err := c.graphqlRequest(ctx, graphqlQuery, map[string]any{"showId": showID}) - if err != nil { - return nil, err - } - - data, ok := result["data"].(map[string]any) - if !ok { - return nil, fmt.Errorf("invalid episode response") - } - - show, ok := data["show"].(map[string]any) - if !ok || show == nil { - return nil, fmt.Errorf("show not found") - } - - detail, ok := show["availableEpisodesDetail"].(map[string]any) - if !ok { - return nil, fmt.Errorf("invalid episodes detail") - } - - rawList, ok := detail[mode].([]any) - if !ok { - return nil, fmt.Errorf("no episodes for mode %s", mode) - } - - episodes := make([]string, 0, len(rawList)) - for _, item := range rawList { - episode, ok := item.(string) - if !ok { - continue - } - - episode = strings.TrimSpace(episode) - if episode == "" { - continue - } - - episodes = append(episodes, episode) - } - - return episodes, nil -} - // GetAvailableEpisodes returns the count of sub/dub/raw episodes available for a show. func (c *allAnimeClient) GetAvailableEpisodes(ctx context.Context, showID string) (AvailableEpisodes, error) { graphqlQuery := `query($showId: String!) { @@ -668,42 +617,6 @@ func (c *allAnimeClient) GetAvailableEpisodes(ctx context.Context, showID string return count, nil } -func (c *allAnimeClient) GetEpisodeMetadata(ctx context.Context, showID string, episode string) (map[string]any, error) { - graphqlQuery := `query($showId: String!, $episodeString: String!, $translationType: VaildTranslationTypeEnumType!) { - episode(showId: $showId, episodeString: $episodeString, translationType: $translationType) { - notes - episodeInfo { - notes - thumbnails - vidinfors { - vidPath - } - } - } - }` - - result, err := c.graphqlRequest(ctx, graphqlQuery, map[string]any{ - "showId": showID, - "episodeString": episode, - "translationType": "sub", - }) - if err != nil { - return nil, err - } - - data, ok := result["data"].(map[string]any) - if !ok { - return nil, fmt.Errorf("invalid response") - } - - ep, ok := data["episode"].(map[string]any) - if !ok { - return nil, fmt.Errorf("episode not found") - } - - return ep, nil -} - func decodeSourceURL(encoded string) string { if encoded == "" { return "" diff --git a/api/playback/service_base.go b/api/playback/service_base.go index 408027f..f1e6a13 100644 --- a/api/playback/service_base.go +++ b/api/playback/service_base.go @@ -349,15 +349,6 @@ func clonePlaybackBaseData(data playbackBaseData) playbackBaseData { } } -// GetEpisodeMetadata fetches episode notes and thumbnails from AllAnime. -func (s *Service) GetEpisodeMetadata(ctx context.Context, malID int, episode string) (map[string]any, error) { - showID, _, err := s.resolveShowCached(ctx, malID, nil) - if err != nil { - return nil, err - } - return s.allAnimeClient.GetEpisodeMetadata(ctx, showID, episode) -} - func toQualities(sources []StreamSource) []string { seen := make(map[string]struct{}) var qualities []string diff --git a/api/playback/service_sources.go b/api/playback/service_sources.go index 3eddf14..b4e69b6 100644 --- a/api/playback/service_sources.go +++ b/api/playback/service_sources.go @@ -9,25 +9,6 @@ import ( "sync" ) -// resolveModeSource fetches sources for a given mode and selects the best one. -func (s *Service) resolveModeSource(ctx context.Context, showID string, episode string, mode string, quality string) (StreamSource, error) { - sources, err := s.allAnimeClient.GetEpisodeSources(ctx, showID, episode, mode) - if err != nil { - return StreamSource{}, err - } - - ranked, err := rankSources(sources, quality) - if err != nil { - return StreamSource{}, err - } - - selected, _, err := s.choosePlaybackSource(ctx, ranked, s.probeDirectMedia) - if err != nil { - return StreamSource{}, err - } - - return selected, nil -} // resolveModeSourceWithCache is like resolveModeSource but caches probe results. func (s *Service) resolveModeSourceWithCache(