CoolFace
Apppublic

id-mapping-api/malid

sourceHugging Faceupdated 4mo agoView on Hugging Face
1likes
App README

๐Ÿง  ID Mapping API

![Hugging Face Space](https://huggingface.co/spaces/id-mapping-api/malid) ![GitHub License](LICENSE)

An advanced ID mapping engine designed to bridge the gap between western metadata (IMDb/Cinemeta) and Japanese anime tracking (MyAnimeList). This API ensures perfect synchronization even for complex, split-season anime by relying on absolute release dates.

๐Ÿ“– Live Documentation

Interactive API documentation (Swagger UI) is available live. You can explore endpoints, view response schemas, and test queries directly from your browser:

๐Ÿ‘‰ [View Interactive API Docs](https://id-mapping-api-malid.hf.space/)

๐Ÿš€ Key Features

  • โ€”๐Ÿ“… Date-Based Fingerprinting: Matches episodes using absolute air dates rather than fragile season/episode numbers. This allows seamless mapping of "Part 2", "The Final Season", and split-cour releases.
  • โ€”๐Ÿ” Multi-Source Discovery: Automatically builds candidate lists by querying external services and performing intelligent title searches.
  • โ€”๐Ÿ•ต๏ธโ€โ™‚๏ธ Total Stealth Mode: Routes MyAnimeList (Jikan) traffic through a Cloudflare Shield to bypass IP blocks and rate limits.
  • โ€”โšก Enterprise-Grade Caching:
  • โ€”Level 1 (Instant): Full mapping results are cached in Supabase for sub-second repeat lookups.
  • โ€”Level 2 (Discovery): Whole anime episode lists are cached to allow instant cross-episode resolution within the same series.
  • โ€”๐ŸŒ Timezone-Proof: Implements a 2-day date tolerance with UTC-only string comparisons to handle global release discrepancies.

โšก Powered By (Acknowledgments)

This project relies on fantastic community APIs to fetch metadata and map candidates. Huge thanks to:

  • โ€”[ARM (Anime Release Metadata)](https://github.com/haglund/arm): Used as the primary discovery network (arm.haglund.dev) to fetch a broad list of candidate MyAnimeList IDs from IMDb, TMDB, and TVDB identifiers.
  • โ€”[AniZip](https://github.com/ebakan/anizip): Used as a highly reliable fallback (api.ani.zip/mappings) for episode air dates when primary sources are missing data, ensuring flawless mapping for the latest seasons.
  • โ€”[Jikan](https://jikan.moe/): The Unofficial MyAnimeList API used for title searching and episode list retrieval.

๐Ÿ›  API Usage

Resolve Episode Mapping

Resolves a Cinemeta/IMDb episode ID to its MyAnimeList equivalent.

Endpoint: GET /api/resolve

Query Parameters:

  • โ€”id: The IMDb series ID (e.g., tt2560140)
  • โ€”s: The season number (as seen in Cinemeta)
  • โ€”e: The episode number (as seen in Cinemeta)

Example Request:

bash
curl "https://id-mapping-api-malid.hf.space/api/resolve?id=tt2560140&s=4&e=29"

Example Response:

json
{
    "id": "tt2560140:s4:e29",
    "imdb_id": "tt2560140",
    "season": 4,
    "episode": 29,
    "mal_id": 51535,
    "mal_episode": 1,
    "anime_title": "Attack on Titan",
    "air_date": "2023-03-03"
}

๐Ÿ— Setup & Installation

Environment Variables

You must configure the following environment variables:

VariableDescription
SUPABASE_URLYour Supabase Project URL
SUPABASE_KEYYour Supabase Service Role Key
JIKAN_PROXY_URLThe URL of your Cloudflare Shield (Jikan Proxy)
PORT(Optional) Port for the Express server (Defaults to 7860)

Local Development

bash
# Install dependencies
npm install

# Start the server
node server.js

๐Ÿงฉ How it Works: The "Truth" Algorithm

Traditional mapping fails when one database numbers an episode as S4 E29 and another calls it Part 3 Ep 1. This API solves the problem by:

  1. 1.Extracting the "Fingerprint": Finding the exact release date of the requested episode from Cinemeta.
  2. 2.Building the Net: Collecting candidate MyAnimeList IDs associated with the show via ARM and Jikan Search.
  3. 3.The Matching Loop: Scanning the episode list of every candidate to find the episode that "was born" on that same day (falling back to AniZip if needed).
  4. 4.DayIndex Resolution: If two episodes dropped on the same day (Specials), it uses their relative position to break the tie.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an Issue.


Maintained by [paregi12](https://github.com/paregi12)