Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
Showing only changes of commit 7584d0a935 - Show all commits

View File

@ -94,33 +94,59 @@ final class Kitsu {
public static function mappingsToUrls(array $mappings, string $kitsuLink = ''): array public static function mappingsToUrls(array $mappings, string $kitsuLink = ''): array
{ {
$output = []; $output = [];
$urlMap = [
'ANIDB' => [
'key' => 'AniDB',
'url' => 'https://anidb.net/anime/{}',
],
'ANILIST_ANIME' => [
'key' => 'Anilist',
'url' => 'https://anilist.co/anime/{}/',
],
'ANILIST_MANGA' => [
'key' => 'Anilist',
'url' => 'https://anilist.co/anime/{}/',
],
'ANIMENEWSNETWORK' => [
'key' => 'AnimeNewsNetwork',
'url' => 'https://www.animenewsnetwork.com/encyclopedia/anime.php?id={}',
],
'MANGAUPDATES' => [
'key' => 'MangaUpdates',
'url' => 'https://www.mangaupdates.com/series.html?id={}',
],
'MYANIMELIST_ANIME' => [
'key' => 'MyAnimeList',
'url' => 'https://myanimelist.net/anime/{}',
],
'MYANIMELIST_CHARACTERS' => [
'key' => 'MyAnimeList',
'url' => 'https://myanimelist.net/character/{}',
],
'MYANIMELIST_MANGA' => [
'key' => 'MyAnimeList',
'url' => 'https://myanimelist.net/manga/{}',
],
'MYANIMELIST_PEOPLE' => [
'key' => 'MyAnimeList',
'url' => 'https://myanimelist.net/people/{}',
],
];
foreach ($mappings as $mapping) foreach ($mappings as $mapping)
{ {
switch ($mapping['externalSite']) if ( ! array_key_exists($mapping['externalSite'], $urlMap))
{ {
case 'ANIDB': continue;
$output['AniDB'] = "https://anidb.net/anime/{$mapping['externalId']}";
break;
case 'ANILIST_ANIME':
$output['Anilist'] = "https://anilist.co/anime/{$mapping['externalId']}/";
break;
case 'ANILIST_MANGA':
$output['Anilist'] = "https://anilist.co/manga/{$mapping['externalId']}/";
break;
case 'MYANIMELIST_ANIME':
$output['MyAnimeList'] = "https://myanimelist.net/anime/{$mapping['externalId']}";
break;
case 'MYANIMELIST_MANGA':
$output['MyAnimeList'] = "https://myanimelist.net/manga/{$mapping['externalId']}";
break;
default:
// Do Nothing
} }
$uMap = $urlMap[$mapping['externalSite']];
$key = $uMap['key'];
$url = str_replace('{}', $mapping['externalId'], $uMap['url']);
$output[$key] = $url;
} }
if ($kitsuLink !== '') if ($kitsuLink !== '')
@ -365,7 +391,7 @@ final class Kitsu {
/** /**
* Get the name and logo for the streaming service of the current link * Get the name and logo for the streaming service of the current link
* *
* @param string $hostname * @param string|null $hostname
* @return array * @return array
*/ */
protected static function getServiceMetaData(string $hostname = NULL): array protected static function getServiceMetaData(string $hostname = NULL): array
@ -373,6 +399,11 @@ final class Kitsu {
$hostname = str_replace('www.', '', $hostname); $hostname = str_replace('www.', '', $hostname);
$serviceMap = [ $serviceMap = [
'animelab.com' => [
'name' => 'Animelab',
'link' => TRUE,
'image' => 'streaming-logos/animelab.svg',
],
'amazon.com' => [ 'amazon.com' => [
'name' => 'Amazon Prime', 'name' => 'Amazon Prime',
'link' => TRUE, 'link' => TRUE,