Skip to content

Commit

Permalink
Merge pull request #282 from jikan-me/master
Browse files Browse the repository at this point in the history
Parser bug fixes
  • Loading branch information
irfan-dahir authored May 20, 2020
2 parents 18d50cc + 80d4bb7 commit c5f4052
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ A REST API service is available as well
### Wrappers

- **[.NET]** [Jikan.net](https://github.com/Ervie/jikan.net) by Ervie
- **[Python]** [JikanPy](https://github.com/AWConant/jikanpy) by Andrew Conant & Abhinav Kasamsetty
- **[Python]** [JikanPy](https://github.com/abhinavk99/jikanpy) by Abhinav Kasamsetty
- **[Ruby]** [Jikan.rb](https://github.com/Zerocchi/jikan.rb) by Zerocchi
- **[JavaScript]** [JikanJS](https://github.com/zuritor/jikanjs) by Zuritor
- **[Java]** [Jikan4java](https://github.com/Doomsdayrs/Jikan4java) by Doomsdayrs
Expand Down
11 changes: 1 addition & 10 deletions src/Parser/Search/CharacterSearchParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,8 @@ public function getModel(): CharacterSearch
*/
public function getResults(): array
{

if ($this->crawler->filterXPath('//div[@id="content"]/table/tr[2]/td')
// Yes, MAL actually has "probrems"
->text() === 'There were some probrems:Must have at least 3 byte characters to search'
) {
return [];
}

return $this->crawler
->filterXPath('//div[@id="content"]/table/tr[1]')
->nextAll()
->filterXPath('//div[@id="content"]/table/tr')
->each(
function (Crawler $c) {
return (new CharacterSearchListItemParser($c))->getModel();
Expand Down
10 changes: 10 additions & 0 deletions src/Parser/User/Profile/AnimeStatsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public function getDaysWatched(): ?float
*/
public function getMeanScore(): ?float
{
$node = $this->crawler
->filterXPath(
'//*[@id="statistics"]/div[contains(@class, "user-statistics-stats")][1]
/div[contains(@class, "stats anime")]/div[1]/div[2]/span[contains(@class, "score-label")]'
);

if ($node->count()) {
return (float) $node->text();
}

$node = $this->crawler
->filterXPath('//div[@class=\'di-tc ar pr8 fs12 fw-b\'][1]');

Expand Down
10 changes: 10 additions & 0 deletions src/Parser/User/Profile/MangaStatsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public function getDaysRead(): ?float
*/
public function getMeanScore(): ?float
{
$node = $this->crawler
->filterXPath(
'//*[@id="statistics"]/div[contains(@class, "user-statistics-stats")][2]
/div[contains(@class, "stats manga")]/div[1]/div[2]/span[contains(@class, "score-label")]'
);

if ($node->count()) {
return (float) $node->text();
}

$node = $this->crawler
->filterXPath('//div[@class=\'di-tc ar pr8 fs12 fw-b\'][2]');

Expand Down

0 comments on commit c5f4052

Please sign in to comment.