From b6e4ea17a3a6dce208c30418a7a3a898b83d6938 Mon Sep 17 00:00:00 2001 From: horus Date: Mon, 24 Feb 2020 02:18:22 +0100 Subject: Stalled... --- app/Anime.php | 9 ++- app/AnimeScore.php | 77 ------------------------- app/AnimeStats.php | 98 ++++++++++++++++++++++++++++++++ app/Http/Controllers/IndexController.php | 2 +- app/Libraries/AnimeSeason.php | 20 +++++-- 5 files changed, 121 insertions(+), 85 deletions(-) delete mode 100644 app/AnimeScore.php create mode 100644 app/AnimeStats.php (limited to 'app') diff --git a/app/Anime.php b/app/Anime.php index 1e8fb95..e19e214 100644 --- a/app/Anime.php +++ b/app/Anime.php @@ -1,4 +1,7 @@ id = $id; + $this->mal_id = $id; if ( $parse_info ) { $jikan = new Malclient; $this->animeInfo = $jikan->getAnime( - (new \Jikan\Request\Anime\AnimeRequest( $this->id )) + (new \Jikan\Request\Anime\AnimeRequest( $this->mal_id )) ); $this->url = $this->animeInfo->GetUrl(); diff --git a/app/AnimeScore.php b/app/AnimeScore.php deleted file mode 100644 index 9f150d0..0000000 --- a/app/AnimeScore.php +++ /dev/null @@ -1,77 +0,0 @@ -id = $id; - - parent::__construct($this->id); - - $jikan = new Malclient; - - $animeInfo = $this->getInfo(); - $this->score = $animeInfo->getScore(); - $this->scored_by = $animeInfo->getScoredBy(); - $this->rank = $animeInfo->getRank(); - $this->popularity = $animeInfo->getPopularity(); - $this->members = $animeInfo->getMembers(); - $this->favorites = $animeInfo->getFavorites(); - - $animeStats = $jikan->getAnimeStats( - (new \Jikan\Request\Anime\AnimeStatsRequest( $this->id )) - ); - - $this->watching = $animeStats->getWatching(); - $this->completed = $animeStats->getCompleted(); - $this->onhold = $animeStats->getOnHold(); - $this->dropped = $animeStats->getDropped(); - $this->plan_to_watch = $animeStats->getPlanToWatch(); - - $scores = $animeStats->getScores(); - - $this->score_1 = $scores[1]->getVotes(); - $this->score_2 = $scores[2]->getVotes(); - $this->score_3 = $scores[3]->getVotes(); - $this->score_4 = $scores[4]->getVotes(); - $this->score_5 = $scores[5]->getVotes(); - $this->score_6 = $scores[6]->getVotes(); - $this->score_7 = $scores[7]->getVotes(); - $this->score_8 = $scores[8]->getVotes(); - $this->score_9 = $scores[9]->getVotes(); - $this->score_10 = $scores[10]->getVotes(); - } - -} diff --git a/app/AnimeStats.php b/app/AnimeStats.php new file mode 100644 index 0000000..fc69468 --- /dev/null +++ b/app/AnimeStats.php @@ -0,0 +1,98 @@ +mal_id = $id; + + parent::__construct($this->mal_id); + + $jikan = new Malclient; + +# if ( 0 == $season_year || "" == $season_name ) { + $season = $jikan->getSeasonal( + (new \Jikan\Request\Seasonal\SeasonalRequest( + )) + ); + + $this->season_year = $season->seasonYear; + $this->season_name= $season->seasonName; + /* + } else { + $this->season_year = $season_year; + $this->season_name= $season_name; + } +*/ + + $animeInfo = $this->getInfo(); + $this->score = $animeInfo->getScore(); + $this->scored_by = $animeInfo->getScoredBy(); + $this->rank = $animeInfo->getRank(); + $this->popularity = $animeInfo->getPopularity(); + $this->members = $animeInfo->getMembers(); + $this->favorites = $animeInfo->getFavorites(); + + $animeStats = $jikan->getAnimeStats( + (new \Jikan\Request\Anime\AnimeStatsRequest( $this->mal_id )) + ); + + $this->watching = $animeStats->getWatching(); + $this->completed = $animeStats->getCompleted(); + $this->onhold = $animeStats->getOnHold(); + $this->dropped = $animeStats->getDropped(); + $this->plan_to_watch = $animeStats->getPlanToWatch(); + + $scores = $animeStats->getScores(); + + $this->score_1 = $scores[1]->getVotes(); + $this->score_2 = $scores[2]->getVotes(); + $this->score_3 = $scores[3]->getVotes(); + $this->score_4 = $scores[4]->getVotes(); + $this->score_5 = $scores[5]->getVotes(); + $this->score_6 = $scores[6]->getVotes(); + $this->score_7 = $scores[7]->getVotes(); + $this->score_8 = $scores[8]->getVotes(); + $this->score_9 = $scores[9]->getVotes(); + $this->score_10 = $scores[10]->getVotes(); + } + +} diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index e6a263b..40bffa6 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -6,7 +6,7 @@ use Illuminate\Http\Request; use App\Libraries\AnimeSchedule; use App\Libraries\AnimeSeason; -use App\AnimeScore; +use App\AnimeStats; class IndexController extends Controller { /** diff --git a/app/Libraries/AnimeSeason.php b/app/Libraries/AnimeSeason.php index a234d5c..acdb34f 100644 --- a/app/Libraries/AnimeSeason.php +++ b/app/Libraries/AnimeSeason.php @@ -3,7 +3,7 @@ namespace App\Libraries; use App\Libraries\AnimeSeason; use App\Anime; -use App\AnimeScore; +use App\AnimeStats; use Carbon\Carbon; @@ -27,16 +27,26 @@ class AnimeSeason { ); $this->year = $season->seasonYear; - $this->name= $season->seasonName; + $this->name = $season->seasonName; $count = 0; foreach($season->anime as $entry) { $count++; - $anime = new AnimeScore( $entry->getMalID() ); - $this->anime[] = $anime; + + $anime = new Anime( $entry->getMalID() ); $anime->save(); - if ( $count == 5) { + $animeStats = new AnimeStats( $entry->getMalID(), $this->year, $this->name ); + $this->anime[] = $animeStats; + + $animeStats->create(); + + /* + echo "
";
+ var_dump($anime);
+ */
+
+ if ( $count == 1) {
return;
}
}
--
cgit v1.2.3