Skip to content

Commit

Permalink
Bug fixes [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Irfan committed Jul 22, 2020
1 parent 2939d64 commit a3a17ad
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/Model/Anime/AnimeReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
*/
class AnimeReview extends \Jikan\Model\Reviews\AnimeReview
{
/**
* @var string
*/
private $title;

/**
* @var AnimeReviewer
Expand All @@ -33,9 +37,10 @@ public static function fromParser(AnimeReviewParser $parser): AnimeReview
{
$instance = new self();

$instance->images = CommonImageResource::factory($parser->getImageUrl());
$instance->title = $parser->getTitle();
$instance->malId = $parser->getId();
$instance->url = $parser->getUrl();
$instance->images = CommonImageResource::factory($parser->getImageUrl());
$instance->type = $parser->getType();
$instance->votes = $parser->getHelpfulCount();
$instance->date = $parser->getDate();
Expand Down
11 changes: 9 additions & 2 deletions src/Model/Manga/MangaReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jikan\Model\Manga;

use Jikan\Model\Resource\CommonImageResource\CommonImageResource;
use Jikan\Parser\Manga\MangaReviewParser;

/**
Expand All @@ -16,6 +17,11 @@ class MangaReview extends \Jikan\Model\Reviews\MangaReview
*/
private $reviewer;

/**
* @var CommonImageResource
*/
private $images;

/**
* Create an instance from an MangaReviewParser parser
*
Expand All @@ -30,14 +36,15 @@ public static function fromParser(MangaReviewParser $parser): MangaReview
{
$instance = new self();

$instance->images = CommonImageResource::factory($parser->getImageUrl());
$instance->malId = $parser->getId();
$instance->url = $parser->getUrl();
$instance->type = $parser->getType();
$instance->helpfulCount= $parser->getHelpfulCount();
$instance->votes = $parser->getHelpfulCount();
$instance->date = $parser->getDate();
$instance->reviewer = $parser->getReviewer();
$instance->scores = $parser->getMangaScores();
$instance->content = $parser->getContent();
$instance->review = $parser->getContent();

return $instance;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Parser/Anime/AnimeReviewParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getUrl(): string
public function getTitle(): string
{
return $this->crawler
->filterXPath('//div[1]/div[3]/div/div/a')
->filterXPath('//div[1]/div[1]/div[2]/strong/a')
->text();
}

Expand All @@ -84,14 +84,14 @@ public function getImageUrl(): string
->filterXPath('//div[12]/div[1]/div[1]/a/img');

if ($node->count()) {
return $node->attr('data-src');
return Parser::parseImageQuality($node->attr('data-src'));
}

// Recent Reviews page
$node = $this->crawler
->filterXPath('//div[1]/div[2]/div[1]/div[1]/a/img');

return $node->attr('data-src');
return Parser::parseImageQuality($node->attr('data-src'));
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/Parser/Manga/MangaReviewParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getType(): ?string
public function getTitle(): string
{
return $this->crawler
->filterXPath('//div[1]/div[3]/div/div/a')
->filterXPath('//div[1]/div[1]/div[2]/strong/a')
->text();
}

Expand All @@ -189,13 +189,15 @@ public function getImageUrl(): string
->filterXPath('//div[12]/div[1]/div[1]/a/img');

if ($node->count()) {
return $node->attr('data-src');
return Parser::parseImageQuality($node->attr('data-src'));
}

// Recent Reviews page
// Recent Reviews Anime page
$node = $this->crawler
->filterXPath('//div[1]/div[2]/div[1]/div[1]/a/img');

return $node->attr('data-src');
if ($node->count()) {
return Parser::parseImageQuality($node->attr('data-src'));
}
}
}

0 comments on commit a3a17ad

Please sign in to comment.