4.1 Beta...ish #12

Merged
timw4mail merged 88 commits from develop into master 2018-11-05 13:15:59 -05:00
5 changed files with 15 additions and 13 deletions
Showing only changes of commit 4d29b43123 - Show all commits

View File

@ -97,19 +97,19 @@ final class ListItem implements ListItemInterface{
* @return Request * @return Request
*/ */
public function update(string $id, FormItemData $data): Request public function update(string $id, FormItemData $data): Request
{ {
$array = $data->toArray(); $array = $data->toArray();
$notes = $data['notes'] ?? ''; $notes = $data['notes'] ?? '';
$progress = array_key_exists('progress', $array) ? $data['progress'] : 0; $progress = array_key_exists('progress', $array) ? $data['progress'] : 0;
$private = array_key_exists('private', $array) ? (bool)$data['private'] : false; $private = array_key_exists('private', $array) ? (bool)$data['private'] : false;
$rating = array_key_exists('rating', $array) ? $data['rating'] : NULL; $rating = array_key_exists('ratingTwenty', $array) ? $data['ratingTwenty'] : NULL;
$status = ($data['reconsuming'] === true) ? AnilistStatus::REPEATING : AnimeWatchingStatus::KITSU_TO_ANILIST[$data['status']]; $status = ($data['reconsuming'] === true) ? AnilistStatus::REPEATING : AnimeWatchingStatus::KITSU_TO_ANILIST[$data['status']];
$updateData = [ $updateData = [
'id' => (int)$id, 'id' => (int)$id,
'status' => $status, 'status' => $status,
'score' => $rating * 10, 'score' => $rating * 5,
'progress' => $progress, 'progress' => $progress,
'repeat' => (int)$data['reconsumeCount'], 'repeat' => (int)$data['reconsumeCount'],
'private' => $private, 'private' => $private,

View File

@ -89,14 +89,14 @@ final class Model
throw new InvalidArgumentException('Media id missing'); throw new InvalidArgumentException('Media id missing');
} }
if ($type === 'anime') if ($type === 'ANIME')
{ {
$createData = [ $createData = [
'id' => $mediaId, 'id' => $mediaId,
'status' => AnimeWatchingStatus::KITSU_TO_ANILIST[$data['status']], 'status' => AnimeWatchingStatus::KITSU_TO_ANILIST[$data['status']],
]; ];
} }
elseif ($type === 'manga') elseif ($type === 'MANGA')
{ {
$createData = [ $createData = [
'id' => $mediaId, 'id' => $mediaId,

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1); <?php // declare(strict_types=1);
/** /**
* Hummingbird Anime List Client * Hummingbird Anime List Client
* *

View File

@ -66,6 +66,8 @@ final class SyncLists extends BaseCommand {
$this->sync('anime'); $this->sync('anime');
$this->sync('manga'); $this->sync('manga');
$this->echoBox('Finished syncing lists');
} }
/** /**
@ -363,7 +365,7 @@ final class SyncLists extends BaseCommand {
'private' => $kItem['private'], 'private' => $kItem['private'],
'progress' => $kItem['progress'], 'progress' => $kItem['progress'],
'repeat' => $kItem['reconsumeCount'], 'repeat' => $kItem['reconsumeCount'],
'score' => $kItem['ratingTwenty'] / 2, 'score' => $kItem['ratingTwenty'] * 5, // 100 point score on Anilist
'status' => $newItemStatus, 'status' => $newItemStatus,
], ],
]; ];
@ -425,7 +427,7 @@ final class SyncLists extends BaseCommand {
$sameNotes = $diff['notes'] === 0; $sameNotes = $diff['notes'] === 0;
$sameStatus = $diff['status'] === 0; $sameStatus = $diff['status'] === 0;
$sameProgress = $diff['progress'] === 0; $sameProgress = $diff['progress'] === 0;
$sameRating = $diff['rating'] === 0; $sameRating = $diff['ratingTwenty'] === 0;
$sameRewatchCount = $diff['reconsumeCount'] === 0; $sameRewatchCount = $diff['reconsumeCount'] === 0;
// If an item is completed, make sure the 'reconsuming' flag is false // If an item is completed, make sure the 'reconsuming' flag is false
@ -497,12 +499,12 @@ final class SyncLists extends BaseCommand {
{ {
if ($kitsuItem['data']['rating'] !== 0 && $dateDiff === 1) if ($kitsuItem['data']['rating'] !== 0 && $dateDiff === 1)
{ {
$update['data']['rating'] = $kitsuItem['data']['rating']; $update['data']['ratingTwenty'] = $kitsuItem['data']['ratingTwenty'];
$return['updateType'][] = 'anilist'; $return['updateType'][] = 'anilist';
} }
else if($dateDiff === -1) else if($dateDiff === -1)
{ {
$update['data']['rating'] = $anilistItem['data']['rating']; $update['data']['ratingTwenty'] = $anilistItem['data']['rating'] * 2;
$return['updateType'][] = 'kitsu'; $return['updateType'][] = 'kitsu';
} }
} }
@ -557,7 +559,7 @@ final class SyncLists extends BaseCommand {
'notes' => $kitsuItem['data']['notes'], 'notes' => $kitsuItem['data']['notes'],
'private' => $kitsuItem['data']['private'], 'private' => $kitsuItem['data']['private'],
'progress' => $kitsuItem['data']['progress'], 'progress' => $kitsuItem['data']['progress'],
'rating' => $kitsuItem['data']['rating'], 'rating' => $kitsuItem['data']['ratingTwenty'] * 5,
'reconsumeCount' => $kitsuItem['data']['reconsumeCount'], 'reconsumeCount' => $kitsuItem['data']['reconsumeCount'],
'reconsuming' => $kitsuItem['data']['reconsuming'], 'reconsuming' => $kitsuItem['data']['reconsuming'],
'status' => $kitsuItem['data']['status'], 'status' => $kitsuItem['data']['status'],

View File

@ -201,7 +201,7 @@ final class Index extends BaseController {
public function images(string $type, string $file): void public function images(string $type, string $file): void
{ {
$kitsuUrl = 'https://media.kitsu.io/'; $kitsuUrl = 'https://media.kitsu.io/';
list($id, $ext) = explode('.', basename($file)); [$id, $ext] = explode('.', basename($file));
switch ($type) switch ($type)
{ {
case 'anime': case 'anime':