HummingBirdAnimeClient/src/API/MAL.php

82 lines
2.4 KiB
PHP
Raw Normal View History

<?php declare(strict_types=1);
/**
2017-02-15 16:13:32 -05:00
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
2017-02-15 16:13:32 -05:00
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
2018-01-15 14:43:15 -05:00
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API;
2018-01-15 14:43:15 -05:00
use Aviat\AnimeClient\API\Enum\{
AnimeWatchingStatus\Kitsu as KAWS,
MangaReadingStatus\Kitsu as KMRS
};
use Aviat\AnimeClient\API\Enum\{
AnimeWatchingStatus\MAL as AnimeWatchingStatus,
MangaReadingStatus\MAL as MangaReadingStatus
2017-02-04 15:18:34 -05:00
};
/**
* Constants and mappings for the My Anime List API
*/
class MAL {
const AUTH_URL = 'https://myanimelist.net/api/account/verify_credentials.xml';
const BASE_URL = 'https://myanimelist.net/api/';
2017-02-04 15:18:34 -05:00
const KITSU_MAL_WATCHING_STATUS_MAP = [
KAWS::WATCHING => AnimeWatchingStatus::WATCHING,
KAWS::COMPLETED => AnimeWatchingStatus::COMPLETED,
KAWS::ON_HOLD => AnimeWatchingStatus::ON_HOLD,
KAWS::DROPPED => AnimeWatchingStatus::DROPPED,
KAWS::PLAN_TO_WATCH => AnimeWatchingStatus::PLAN_TO_WATCH
];
2018-01-15 14:43:15 -05:00
const MAL_KITSU_WATCHING_STATUS_MAP = [
1 => KAWS::WATCHING,
2 => KAWS::COMPLETED,
3 => KAWS::ON_HOLD,
4 => KAWS::DROPPED,
6 => KAWS::PLAN_TO_WATCH
2017-02-04 15:18:34 -05:00
];
public static function getIdToWatchingStatusMap()
{
return [
1 => AnimeWatchingStatus::WATCHING,
2 => AnimeWatchingStatus::COMPLETED,
3 => AnimeWatchingStatus::ON_HOLD,
4 => AnimeWatchingStatus::DROPPED,
2017-02-04 15:18:34 -05:00
6 => AnimeWatchingStatus::PLAN_TO_WATCH,
'watching' => AnimeWatchingStatus::WATCHING,
'completed' => AnimeWatchingStatus::COMPLETED,
'onhold' => AnimeWatchingStatus::ON_HOLD,
'dropped' => AnimeWatchingStatus::DROPPED,
'plantowatch' => AnimeWatchingStatus::PLAN_TO_WATCH
];
}
public static function getIdToReadingStatusMap()
{
return [
1 => MangaReadingStatus::READING,
2 => MangaReadingStatus::COMPLETED,
3 => MangaReadingStatus::ON_HOLD,
4 => MangaReadingStatus::DROPPED,
2017-02-04 15:18:34 -05:00
6 => MangaReadingStatus::PLAN_TO_READ,
'reading' => MangaReadingStatus::READING,
'completed' => MangaReadingStatus::COMPLETED,
'onhold' => MangaReadingStatus::ON_HOLD,
'dropped' => MangaReadingStatus::DROPPED,
2017-02-22 14:46:35 -05:00
'plantoread' => MangaReadingStatus::PLAN_TO_READ
];
}
}