Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code-quality-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup PHP and linter
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.4'
tools: parallel-lint, phpunit, php-cs-fixer
- name: Run code quality checks
run: ./.github/workflows/utilities/lint-pr ${{ github.base_ref }}
2 changes: 1 addition & 1 deletion .github/workflows/code-quality-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP and linter
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.4'
tools: parallel-lint, phpunit, php-cs-fixer
- name: Run code quality checks
run: ./.github/workflows/utilities/lint-push
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
max-parallel: 4
matrix:
operatingSystem: [ubuntu-22.04, windows-latest]
phpVersion: ['8.3']
phpVersion: ['8.4']
fail-fast: false
runs-on: ${{ matrix.operatingSystem }}
name: ${{ matrix.operatingSystem }} / PHP ${{ matrix.phpVersion }}
Expand Down
12 changes: 6 additions & 6 deletions src/Parser/Anime/AnimeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function getStatus(): ?string
public function getPremiered(): ?string
{
$premiered = $this->crawler
->filterXPath('//span[text()="Premiered:"]');
->filterXPath('//span[contains(normalize-space(.), "Premiered:")]');

if (!$premiered->count()) {
return null;
Expand Down Expand Up @@ -702,7 +702,7 @@ public function getExternalLinks(): array
public function getStreamingLinks(): array
{
$links = $this->crawler
->filterXPath('//*[@id="content"]/table/tr/td[1]/div/div[contains(@class, "broadcast")]//div[contains(@class, "broadcast")]');
->filterXPath('//*[@id="content"]/table/tbody/tr/td[1]/div/div[contains(@class, "broadcast")]//div[contains(@class, "broadcast")]');

if (!$links->count()) {
return [];
Expand Down Expand Up @@ -766,7 +766,7 @@ function (Crawler $c) use (&$related) {

// Then we'll parse the table
$this->crawler
->filterXPath('//table[contains(@class, "entries-table")]/tr')
->filterXPath('//table[contains(@class, "entries-table")]/tbody/tr')
->each(
function (Crawler $c) use (&$related) {
$links = $c->filterXPath('//td[2]//a');
Expand Down Expand Up @@ -834,9 +834,9 @@ public function getBackground(): ?string
*/
public function getOpeningThemes(): array
{
$node = $this->crawler->filterXPath('//div[@class="theme-songs js-theme-songs opnening"]/table/tr');
$node = $this->crawler->filterXPath('//div[@class="theme-songs js-theme-songs opnening"]/table/tbody/tr/td');

if (preg_match('~No opening themes have been added to this title~', $node->text())) {
if (str_contains($node->text(), 'No opening themes have been added to this title')) {
return [];
}

Expand All @@ -853,7 +853,7 @@ public function getOpeningThemes(): array
*/
public function getEndingThemes(): array
{
$node = $this->crawler->filterXPath('//div[@class="theme-songs js-theme-songs ending"]/table/tr');
$node = $this->crawler->filterXPath('//div[@class="theme-songs js-theme-songs ending"]/table/tbody/tr');

if (preg_match('~No ending themes have been added to this title~', $node->text())) {
return [];
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Anime/AnimeRecentlyUpdatedByUsersParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getResults(): array
{
try {
return $this->crawler
->filterXPath('//table[@class="table-recently-updated"]/tr[1]')
->filterXPath('//table[@class="table-recently-updated"]/tbody/tr[1]')
->nextAll()
->each(
function ($c) {
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Anime/AnimeStatsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function getScores(): array
return [];
}

$table = $this->crawler->filterXPath('//h2[text()="Score Stats"]/following-sibling::table[1]/tr');
$table = $this->crawler->filterXPath('//h2[text()="Score Stats"]/following-sibling::table[1]/tbody/tr');

$scores = [];
$table
Expand Down
8 changes: 4 additions & 4 deletions src/Parser/Anime/EpisodesParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function (Crawler $crawler) {
public function getLastPage(): int
{
$pages = $this->crawler
->filterXPath('//*[@id="content"]/table/tr/td[2]/div[2]/div[2]/div[2]/div//a[contains(@class, "link")]');
->filterXPath('//*[@id="content"]/table/tbody/tr/td[2]/div[2]/div[2]/div[2]/div//a[contains(@class, "link")]');

if (!$pages->count()) {
return 1;
Expand All @@ -80,7 +80,7 @@ public function getLastPage(): int
public function getHasNextPage(): bool
{
$isBeyondLastPage = $this->crawler
->filterXPath('//*[@id="content"]/table/tr/td[2]/div/div[2]/table/tbody/tr/td/div[2]');
->filterXPath('//*[@id="content"]/table/tbody/tr/td[2]/div/div[2]/table/tbody/tr/td/div[2]');

if (
$isBeyondLastPage->count()
Expand All @@ -90,14 +90,14 @@ public function getHasNextPage(): bool
}

$pageLinks = $this->crawler
->filterXPath('//*[@id="content"]/table/tr/td[2]/div[2]/div[2]/div[2]/div//a[contains(@class, "link")]');
->filterXPath('//*[@id="content"]/table/tbody/tr/td[2]/div[2]/div[2]/div[2]/div//a[contains(@class, "link")]');

if (!$pageLinks->count()) {
return false;
}

$isLastPage = $this->crawler
->filterXPath('//*[@id="content"]/table/tr/td[2]/div[2]/div[2]/div[2]/div//a[contains(@class, "current") and position() = last()]');
->filterXPath('//*[@id="content"]/table/tbody/tr/td[2]/div[2]/div[2]/div[2]/div//a[contains(@class, "current") and position() = last()]');

if ($isLastPage->count()) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Anime/VideosParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(Crawler $crawler)
public function getEpisodes(): array
{
$episodes = $this->crawler
->filterXPath('//*[@id="content"]/table/tr/td[2]/div[2]/div[2]/div[contains(@class, "video-block episode-video")]//*[contains(@class, "video-list-outer")]');
->filterXPath('//*[@id="content"]/table/tbody/tr/td[2]/div[2]/div[2]/div[contains(@class, "video-block episode-video")]//*[contains(@class, "video-list-outer")]');

if (!$episodes->count()) {
return [];
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Character/CharacterListItemParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(Crawler $crawler)
*/
public function getVoiceActors(): array
{
return $this->crawler->filterXPath('//table[2]/tr')->each(
return $this->crawler->filterXPath('//table[2]/tbody/tr')->each(
function (Crawler $c) {
return new VoiceActorParser($c)->getModel();
}
Expand Down
12 changes: 7 additions & 5 deletions src/Parser/Character/CharacterParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ public function getNameNicknames(): array
*/
public function getAbout(): ?string
{
$crawler = $this->crawler->filterXPath('//*[@id="content"]/table/tr/td[2]');

$crawler = $this->crawler->filterXPath('//*[@id="content"]/table/tbody/tr/td[2]');

$aboutHtml = $crawler->html();

$aboutHtml = str_replace(['<br>'], '\n', $aboutHtml);
Expand All @@ -135,7 +137,7 @@ public function getAbout(): ?string
*/
public function getMemberFavorites(): int
{
$crawler = $this->crawler->filterXPath('//*[@id="content"]/table/tr/td[1]');
$crawler = $this->crawler->filterXPath('//*[@id="content"]/table/tbody/tr/td[1]');
$crawler = Parser::removeChildNodes($crawler);

return (int) preg_replace('/\D/', '', $crawler->text());
Expand All @@ -157,7 +159,7 @@ public function getImage(): string
public function getAnimeography(): array
{
return $this->crawler
->filterXPath('//div[contains(text(), \'Animeography\')]/../table[1]/tr')
->filterXPath('//div[contains(text(), \'Animeography\')]/../table[1]/tbody/tr')
->each(
function (Crawler $c) {
return new AnimeographyParser($c)->getModel();
Expand All @@ -172,7 +174,7 @@ function (Crawler $c) {
public function getMangaography(): array
{
return $this->crawler
->filterXPath('//div[contains(text(), \'Mangaography\')]/../table[2]/tr')
->filterXPath('//div[contains(text(), \'Mangaography\')]/../table[2]/tbody/tr')
->each(
function (Crawler $c) {
return new MangaographyParser($c)->getModel();
Expand All @@ -188,7 +190,7 @@ function (Crawler $c) {
public function getVoiceActors(): array
{
return $this->crawler
->filterXPath('//div[contains(text(), \'Voice Actors\')]/../table/tr')
->filterXPath('//div[contains(text(), \'Voice Actors\')]/../table/tbody/tr')
->each(
function (Crawler $c) {
return new VoiceActorParser($c)->getModel();
Expand Down
12 changes: 6 additions & 6 deletions src/Parser/Club/ClubParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getImageUrl(): string
{
return Parser::parseImageQuality(
$this->crawler
->filterXPath('//div[@id="content"]/table/tr/td[2]/div/div[1]/img')
->filterXPath('//div[@id="content"]/table/tbody/tr/td[2]/div/div[1]/img')
->attr('data-src')
);
}
Expand All @@ -85,7 +85,7 @@ public function getMembersCount(): int
{
return (int) Parser::removeChildNodes(
$this->crawler
->filterXPath('//div[@id="content"]/table/tr/td[2]/div/div[4]')
->filterXPath('//div[@id="content"]/table/tbody/tr/td[2]/div/div[4]')
)->text();
}

Expand All @@ -96,7 +96,7 @@ public function getPicturesCount(): int
{
return (int) Parser::removeChildNodes(
$this->crawler
->filterXPath('//div[@id="content"]/table/tr/td[2]/div/div[5]')
->filterXPath('//div[@id="content"]/table/tbody/tr/td[2]/div/div[5]')
)->text();
}

Expand All @@ -108,7 +108,7 @@ public function getCategory(): string
$category = JString::cleanse(
Parser::removeChildNodes(
$this->crawler
->filterXPath('//div[@id="content"]/table/tr/td[2]/div/div[6]')
->filterXPath('//div[@id="content"]/table/tbody/tr/td[2]/div/div[6]')
)->text()
);

Expand All @@ -122,7 +122,7 @@ public function getCategory(): string
public function getCreated(): \DateTimeImmutable
{
$node = $this->crawler
->filterXPath('//div[@id="content"]/table/tr/td[2]/div/div[contains(., "Created")]');
->filterXPath('//div[@id="content"]/table/tbody/tr/td[2]/div/div[contains(., "Created")]');

$date = JString::cleanse(
Parser::removeChildNodes($node)
Expand All @@ -139,7 +139,7 @@ public function getType(): string
{
$typeNode = JString::cleanse(
$this->crawler
->filterXPath('//div[@id="content"]/table/tr/td[2]/div')
->filterXPath('//div[@id="content"]/table/tbody/tr/td[2]/div')
->text()
);

Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Club/UserListParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getModel(): UserList
public function getResults(): array
{
return $this->crawler
->filterXPath('//*[@id="content"]/table/tr/td')
->filterXPath('//*[@id="content"]/table/tbody/tr/td')
->each(
function (Crawler $crawler) {
return new UserProfileParser($crawler)->getModel();
Expand Down
15 changes: 6 additions & 9 deletions src/Parser/Common/Recommendation.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
*/
class Recommendation implements ParserInterface
{
/**
* @var Crawler
*/
private $crawler;
private \Symfony\Component\DomCrawler\Crawler $crawler;

/**
* Recommendation constructor.
Expand All @@ -38,7 +35,7 @@ public function __construct(Crawler $crawler)
public function getUrl(): string
{
return $this->crawler
->filterXPath('//table/tr/td[2]/div[2]/a[1]')->attr('href');
->filterXPath('//table/tbody/tr/td[2]/div[2]/a[1]')->attr('href');
}

/**
Expand All @@ -49,7 +46,7 @@ public function getImageUrl(): string
{
return Parser::parseImageQuality(
$this->crawler
->filterXPath('//table/tr/td[1]/div[1]/a/img')->attr('data-src')
->filterXPath('//table/tbody/tr/td[1]/div[1]/a/img')->attr('data-src')
);
}

Expand All @@ -60,7 +57,7 @@ public function getImageUrl(): string
public function getRecommendationurl(): string
{
return Constants::BASE_URL . $this->crawler
->filterXPath('//table/tr/td[2]/div[2]/span/a')->attr('href');
->filterXPath('//table/tbody/tr/td[2]/div[2]/span/a')->attr('href');
}

/**
Expand All @@ -70,7 +67,7 @@ public function getRecommendationurl(): string
public function getTitle(): string
{
return $this->crawler
->filterXPath('//table/tr/td[2]/div[2]/a[1]')->text();
->filterXPath('//table/tbody/tr/td[2]/div[2]/a[1]')->text();
}

/**
Expand All @@ -80,7 +77,7 @@ public function getTitle(): string
public function getRecommendationCount(): int
{
$node = $this->crawler
->filterXPath('//table/tr/td[2]/div[4]/a[1]/strong');
->filterXPath('//table/tbody/tr/td[2]/div[4]/a[1]/strong');

if (!$node->count()) {
return 1;
Expand Down
Loading