KatsuteDev/Mal4J

Missing alternative titles

Katsute opened this issue · 1 comments

Feature

The alternative items class is incomplete, currently only include en and ja.

Two sections might1 need to be updated:

public abstract class AlternativeTitles {
/**
* Returns the synonyms for the title.
*
* @return synonyms
*
* @since 1.0.0
*/
public abstract String[] getSynonyms();
/**
* Returns the English title.
*
* @return English title
*
* @since 1.0.0
*/
public abstract String getEnglish();
/**
* Returns the Japanese title.
*
* @return Japanese title
*
* @since 1.0.0
*/
public abstract String getJapanese();
}

static AlternativeTitles asAlternativeTitles(final MyAnimeList mal, final Json.JsonObject schema){
return new AlternativeTitles() {
private final String[] synonyms = requireNonNull(() -> schema.getStringArray("synonyms"));
private final String english = requireNonNull(() -> schema.getString("en"));
private final String japanese = requireNonNull(() -> schema.getString("ja"));
// API methods
@Override
public final String[] getSynonyms() {
return synonyms != null ? Arrays.copyOf(synonyms, synonyms.length) : null;
}
@Override
public final String getEnglish() {
return english;
}
@Override
public final String getJapanese() {
return japanese;
}
//
@Override
public final String toString(){
return "AlternativeTitles{" +
"synonyms=" + Arrays.toString(synonyms) +
", english='" + english + '\'' +
", japanese='" + japanese + '\'' +
'}';
}
};
}

Reason

Some items include more than just en and ja: https://myanimelist.net/anime/7817/B-gata_H-kei

Footnotes

  1. Languages other than en and ja are not documented, see https://myanimelist.net/apiconfig/references/api/v2#operation/anime_anime_id_get

External issue, alternative_titles doesn't return anything other than en, ja.