From 3dfbcdb8157255ba806408e6dc5245cda73f82ff Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 23 Jun 2026 17:27:40 +0200 Subject: [PATCH] refactor: move producer type and method out of studio.go --- integrations/jikan/producers.go | 15 +++++++++++ integrations/jikan/studio.go | 44 --------------------------------- integrations/jikan/types.go | 23 +++++++++++++++++ 3 files changed, 38 insertions(+), 44 deletions(-) delete mode 100644 integrations/jikan/studio.go diff --git a/integrations/jikan/producers.go b/integrations/jikan/producers.go index a29b6a8..6c7b77d 100644 --- a/integrations/jikan/producers.go +++ b/integrations/jikan/producers.go @@ -27,6 +27,21 @@ type ProducerListResult struct { HasNextPage bool } +func (c *Client) GetProducerByID(ctx context.Context, id int) (ProducerResponse, error) { + if id <= 0 { + return ProducerResponse{}, fmt.Errorf("invalid producer id") + } + + cacheKey := fmt.Sprintf("producer:%d", id) + reqURL := fmt.Sprintf("%s/producers/%d", c.baseURL, id) + + var result ProducerResponse + if err := c.getWithCache(ctx, cacheKey, producerCacheTTL, reqURL, &result); err != nil { + return ProducerResponse{}, err + } + return result, nil +} + func (c *Client) GetProducers(ctx context.Context, query string, page int, limit int) (ProducerListResult, error) { if page < 1 { page = 1 diff --git a/integrations/jikan/studio.go b/integrations/jikan/studio.go deleted file mode 100644 index 2578621..0000000 --- a/integrations/jikan/studio.go +++ /dev/null @@ -1,44 +0,0 @@ -package jikan - -import ( - "context" - "fmt" -) - -type ProducerResponse struct { - Data struct { - MalID int `json:"mal_id"` - Titles []struct { - Type string `json:"type"` - Title string `json:"title"` - } `json:"titles"` - Images struct { - Jpg struct { - ImageURL string `json:"image_url"` - } `json:"jpg"` - } `json:"images"` - Favorites int `json:"favorites"` - Established string `json:"established"` - About string `json:"about"` - Count int `json:"count"` - External []struct { - Name string `json:"name"` - URL string `json:"url"` - } `json:"external"` - } `json:"data"` -} - -func (c *Client) GetProducerByID(ctx context.Context, id int) (ProducerResponse, error) { - if id <= 0 { - return ProducerResponse{}, fmt.Errorf("invalid producer id") - } - - cacheKey := fmt.Sprintf("producer:%d", id) - reqURL := fmt.Sprintf("%s/producers/%d", c.baseURL, id) - - var result ProducerResponse - if err := c.getWithCache(ctx, cacheKey, producerCacheTTL, reqURL, &result); err != nil { - return ProducerResponse{}, err - } - return result, nil -} diff --git a/integrations/jikan/types.go b/integrations/jikan/types.go index de4e162..4e8ae4f 100644 --- a/integrations/jikan/types.go +++ b/integrations/jikan/types.go @@ -22,6 +22,29 @@ type StudioAnimeResult struct { StudioName string } +type ProducerResponse struct { + Data struct { + MalID int `json:"mal_id"` + Titles []struct { + Type string `json:"type"` + Title string `json:"title"` + } `json:"titles"` + Images struct { + Jpg struct { + ImageURL string `json:"image_url"` + } `json:"jpg"` + } `json:"images"` + Favorites int `json:"favorites"` + Established string `json:"established"` + About string `json:"about"` + Count int `json:"count"` + External []struct { + Name string `json:"name"` + URL string `json:"url"` + } `json:"external"` + } `json:"data"` +} + type NamedEntity struct { MalID int `json:"mal_id"` Name string `json:"name"`