Fix issues with sync-lists command, add more docblocks
This commit is contained in:
parent
b6dc104947
commit
34604d1b7b
@ -19,25 +19,19 @@ namespace Aviat\AnimeClient\API\Kitsu;
|
|||||||
use function Amp\{all, wait};
|
use function Amp\{all, wait};
|
||||||
|
|
||||||
use Amp\Artax\{Client, Request};
|
use Amp\Artax\{Client, Request};
|
||||||
use Aviat\AnimeClient\API\{
|
use Aviat\AnimeClient\API\{CacheTrait, JsonAPI, Kitsu as K};
|
||||||
CacheTrait,
|
|
||||||
JsonAPI,
|
|
||||||
Kitsu as K,
|
|
||||||
Mapping\AnimeWatchingStatus,
|
|
||||||
Mapping\MangaReadingStatus
|
|
||||||
};
|
|
||||||
use Aviat\AnimeClient\API\Enum\{
|
use Aviat\AnimeClient\API\Enum\{
|
||||||
AnimeWatchingStatus\Title,
|
AnimeWatchingStatus\Title,
|
||||||
MangaReadingStatus\Kitsu as KitsuReadingStatus
|
MangaReadingStatus\Kitsu as KitsuReadingStatus
|
||||||
};
|
};
|
||||||
|
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
|
||||||
use Aviat\AnimeClient\API\Kitsu\Transformer\{
|
use Aviat\AnimeClient\API\Kitsu\Transformer\{
|
||||||
AnimeTransformer,
|
AnimeTransformer,
|
||||||
AnimeListTransformer,
|
AnimeListTransformer,
|
||||||
MangaTransformer,
|
MangaTransformer,
|
||||||
MangaListTransformer
|
MangaListTransformer
|
||||||
};
|
};
|
||||||
use Aviat\Ion\Di\ContainerAware;
|
use Aviat\Ion\{Di\ContainerAware, Json};
|
||||||
use Aviat\Ion\Json;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kitsu API Model
|
* Kitsu API Model
|
||||||
@ -336,6 +330,11 @@ class Model {
|
|||||||
return $this->getRequest('library-entries', $options);
|
return $this->getRequest('library-entries', $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the anine entries, that are organized for output to html
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getFullOrganizedAnimeList(): array
|
public function getFullOrganizedAnimeList(): array
|
||||||
{
|
{
|
||||||
$cacheItem = $this->cache->getItem(self::FULL_TRANSFORMED_LIST_CACHE_KEY);
|
$cacheItem = $this->cache->getItem(self::FULL_TRANSFORMED_LIST_CACHE_KEY);
|
||||||
@ -405,6 +404,11 @@ class Model {
|
|||||||
return $cacheItem->get();
|
return $cacheItem->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all Manga lists
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getFullOrganizedMangaList(): array
|
public function getFullOrganizedMangaList(): array
|
||||||
{
|
{
|
||||||
$statuses = KitsuReadingStatus::getConstList();
|
$statuses = KitsuReadingStatus::getConstList();
|
||||||
@ -556,6 +560,11 @@ class Model {
|
|||||||
return $this->listItem->delete($id);
|
return $this->listItem->delete($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the kitsu username from config
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function getUsername(): string
|
private function getUsername(): string
|
||||||
{
|
{
|
||||||
return $this->getContainer()
|
return $this->getContainer()
|
||||||
@ -563,6 +572,13 @@ class Model {
|
|||||||
->get(['kitsu_username']);
|
->get(['kitsu_username']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the raw data for the anime id
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
private function getRawMediaDataById(string $type, string $id): array
|
private function getRawMediaDataById(string $type, string $id): array
|
||||||
{
|
{
|
||||||
$options = [
|
$options = [
|
||||||
@ -579,6 +595,13 @@ class Model {
|
|||||||
return $baseData;
|
return $baseData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get media item by slug
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $slug
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
private function getRawMediaData(string $type, string $slug): array
|
private function getRawMediaData(string $type, string $slug): array
|
||||||
{
|
{
|
||||||
$options = [
|
$options = [
|
||||||
|
@ -18,9 +18,8 @@ namespace Aviat\AnimeClient\Command;
|
|||||||
|
|
||||||
use function Amp\{all, wait};
|
use function Amp\{all, wait};
|
||||||
|
|
||||||
use Amp\Artax;
|
|
||||||
use Amp\Artax\Client;
|
use Amp\Artax\Client;
|
||||||
use Aviat\AnimeClient\API\{JsonAPI, Kitsu, MAL};
|
use Aviat\AnimeClient\API\{JsonAPI, Mapping\AnimeWatchingStatus};
|
||||||
use Aviat\AnimeClient\API\MAL\Transformer\AnimeListTransformer as ALT;
|
use Aviat\AnimeClient\API\MAL\Transformer\AnimeListTransformer as ALT;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ class SyncKitsuWithMal extends BaseCommand {
|
|||||||
$requests = [];
|
$requests = [];
|
||||||
|
|
||||||
// Set up requests
|
// Set up requests
|
||||||
for ($i = 0; $i < $count; $i++)
|
for ($i = 0; $i < $pages; $i++)
|
||||||
{
|
{
|
||||||
$offset = $i * $size;
|
$offset = $i * $size;
|
||||||
$requests[] = $this->kitsuModel->getPagedAnimeList($size, $offset);
|
$requests[] = $this->kitsuModel->getPagedAnimeList($size, $offset);
|
||||||
@ -131,7 +130,7 @@ class SyncKitsuWithMal extends BaseCommand {
|
|||||||
$output[$item['series_animedb_id']] = [
|
$output[$item['series_animedb_id']] = [
|
||||||
'id' => $item['series_animedb_id'],
|
'id' => $item['series_animedb_id'],
|
||||||
'data' => [
|
'data' => [
|
||||||
'status' => MAL::MAL_KITSU_WATCHING_STATUS_MAP[$item['my_status']],
|
'status' => AnimeWatchingStatus::MAL_TO_KITSU[$item['my_status']],
|
||||||
'progress' => $item['my_watched_episodes'],
|
'progress' => $item['my_watched_episodes'],
|
||||||
'reconsuming' => (bool) $item['my_rewatching'],
|
'reconsuming' => (bool) $item['my_rewatching'],
|
||||||
'reconsumeCount' => array_key_exists('times_rewatched', $item)
|
'reconsumeCount' => array_key_exists('times_rewatched', $item)
|
||||||
|
Loading…
Reference in New Issue
Block a user