Skip to content

Commit

Permalink
fix #374 v2
Browse files Browse the repository at this point in the history
  • Loading branch information
irfan-dahir committed Dec 7, 2021
1 parent dd51335 commit c80d751
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
41 changes: 21 additions & 20 deletions src/Parser/User/Profile/FavoritesParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jikan\Parser\User\Profile;

use Jikan\Helper\Constants;
use Jikan\Helper\Parser;
use Jikan\Model\Common\AnimeMeta;
use Jikan\Model\Common\CharacterMeta;
Expand Down Expand Up @@ -48,14 +49,14 @@ public function getModel(): Favorites
*/
public function getAnime(): array
{
return $this->crawler->filterXPath('//ul[@class=\'favorites-list anime\']/li')
return $this->crawler->filterXPath('//div[@id=\'anime_favorites\']/div[@class=\'fav-slide-outer\']/ul/li')
->each(
function (Crawler $crawler) {
return new AnimeMeta(
$crawler->filterXPath('//div[position() = 2]/a')->text(),
$crawler->filterXPath('//div[position() = 2]/a')->attr('href'),
Parser::parseImageQuality($crawler->filterXPath('//div[position() = 1]/a/img')
->attr('src'))
$crawler->filterXPath('//a/span[contains(@class, \'title\')]')->text(),
$crawler->filterXPath('//a')->attr('href'),
Parser::parseImageQuality($crawler->filterXPath('//a/img')
->attr('data-src')),
);
}
);
Expand All @@ -67,14 +68,14 @@ function (Crawler $crawler) {
*/
public function getManga(): array
{
return $this->crawler->filterXPath('//ul[@class=\'favorites-list manga\']/li')
return $this->crawler->filterXPath('//div[@id=\'manga_favorites\']/div[@class=\'fav-slide-outer\']/ul/li')
->each(
function (Crawler $crawler) {
return new MangaMeta(
$crawler->filterXPath('//div[position() = 2]/a')->text(),
$crawler->filterXPath('//div[position() = 2]/a')->attr('href'),
Parser::parseImageQuality($crawler->filterXPath('//div[position() = 1]/a/img')
->attr('src'))
$crawler->filterXPath('//a/span[contains(@class, \'title\')]')->text(),
$crawler->filterXPath('//a')->attr('href'),
Parser::parseImageQuality($crawler->filterXPath('//a/img')
->attr('data-src')),
);
}
);
Expand All @@ -86,14 +87,14 @@ function (Crawler $crawler) {
*/
public function getCharacters(): array
{
return $this->crawler->filterXPath('//ul[@class=\'favorites-list characters\']/li')
return $this->crawler->filterXPath('//div[@id=\'character_favorites\']/div[@class=\'fav-slide-outer\']/ul/li')
->each(
function (Crawler $crawler) {
return new CharacterMeta(
$crawler->filterXPath('//div[position() = 2]/a')->text(),
$crawler->filterXPath('//div[position() = 2]/a')->attr('href'),
Parser::parseImageQuality($crawler->filterXPath('//div[position() = 1]/a/img')
->attr('src'))
$crawler->filterXPath('//a/span[contains(@class, \'title\')]')->text(),
Constants::BASE_URL.$crawler->filterXPath('//a')->attr('href'),
Parser::parseImageQuality($crawler->filterXPath('//a/img')
->attr('data-src')),
);
}
);
Expand All @@ -105,14 +106,14 @@ function (Crawler $crawler) {
*/
public function getPeople(): array
{
return $this->crawler->filterXPath('//ul[@class=\'favorites-list people\']/li')
return $this->crawler->filterXPath('//div[@id=\'person_favorites\']/div[@class=\'fav-slide-outer\']/ul/li')
->each(
function (Crawler $crawler) {
return new PersonMeta(
$crawler->filterXPath('//div[position() = 2]/a')->text(),
$crawler->filterXPath('//div[position() = 2]/a')->attr('href'),
Parser::parseImageQuality($crawler->filterXPath('//div[position() = 1]/a/img')
->attr('src'))
$crawler->filterXPath('//a/span[contains(@class, \'title\')]')->text(),
Constants::BASE_URL.$crawler->filterXPath('//a')->attr('href'),
Parser::parseImageQuality($crawler->filterXPath('//a/img')
->attr('data-src')),
);
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/User/Profile/UserProfileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function getAbout(): ?string
public function getFavorites(): Model\User\Favorites
{
// $node = $this->crawler->filterXPath('//ul[@class=\'favorites-list anime\']/li')
$node = $this->crawler->filterXPath('//div[contains(@class, \'user-favorites\')]');
$node = $this->crawler->filterXPath('//div[contains(@class, \'container-right\')]');

return (new FavoritesParser($node))->getModel();
}
Expand Down

0 comments on commit c80d751

Please sign in to comment.