Code Monkey home page Code Monkey logo

myanimelist-api's Introduction

myanimelist-api

This is an api developed to get information from pages of anime, manga, character and people on MyAnimelist. It works by scanning the html code of the page requested, so this library crashes when it changes.

Required

  • CURL
  • PHP 7

How to Install?

$ composer require magnum357i/myanimelist-api

How to Use?

Anime Page

Example
// Create object
$mal = new \myanimelist\Page\Anime( 20 );

// Send request
$mal->sendRequestOrGetData();

// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {

   echo $mal->title()->original;
   echo $mal->title()->english;
   echo $mal->title()->japanese;
   echo $mal->title()->sysnonmys;
   echo $mal->poster;
   echo $mal->description;
   echo $mal->category;
   echo $mal->status;
   echo $mal->broadcast()->day;
   echo $mal->broadcast()->hour;
   echo $mal->broadcast()->minute;
   echo $mal->statistic()->rank;
   echo $mal->statistic()->member;
   echo $mal->statistic()->memberraw;
   echo $mal->statistic()->popularity;
   echo $mal->statistic()->favorite;
   echo $mal->statistic()->favoriteraw;
   echo $mal->rating;
   echo $mal->score()->vote;
   echo $mal->score()->voteraw;
   echo $mal->score()->point;
   echo $mal->genres;
   echo $mal->source;
   echo $mal->aired()->first()->month;
   echo $mal->aired()->first()->day;
   echo $mal->aired()->first()->year;
   echo $mal->aired()->last()->month;
   echo $mal->aired()->last()->day;
   echo $mal->aired()->last()->year;
   echo $mal->episode;
   echo $mal->studios;
   echo $mal->duration()->minute;
   echo $mal->duration()->hour;
   echo $mal->producers;
   echo $mal->licensors;
   echo $mal->premiered()->season;
   echo $mal->premiered()->year;
   echo $mal->year;
   echo $mal->voice;
   echo $mal->staff;
   echo $mal->related()->adaptation;
   echo $mal->related()->prequel;
   echo $mal->related()->sequel;
   echo $mal->related()->parentstory;
   echo $mal->related()->sidestory;
   echo $mal->related()->spinoff;
   echo $mal->related()->alternativeversion;
   echo $mal->related()->other;
   echo $mal->related()->sequel;
   echo $mal->link;
   echo $mal->trailer;
}
else {

   echo 'No data.';
}

Manga Page

Example
// Create object
$mal = new \myanimelist\Page\Manga( 2 );

// Send request
$mal->sendRequestOrGetData();

// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {

   echo $mal->title()->original;
   echo $mal->title()->english;
   echo $mal->title()->japanese;
   echo $mal->poster;
   echo $mal->description;
   echo $mal->type;
   echo $mal->score()->vote;
   echo $mal->score()->voteraw;
   echo $mal->score()->point;
   echo $mal->genres;
   echo $mal->statistic()->rank;
   echo $mal->statistic()->popularity;
   echo $mal->statistic()->member;
   echo $mal->statistic()->memberraw;
   echo $mal->statistic()->favorite;
   echo $mal->statistic()->favoriteraw;
   echo $mal->status;
   echo $mal->published()->first()->month;
   echo $mal->published()->first()->day;
   echo $mal->published()->first()->year;
   echo $mal->published()->last()->month;
   echo $mal->published()->last()->day;
   echo $mal->published()->last()->year;
   echo $mal->authors;
   echo $mal->volume;
   echo $mal->chapter;
   echo $mal->serialization;
   echo $mal->year;
   echo $mal->characters;
   echo $mal->related()->adaptation;
   echo $mal->related()->sequel;
   echo $mal->related()->prequel;
   echo $mal->related()->parentstory;
   echo $mal->related()->sidestory;
   echo $mal->related()->other;
   echo $mal->related()->spinoff;
   echo $mal->related()->alternativeversion;
   echo $mal->link;
}
else {

   echo 'No data.';
}

Character Page

Example
// Create object
$mal = new \myanimelist\Page\Character( 40 );

// Send request
$mal->sendRequestOrGetData();

// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {

   echo $mal->title()->self;
   echo $mal->title()->nickname;
   echo $mal->poster;
   echo $mal->description;
   echo $mal->statistic()->favorite;
   echo $mal->statistic()->favoriteraw;
   echo $mal->recentanime;
   echo $mal->recentmanga;
   echo $mal->voiceactors;
}
else {

   echo 'No data.';
}

People Page

Example
// Create object
$mal = new \myanimelist\Page\People( 80 );

// Send request
$mal->sendRequestOrGetData();

// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {

   echo $mal->name;
   echo $mal->poster;
   echo $mal->description;
   echo $mal->statistic()->favorite;
   echo $mal->statistic()->favoriteraw;
   echo $mal->recentvoice;
   echo $mal->recentwork;
   echo $mal->link;
}
else {

   echo 'No data.';
}

Anime Search

Example
// Create object
$mal = new \myanimelist\Search\Anime( 'bleach' );

// Send request
$mal->sendRequestOrGetData();

// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {

   echo $mal->results;
   echo $mal->link;
}
else {

   echo 'No data.';
}

Manga Search

Example
// Create object
$mal = new \myanimelist\Search\Manga( 'baka to test to shoukanjuu' );

// Send request
$mal->sendRequestOrGetData();

// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {

   echo $mal->results;
   echo $mal->link;
}
else {

   echo 'No data.';
}

Character Search

Example
// Create object
$mal = new \myanimelist\Search\Character( 'yugi' );

// Send request
$mal->sendRequestOrGetData();

// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {

   echo $mal->results;
   echo $mal->link;
}
else {

   echo 'No data.';
}

People Search

Example
// Create object
$mal = new \myanimelist\Search\People( 'yui' );

// Send request
$mal->sendRequestOrGetData();

// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {

   echo $mal->results;
   echo $mal->link;
}
else {

   echo 'No data.';
}

New Anime Widget

Example
// Create object
$mal = new \myanimelist\Widget\NewAnime;

// Send request
$mal->sendRequestOrGetData();

// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {

   echo $mal->tvnew;
   echo $mal->tvcontinuing;
   echo $mal->ona;
   echo $mal->ova;
   echo $mal->movie;
   echo $mal->special;
   echo $mal->link;
}
else {

   echo 'No data.';
}

Configuration

Reverse Names

If true, the name order is reversed firstname-lastname instead of lastname-firstname.

// Create object
$mal = new \myanimelist\Page\Manga( 1 );

// Reverse name
$mal->config()->convertName();

// Send request
$mal->sendRequestOrGetData();

// Test
echo $mal->authors;

// Output
// reverse name option is true: Naoki Urasawa
// reverse name option is false: Urasawa, Naoki

Enable Cache

If true, the cache system enabled.

// Create object
$mal = new \myanimelist\Page\Anime( 1 );

// Enable cache
$mal->config()->enableCache();
$mal->cache()->setExpiredTime( 5 ); // In days.
$mal->cache()->setPath( ROOT_PATH . '/upload' );

// Send request
$mal->sendRequestOrGetData();

// Test
echo $mal->title()->english;
echo $mal->poster;

// Note
// Backs up the values you use.
// So, based on the above values, this will be create a file named 1.json
// and inside of the file writes the english title of the anime.
// Also a poster named 1.jpg is saved.
// After all, it will return false even if you call another value until the cache expires.
// Please don't forget this.

cURL Settings

// Create object
$mal = new myanimelist\Page\People( 1 );

// A sample setting
$mal->config()->setCurlOption( 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0', 'USERAGENT' );

// Send request
$mal->sendRequestOrGetData();

myanimelist-api's People

Contributors

magnum357i avatar

Watchers

Md. Sumon Islam avatar  avatar

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.