refactor: remove unreachable jikan client functions
This commit is contained in:
@@ -8,11 +8,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Search performs a basic anime search by query string.
|
||||
func (c *Client) Search(ctx context.Context, query string, page int) (SearchResult, error) {
|
||||
return c.search(ctx, query, page, 0)
|
||||
}
|
||||
|
||||
// SearchAdvanced performs a filtered anime search with type, status, ordering, and genre filters.
|
||||
func (c *Client) SearchAdvanced(ctx context.Context, query, animeType, status, orderBy, sort string, genres []int, sfw bool, page, limit int) (SearchResult, error) {
|
||||
if page < 1 {
|
||||
@@ -78,52 +73,6 @@ func (c *Client) SearchAdvanced(ctx context.Context, query, animeType, status, o
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Client) search(ctx context.Context, query string, page int, limit int) (SearchResult, error) {
|
||||
if query == "" {
|
||||
return SearchResult{}, nil
|
||||
}
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
if limit < 0 {
|
||||
limit = 0
|
||||
}
|
||||
|
||||
cacheKey := fmt.Sprintf("search:%s:%d:%d", query, page, limit)
|
||||
|
||||
var result SearchResponse
|
||||
reqURL := fmt.Sprintf("%s/anime?q=%s&page=%d", c.baseURL, url.QueryEscape(query), page)
|
||||
if limit > 0 {
|
||||
reqURL = fmt.Sprintf("%s&limit=%d", reqURL, limit)
|
||||
}
|
||||
|
||||
if err := c.getWithCache(ctx, cacheKey, shortCacheTTL, reqURL, &result); err != nil {
|
||||
if limit > 0 && IsRetryableError(err) {
|
||||
fallbackURL := fmt.Sprintf("%s/anime?q=%s&page=%d", c.baseURL, url.QueryEscape(query), page)
|
||||
if fallbackErr := c.fetchWithRetry(ctx, fallbackURL, &result); fallbackErr == nil {
|
||||
res := SearchResult{
|
||||
Animes: result.Data,
|
||||
HasNextPage: result.Pagination.HasNextPage,
|
||||
}
|
||||
c.setCache(ctx, cacheKey, res, shortCacheTTL)
|
||||
return res, nil
|
||||
}
|
||||
}
|
||||
|
||||
var stale SearchResult
|
||||
if c.getStaleCache(ctx, cacheKey, &stale) {
|
||||
return stale, nil
|
||||
}
|
||||
|
||||
return SearchResult{}, err
|
||||
}
|
||||
|
||||
return SearchResult{
|
||||
Animes: result.Data,
|
||||
HasNextPage: result.Pagination.HasNextPage,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetTopAnime returns the top-rated anime list for a given page.
|
||||
func (c *Client) GetTopAnime(ctx context.Context, page int) (TopAnimeResult, error) {
|
||||
if page < 1 {
|
||||
|
||||
Reference in New Issue
Block a user