feat: add shared query param helpers for jikan

This commit is contained in:
2026-06-11 12:27:56 +02:00
parent 4b95f85d4d
commit 5ada1f72e4
6 changed files with 103 additions and 45 deletions

View File

@@ -3,6 +3,8 @@ package jikan
import (
"context"
"fmt"
"net/url"
"strconv"
"sync"
"time"
)
@@ -15,7 +17,9 @@ func (c *Client) GetEpisodes(ctx context.Context, animeID int, page int) (Episod
cacheKey := fmt.Sprintf("anime:%d:episodes:%d", animeID, page)
var result EpisodesResponse
reqURL := fmt.Sprintf("%s/anime/%d/episodes?page=%d", c.baseURL, animeID, page)
params := url.Values{}
params.Set("page", strconv.Itoa(page))
reqURL := buildRequestURL(c.baseURL, fmt.Sprintf("/anime/%d/episodes", animeID), params)
err := c.getWithCache(ctx, cacheKey, 12*time.Hour, reqURL, &result)
return result, err