Giter VIP home page Giter VIP logo

mal4j's Introduction

Mal4J - MyAnimeList for Java

Java wrapper for the official MyAnimeList API


Mal4J is a Java wrapper for the MyAnimeList API. This library is compatible with Java 8+, Java 9+ modules, and Android.

This library supports read and write operations, including list updates.

Installation

Mal4J requires at least Java 8. No additional dependencies/libraries are required.

Compiled binaries can be installed from:

See setup for steps to authenticate and actually use this library.

Features

Search Queries

Find Anime and Manga by search, ranking, season, and suggestions.

MyAnimeList mal = MyAnimeList.withClientID("");
List<Anime> search =
    mal.getAnime()
        .withQuery("さくら荘のペットな彼女")
        .withLimit(1)
        .withOffset(1)
        .includeNSFW(false)
        .search();

Anime and Manga Lists

Read and edit your Anime and Manga listings.

MyAnimeList mal = MyAnimeList.withToken("");
MangaListStatus status =
    mal.updateMangaListing(28107)
        .status(MangaStatus.Reading)
        .volumesRead(7)
        .chaptersRead(2)
        .rereading(false)
        .priority(Priority.High)
        .timesReread(0)
        .rereadValue(RereadValue.VeryHigh)
        .tags("tags", "more tags")
        .comments("comments")
        .update();

Everything Else

All information provided in the MyAnimeList API including Anime, Manga, forums, genres, pictures, statistics, and characters, are accessible in this library.

MyAnimeList mal = MyAnimeList.withClientID("");
Anime anime = mal.getAnime(13759);

String ja = anime.getAlternativeTitles().getJapanese();
Genre[] genres = anime.getGenres();
RelatedAnime[] relatedAnime = anime.getRelatedAnime();
AnimeRecommendation[] recs = anime.getRecommendations();
OpeningTheme[] op = anime.getOpeningThemes();
Video[] PV = anime.getVideos();
List<Character> characters = anime.getCharacters().search();

Character character = mal.getCharacter(61371);
Person person = mal.getPerson(10765);

Contributing

Before you start

For Anime/Manga list tests Sakura-sou no Pet na Kanojo (Anime#13759 and Manga#28107) will be used.

The test cases will create a backup of your list in the anime-list.txt and manga-list.txt files. Make sure you fix your ratings and any other information that might be overwritten by this test.

Ignore test failures for these known issues: ⚠️ External Issues.

Running Tests Locally

For local tests you can use Java 8+, however only methods in the Java 8 API may be used. The src/main/java9 and src/main/java11 folders should not be marked as a source root.

Run tests locally by adding a text file named client.txt that contains the client ID in the src/test/java/resources directory.

Please note that the client ID being used for tests must not have a client secret and must have an app redirect url of http://localhost:5050.

Running Tests using GitHub Actions

Tests can be run using GitHub Actions by running the MyAnimeList CI workflow manually in the actions tab of your fork. Note that this requires two secrets, a MAL_CLIENT which contains the client ID, and a MAL_TOKEN which contains the OAuth token (ex: Bearer <oauth token>).

 

This library is released under the GNU General Public License (GPL) v2.0.

mal4j's People

Contributors

dependabot[bot] avatar imgbot[bot] avatar katsute avatar kdevbot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mal4j's Issues

Separate test classes

Move object tests into their own classes and instead use a static class to retrieve MAL obj. Only create if not already set.

For each test create static object then run single method tests. Keep only a single object per class.

Make line split regex ignore escaped quotes

The current line split regex works except in cases where an escaped quote exists. This needs to be fixed so that it works with escaped quotes.

(?<=[{\[,]|(?=[}\]])) ?(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)(?!$)

Example where regex works: {"obj":{},"arr":[],"escaped":"str"}
Example where regex fails: {"obj":{},"arr":[],"escape\"d":"str"}

The fixed regex should split where there is a {}[], except within quotes.

Do not make a pull, instead post a new regex in the comments

Out of bounds limit/offset parameter causes 400 error

The client side code works correctly and limits these parameters to their minimum and maximum values. This is a server side issue where the API returns a code 400 when trying to load with 0 offset or limiting over the max possible results (insufficient search listings).

Allow soft failure for delete Anime/Manga listing

An error code 404 indicates that the listing has already been deleted. For the delete method there really is no reason to throw an exception if it has already been deleted since we wanted to delete the listing anyways.

Use try catch only on case 404.

Remove redundant date methods

For endpoints that return only yyyymmdd format return Date only, it doesn't make sense to return a long for these fields.

Notable issues:

  • Anime/manga start/end date
  • Anime/manga list start/finish date
  • User birthday

Return Date alongside epoch

MangaListStatus isn't working

The update methods work correctly and return a correct list status, as well as an implicit call to #getManga. This method however fails when trying to search UserMangaList for both self and users, this seems to be a server side issue as this code was working last week.

It's also important to note that AnimeListStatus is still functioning properly.

Nullable fields should not return primitive types

With many nullable fields it can be difficult to determine whether the default value is the actual value (ex: false by default).

All methods should be changed to return object type rather than primitive types.

Fix typecasting for primitives

Maps store primitives as their object type making it impossible to cast them. Make json return a json object instead of using maps and lists. This would also make it easier to access the object in the schema as we could skip casting with methods.

Replace site with Redoc.

Changes:

  • Move FAQ to its own markdown file.
  • Move setup to its own markdown file.
  • Move features to README.
  • Replace javadoc site with Redoc (possible move to /docs path).

Inheritance optimizations

Both the Anime and Manga classes explicitly state the methods getAnime and getManga but these methods can be retrieved by instead implementing the interface AnimeRetrievable and MangaRetrievable.

Simplify pom

  • Have separate profiles (package & deploy)
  • Move settings to pom

Consecutive Anime list updates causes code 500 error.

For some reason updating an Anime listing that already exists returns a 500 error. It is unclear what causes this and why it only occurs for Anime list updates.

Potential fix may require first getting that list, deleting it, then updating it with values from the initial list with new values.

This issue may or may not be fixed at a later date. If you experience this issue simply delete and update.

Redoc defect issues.

This issue only affects branch redoc@0450bbc5.

There are several defects in redoc that is causing valid schema to produce invalid documentation.

  • /anime, /anime/seasonal/{year}/{season}, /anime/suggestions
    • List status not being returned
    • Studios not being returned
  • /anime/{anime_id}
    • Studios not being returned
    • RelatedAnime not being returned
    • Recommendations not being returned
  • /anime/ranking
    • Not returning Anime
  • /users/{user_name}/animelist
    • Comments type is any
  • /manga
    • List status not being returned
    • Authors not being returned
  • /manga/{anime_id}
    • Authors not being returned
    • RelatedManga not being returned
    • Recommendations not being returned
    • Serialization not being returned
  • /manga/ranking
    • Not returning Manga
  • /users/{user_name}/mangalist
    • Edit not being returned
  • /forum/boards
    • Subboards not being returned
    • Post author not being returned
  • /forum/topic/{topic_id}
    • Internal posts not being returned
    • Poll options not being returned

Change name to MAL4J

Current name is too vague and may cause issues in the future in the event of additional Java wrappers.

  • Change repo name to Mal4J
  • Change logo
  • Change subdomain to mal4j but also keep myanimelist and mal as redirects
  • Change maven repo to mal4j

Better authentication page

Prerequisites

If all checks are not passed then the request will be closed.

  • I have checked that no other similar feature request already exists.
  • I have checked that this feature does not already exist.
  • The feature request makes sense for the project.

Proposal

Describe the feature that should be added.
Designs for the finished authentication screen.

Reasoning

Explain why this feature should be added.
Its a bit empty at the moment. Please edit the html file with new designs ♥

Transfer repo ownership

Repository will be maintained primarily by @Katsute and not @Ktt-Development

Note that this repository will still retain owner ship over:

  • myanimelist.kttdevelopment.com domain
  • com.kttdevelopment.myanimelist repository

Site issues

  • Code is wrapping lines instead of overflowing to scroll.
  • Mobile view may be cluttered, add additional padding on main divs.

Make requests return default fields instead of all fields.

The API by default does not return all fields and it is expected that in the future they will have rate limits.

This should be changed so there is a static variable ALL_ANIME_FIELDS and ALL_MANGA_FIELDS.

Currently the setup of null to all has lead to bugs where empty or null fields would lead to all of them being sent.

Serialization role is null

The API does not return a role even when explicitly listed on the field parameter.

This issue still exists as of 7/17/2022

Add AuthenticatedUser

Have the @me user return an AuthenticatedUser instead of user and have the class have additional methods to retrieve user anime and manga listings.

Fix clashing names

ForumTopicDetail should be ForumTopic and ForumTopic should be ForumTopicDetail.

Website for repository

This repository acts independently of the main organization (Ktt Development) and is not posted on that site. This repository should instead maintain its own site for overview and documentation.

Simplify withQuery redundancy

Add a new class that extends FieldSearchQuery with the withQuery method. For ForumSearchQuery just deprecate the field methods.

Minimize dependencies

Currently the API depends on Retrofit2 which itself depends on about a dozen libraries to operate. The long term goal is to try and get this library to operate with minimal or no dependencies.

Proposed Changes:

  • Remove retrofit and handle requests internally

  • Find a way to parse the JSON without using a library (or a standalone library)

  • Make project modular (previously blocked by retrofit defect)

  • Replicate retrofit behavior with annotations

  • Replicate json behavior by reading line by line with regex, possibly trim spaces

Add FAQ to site.

Some methods in the library may be unclear to some developers, a FAQ should be added to address these questions.

A link to this page should also be added in the issue templates, list, and readme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.