aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-02-24 17:36:55 +0530
committerBobby <[email protected]>2026-02-24 17:36:55 +0530
commit2df69fab61b580b6b329db214ee0025a9d84958d (patch)
treebf7d69e1cfc5f6dc3e387f99325e6842e7dc60c1 /utils
parentd3507ae5b9d88a250b444c0e996fa07f84f6e3c5 (diff)
downloadmetachan-2df69fab61b580b6b329db214ee0025a9d84958d.tar.xz
metachan-2df69fab61b580b6b329db214ee0025a9d84958d.zip
feat: Enhance person handling and synchronization logic
- Introduced new Person entity with detailed attributes - Updated repositories and controllers to support person data retrieval - Implemented PersonSync task for background enrichment of person data - Refactored existing character and voice actor logic to utilize Person entity - Added Jikan API integration for fetching person details
Diffstat (limited to 'utils')
-rw-r--r--utils/api/jikan/jikan.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/api/jikan/jikan.go b/utils/api/jikan/jikan.go
index 507130a..c5bb2c8 100644
--- a/utils/api/jikan/jikan.go
+++ b/utils/api/jikan/jikan.go
@@ -335,3 +335,22 @@ func GetCharacterByMALID(id int) (*types.JikanCharacterFullResponse, error) {
}
return &response, nil
}
+
+func GetPersonByMALID(id int) (*types.JikanPersonFullResponse, error) {
+ url := fmt.Sprintf("%s/people/%d/full", jikanAPIBaseURL, id)
+ ctx, cancel := context.WithTimeout(context.Background(), contextTimeout)
+ defer cancel()
+
+ bytes, err := clientInstance.makeRequest(ctx, url)
+ if err != nil {
+ logger.Errorf("JikanClient", "GetPersonByMALID failed for ID %d: %v", id, err)
+ return nil, errors.New("failed to fetch person data from Jikan API")
+ }
+
+ var response types.JikanPersonFullResponse
+ if err := json.Unmarshal(bytes, &response); err != nil {
+ logger.Errorf("JikanClient", "Failed to unmarshal person response for ID %d: %v", id, err)
+ return nil, errors.New("failed to parse person data from Jikan API")
+ }
+ return &response, nil
+}