From 627c2c239e0a44b6363a9f02235a73f5e2c81d2e Mon Sep 17 00:00:00 2001 From: Bobby <30593201+luciferreeves@users.noreply.github.com> Date: Thu, 26 Feb 2026 14:28:21 +0530 Subject: Add MAL client and anime parsing functionality - Implemented a new CloudflareClient to handle requests with randomized browser profiles. - Created structures and functions for parsing anime data from MyAnimeList (MAL), including anime details, episodes, and theme songs. - Added enums for anime types, statuses, sources, and ratings. - Developed utility functions for making HTTP requests with rate limiting and error handling. - Introduced image handling for anime covers and thumbnails. - Established a comprehensive data model for anime, including fields for statistics, trailers, and external links. --- controllers/anime.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'controllers') diff --git a/controllers/anime.go b/controllers/anime.go index 2418c67..be740ce 100644 --- a/controllers/anime.go +++ b/controllers/anime.go @@ -2,26 +2,24 @@ package controllers import ( "errors" - "metachan/enums" - "metachan/repositories" + "metachan/utils/mal" "metachan/utils/meta" + "strconv" "github.com/gofiber/fiber/v2" ) func GetAnime(c *fiber.Ctx) error { - id := meta.Request(c).MustHave().Param("id") - provider := meta.Request(c).Default("mal").Query("provider") + idString := meta.Request(c).MustHave().Param("id") - switch provider { - case "mal", "anilist": - default: - return BadRequest(c, errors.New("invalid provider")) + malID, parseErr := strconv.Atoi(idString) + if parseErr != nil { + return BadRequest(c, errors.New("invalid MAL ID")) } - anime, err := repositories.GetAnime(enums.MappingType(provider), id) - if err != nil { - return NotFound(c, err) + anime, fetchErr := mal.GetAnimeByMALID(malID) + if fetchErr != nil { + return NotFound(c, fetchErr) } return c.JSON(anime) -- cgit v1.2.3