jikan-me / jikan

Unofficial MyAnimeList PHP+REST API which provides functions other than the official API
https://jikan.moe
MIT License
875 stars 93 forks source link

MAL Articles #491

Open irfan-dahir opened 1 year ago

irfan-dahir commented 1 year ago

Definition/Requirement

"Featured articles" are a bit different than News.

News is user submitted. Whereas "Features articles" are written by MAL's editorial team and are usually more in content. There will be some differences in the model objects.

👉 We'll dropping the word "Featured" and calling them simply as "Articles" in Jikan,.

Endpoints

Article Tags

Article Tags: https://myanimelist.net/featured/tag

$jikan->getArticleTags($request)

Categories are listed here in a similar manner to genre listing. So we can re-use the same parser here probably.

Recent Articles

Recent Articles: https://myanimelist.net/featured

$jikan->getArticles(new ArticlesRequest(int $page))

Pinned Articles

Pinned Articles: https://myanimelist.net/featured

MAL pins/sets to feature usually 4 articles at the top of the same recent articles page. I don't want to return this in getArticles as it implements Results and that work break it.

$jikan->getPinnedArticles(new ArticlesPinnedRequest())

Note: ArticlesPinnedRequest is the same as ArticlesRequest but without the pagination. Pinned articles are only on the first page.

Article By Tag

News By Tag: https://myanimelist.net/featured/tag/events

$jikan->getArticleByTag(new ArticleByTagRequest(string $tag, int $page))

Article Search

Article Search: https://myanimelist.net/featured/search?cat=featured&q=ghost+in+the+shell

$jikan->getArticleSearch(new ArticleSearchRequest(string $query, int $page))

Response Objects

Tags

Unlike News, a category here is a Tag itself as there's no higher hierarchy. We'll simply re-use the same approach as genre listing. where a list of MalUrl is returned.

Property Type Remarks
mal_id String Tag name (canonical)
url String -
name String Tag name

Could possibly re-use TagMeta from News as well.

ArticleByID

MAL URL: https://myanimelist.net/featured/2380/Anime_Expo__Lookback_Special https://myanimelist.net/featured/2378/Ni_no_Kuni__Cross_Worlds_Global_Version_Release_on_the_Horizon https://myanimelist.net/featured/1087/The_Philosophy_Behind_Ghost_in_the_Shell

Property Type Remarks
mal_id String News ID
url String -
title String News title
subtitle String News subtitle
date String ISO8601
content String Unparsed HTML response (like user about mes'?)
user UserMeta Author user object
views Integer Comment count
relations Objects of MalUrl[] Same as relation is done in getAnime & getManga
related_articles Objects of ArticleListItem âš Kinda same property name as relations.
tags TagMeta[] Array of tag metadata objects (mal_id, name, URL)

Results

The following will implement Results.

getResults() will return an array of ArticleListItem

ArticleListItem

Property Type Remarks
mal_id String News ID
url String -
images Images Object Need to look into available formats & sizes
title String News title
date String ISO8601
excerpt String -
user UserMeta Author user object
tags TagMeta[] Array of tag metadata objects (mal_id, name, URL)
is_spoiler Boolean Spoiler
is_advertorial Boolean Advertorial
views Integer View count
irfan-dahir commented 1 year ago

Notes on REST API implementation for this and #391 .

Thinking about it, I believe it would be best to implement it like Anime or Manga is. Indexed within the DB and made available within Scout.

Otherwise using MAL's search for News and articles would be very limited. Custom queries would allow us to further filter by

This should further allow us to provide an even better API call experience for Anime/Manga News rather than relying on parsing MAL.