Fix display of streaming links in cover and list views
This commit is contained in:
parent
1818bf105d
commit
b8f75e14ec
@ -54,7 +54,7 @@
|
||||
<?php foreach($item['anime']['streaming_links'] as $link): ?>
|
||||
<div class="cover_streaming_link">
|
||||
<?php if($link['meta']['link']): ?>
|
||||
<a href="<?= $link['link']?>">
|
||||
<a href="<?= $link['link']?>" title="Stream '<?= $item['anime']['title'] ?>' on <?= $link['meta']['name'] ?>">
|
||||
<?= $link['meta']['logo'] ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
|
@ -162,6 +162,39 @@ class Kitsu {
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorganize streaming links for the current list item
|
||||
*
|
||||
* @param array $included
|
||||
* @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)
|
||||
{
|
||||
foreach ($anime['relationships']['streamingLinks'] as $streamingLink)
|
||||
{
|
||||
$host = parse_url($streamingLink['url'], \PHP_URL_HOST);
|
||||
|
||||
$links[] = [
|
||||
'meta' => static::getServiceMetaData($host),
|
||||
'link' => $streamingLink['url'],
|
||||
'subs' => $streamingLink['subs'],
|
||||
'dubs' => $streamingLink['dubs']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out duplicate and very similar names from
|
||||
*
|
||||
|
@ -175,7 +175,7 @@ class KitsuModel {
|
||||
'include' => 'media,media.genres,media.mappings,anime.streamingLinks',
|
||||
'page' => [
|
||||
'offset' => 0,
|
||||
'limit' => 500
|
||||
'limit' => 600
|
||||
]
|
||||
]
|
||||
];
|
||||
|
@ -61,6 +61,8 @@ class AnimeListTransformer extends AbstractTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
$streamingLinks = Kitsu::parseListItemStreamingLinks($included, $animeId);
|
||||
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'mal_id' => $MALid,
|
||||
@ -78,12 +80,13 @@ class AnimeListTransformer extends AbstractTransformer {
|
||||
],
|
||||
'anime' => [
|
||||
'age_rating' => $anime['ageRating'],
|
||||
'title' => $anime['canonicalTitle'],
|
||||
'titles' => Kitsu::filterTitles($anime),
|
||||
'slug' => $anime['slug'],
|
||||
'type' => $this->string($anime['showType'])->upperCaseFirst()->__toString(),
|
||||
'image' => $anime['posterImage']['small'],
|
||||
'genres' => $genres,
|
||||
'streaming_links' => Kitsu::parseStreamingLinks($included),
|
||||
'streaming_links' => $streamingLinks,
|
||||
],
|
||||
'watching_status' => $item['attributes']['status'],
|
||||
'notes' => $item['attributes']['notes'],
|
||||
|
@ -34,7 +34,7 @@ class API extends Model {
|
||||
|
||||
/**
|
||||
* Cache manager
|
||||
* @var \Aviat\Ion\Cache\CacheInterface
|
||||
* @var \Psr\Cache\CacheItemPoolInterface
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
@ -56,7 +56,7 @@ class API extends Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the manga entries by their title
|
||||
* Sort the list entries by their title
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @param array $array
|
||||
@ -75,4 +75,3 @@ class API extends Model {
|
||||
array_multisort($sort, SORT_ASC, $array);
|
||||
}
|
||||
}
|
||||
// End of BaseApiModel.php
|
||||
|
Loading…
Reference in New Issue
Block a user