Remove some more dead code
This commit is contained in:
parent
e0ad68b9d2
commit
ad0dcb5750
@ -22,9 +22,9 @@ use Aviat\Ion\Enum;
|
|||||||
* Possible values for watching status for the current anime
|
* Possible values for watching status for the current anime
|
||||||
*/
|
*/
|
||||||
final class Kitsu extends Enum {
|
final class Kitsu extends Enum {
|
||||||
public const WATCHING = 'current';
|
public const WATCHING = 'CURRENT';
|
||||||
public const PLAN_TO_WATCH = 'planned';
|
public const PLAN_TO_WATCH = 'PLANNED';
|
||||||
public const ON_HOLD = 'on_hold';
|
public const ON_HOLD = 'ON_HOLD';
|
||||||
public const DROPPED = 'dropped';
|
public const DROPPED = 'DROPPED';
|
||||||
public const COMPLETED = 'completed';
|
public const COMPLETED = 'COMPLETED';
|
||||||
}
|
}
|
@ -42,8 +42,8 @@ final class Kitsu {
|
|||||||
/**
|
/**
|
||||||
* Determine whether an anime is airing, finished airing, or has not yet aired
|
* Determine whether an anime is airing, finished airing, or has not yet aired
|
||||||
*
|
*
|
||||||
* @param string $startDate
|
* @param string|null $startDate
|
||||||
* @param string $endDate
|
* @param string|null $endDate
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getAiringStatus(string $startDate = NULL, string $endDate = NULL): string
|
public static function getAiringStatus(string $startDate = NULL, string $endDate = NULL): string
|
||||||
@ -158,50 +158,6 @@ final class Kitsu {
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reorganize streaming links
|
|
||||||
*
|
|
||||||
* @param array $included
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function oldParseStreamingLinks(array $included): array
|
|
||||||
{
|
|
||||||
if (
|
|
||||||
( ! array_key_exists('streamingLinks', $included)) ||
|
|
||||||
count($included['streamingLinks']) === 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$links = [];
|
|
||||||
|
|
||||||
foreach ($included['streamingLinks'] as $streamingLink)
|
|
||||||
{
|
|
||||||
$url = $streamingLink['url'];
|
|
||||||
|
|
||||||
// 'Fix' links that start with the hostname,
|
|
||||||
// rather than a protocol
|
|
||||||
if (strpos($url, '//') === FALSE)
|
|
||||||
{
|
|
||||||
$url = '//' . $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
$host = parse_url($url, \PHP_URL_HOST);
|
|
||||||
|
|
||||||
$links[] = [
|
|
||||||
'meta' => static::getServiceMetaData($host),
|
|
||||||
'link' => $streamingLink['url'],
|
|
||||||
'subs' => $streamingLink['subs'],
|
|
||||||
'dubs' => $streamingLink['dubs']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
usort($links, fn ($a, $b) => $a['meta']['name'] <=> $b['meta']['name']);
|
|
||||||
|
|
||||||
return $links;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reorganize streaming links
|
* Reorganize streaming links
|
||||||
*
|
*
|
||||||
@ -243,49 +199,6 @@ final class Kitsu {
|
|||||||
return $links;
|
return $links;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reorganize streaming links for the current list item
|
|
||||||
*
|
|
||||||
* @param array $included
|
|
||||||
* @param string $animeId
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function parseListItemStreamingLinks(array $included, string $animeId): array
|
|
||||||
{
|
|
||||||
// Anime lists have a different structure to search through
|
|
||||||
if (array_key_exists('anime', $included) && ! array_key_exists('streamingLinks', $included))
|
|
||||||
{
|
|
||||||
$links = [];
|
|
||||||
$anime = $included['anime'][$animeId];
|
|
||||||
|
|
||||||
if (count($anime['relationships']['streamingLinks']) > 0)
|
|
||||||
{
|
|
||||||
return static::oldParseStreamingLinks($anime['relationships']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $links;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the list of titles
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function oldGetTitles(array $data): array
|
|
||||||
{
|
|
||||||
$raw = array_unique([
|
|
||||||
$data['canonicalTitle'],
|
|
||||||
...array_values($data['titles']),
|
|
||||||
...array_values($data['abbreviatedTitles'] ?? []),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return array_diff($raw,[$data['canonicalTitle']]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of titles
|
* Get the list of titles
|
||||||
*
|
*
|
||||||
@ -297,37 +210,11 @@ final class Kitsu {
|
|||||||
$raw = array_unique([
|
$raw = array_unique([
|
||||||
$titles['canonical'],
|
$titles['canonical'],
|
||||||
...array_values($titles['localized']),
|
...array_values($titles['localized']),
|
||||||
// ...array_values($data['abbreviatedTitles'] ?? []),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return array_diff($raw,[$titles['canonical']]);
|
return array_diff($raw,[$titles['canonical']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter out duplicate and very similar names from
|
|
||||||
*
|
|
||||||
* @param array $data The 'attributes' section of the api data response
|
|
||||||
* @return array List of alternate titles
|
|
||||||
*/
|
|
||||||
public static function filterTitles(array $data): array
|
|
||||||
{
|
|
||||||
// The 'canonical' title is always returned
|
|
||||||
$valid = [$data['canonicalTitle']];
|
|
||||||
|
|
||||||
if (array_key_exists('titles', $data) && is_array($data['titles']))
|
|
||||||
{
|
|
||||||
foreach($data['titles'] as $alternateTitle)
|
|
||||||
{
|
|
||||||
if (self::titleIsUnique($alternateTitle, $valid))
|
|
||||||
{
|
|
||||||
$valid[] = $alternateTitle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter out duplicate and very similar titles from a GraphQL response
|
* Filter out duplicate and very similar titles from a GraphQL response
|
||||||
*
|
*
|
||||||
|
@ -42,7 +42,7 @@ class Anime extends API {
|
|||||||
* @param string $status
|
* @param string $status
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getList($status): array
|
public function getList(string $status): array
|
||||||
{
|
{
|
||||||
$data = $this->kitsuModel->getAnimeList($status);
|
$data = $this->kitsuModel->getAnimeList($status);
|
||||||
$this->sortByName($data, 'anime');
|
$this->sortByName($data, 'anime');
|
||||||
|
@ -38,7 +38,7 @@ class Manga extends API {
|
|||||||
* @param string $status
|
* @param string $status
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getList($status): array
|
public function getList(string $status): array
|
||||||
{
|
{
|
||||||
if ($status === 'All')
|
if ($status === 'All')
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ class Manga extends API {
|
|||||||
* @param string $manga_id
|
* @param string $manga_id
|
||||||
* @return MangaPage
|
* @return MangaPage
|
||||||
*/
|
*/
|
||||||
public function getManga($manga_id): MangaPage
|
public function getManga(string $manga_id): MangaPage
|
||||||
{
|
{
|
||||||
return $this->kitsuModel->getManga($manga_id);
|
return $this->kitsuModel->getManga($manga_id);
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ class Manga extends API {
|
|||||||
Title::COMPLETED => [],
|
Title::COMPLETED => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($data as &$entry) {
|
foreach ($data as $entry) {
|
||||||
$statusMap = MangaReadingStatus::KITSU_TO_TITLE;
|
$statusMap = MangaReadingStatus::KITSU_TO_TITLE;
|
||||||
$key = $statusMap[$entry['reading_status']];
|
$key = $statusMap[$entry['reading_status']];
|
||||||
$output[$key][] = $entry;
|
$output[$key][] = $entry;
|
||||||
|
Loading…
Reference in New Issue
Block a user