API client for Kitsu.io, with optional Anime collection, and optional Anilist syncing.
anime
manga
kitsu
anilist
single-user

MAL.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php declare(strict_types=1);
  2. /**
  3. * Hummingbird Anime List Client
  4. *
  5. * An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
  6. *
  7. * PHP version 7
  8. *
  9. * @package HummingbirdAnimeClient
  10. * @author Timothy J. Warren <tim@timshomepage.net>
  11. * @copyright 2015 - 2018 Timothy J. Warren
  12. * @license http://www.opensource.org/licenses/mit-license.html MIT License
  13. * @version 4.0
  14. * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
  15. */
  16. namespace Aviat\AnimeClient\API;
  17. use Aviat\AnimeClient\API\Enum\{
  18. AnimeWatchingStatus\Kitsu as KAWS,
  19. MangaReadingStatus\Kitsu as KMRS
  20. };
  21. use Aviat\AnimeClient\API\Enum\{
  22. AnimeWatchingStatus\MAL as AnimeWatchingStatus,
  23. MangaReadingStatus\MAL as MangaReadingStatus
  24. };
  25. /**
  26. * Constants and mappings for the My Anime List API
  27. */
  28. final class MAL {
  29. const AUTH_URL = 'https://myanimelist.net/api/account/verify_credentials.xml';
  30. const BASE_URL = 'https://myanimelist.net/api/';
  31. const KITSU_MAL_WATCHING_STATUS_MAP = [
  32. KAWS::WATCHING => AnimeWatchingStatus::WATCHING,
  33. KAWS::COMPLETED => AnimeWatchingStatus::COMPLETED,
  34. KAWS::ON_HOLD => AnimeWatchingStatus::ON_HOLD,
  35. KAWS::DROPPED => AnimeWatchingStatus::DROPPED,
  36. KAWS::PLAN_TO_WATCH => AnimeWatchingStatus::PLAN_TO_WATCH
  37. ];
  38. const MAL_KITSU_WATCHING_STATUS_MAP = [
  39. 1 => KAWS::WATCHING,
  40. 2 => KAWS::COMPLETED,
  41. 3 => KAWS::ON_HOLD,
  42. 4 => KAWS::DROPPED,
  43. 6 => KAWS::PLAN_TO_WATCH
  44. ];
  45. public static function getIdToWatchingStatusMap()
  46. {
  47. return [
  48. 1 => AnimeWatchingStatus::WATCHING,
  49. 2 => AnimeWatchingStatus::COMPLETED,
  50. 3 => AnimeWatchingStatus::ON_HOLD,
  51. 4 => AnimeWatchingStatus::DROPPED,
  52. 6 => AnimeWatchingStatus::PLAN_TO_WATCH,
  53. 'watching' => AnimeWatchingStatus::WATCHING,
  54. 'completed' => AnimeWatchingStatus::COMPLETED,
  55. 'onhold' => AnimeWatchingStatus::ON_HOLD,
  56. 'dropped' => AnimeWatchingStatus::DROPPED,
  57. 'plantowatch' => AnimeWatchingStatus::PLAN_TO_WATCH
  58. ];
  59. }
  60. public static function getIdToReadingStatusMap()
  61. {
  62. return [
  63. 1 => MangaReadingStatus::READING,
  64. 2 => MangaReadingStatus::COMPLETED,
  65. 3 => MangaReadingStatus::ON_HOLD,
  66. 4 => MangaReadingStatus::DROPPED,
  67. 6 => MangaReadingStatus::PLAN_TO_READ,
  68. 'reading' => MangaReadingStatus::READING,
  69. 'completed' => MangaReadingStatus::COMPLETED,
  70. 'onhold' => MangaReadingStatus::ON_HOLD,
  71. 'dropped' => MangaReadingStatus::DROPPED,
  72. 'plantoread' => MangaReadingStatus::PLAN_TO_READ
  73. ];
  74. }
  75. }