Skip to content

Commit

Permalink
Use GraphQL to fetch paginated keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
jetrosuni committed Feb 25, 2024
1 parent c622579 commit 8717692
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Imdb/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -2955,9 +2955,16 @@ public function officialSites()
public function keywords_all()
{
if (empty($this->all_keywords)) {
$page = $this->getPage("Keywords");
if (preg_match_all('|<a.*?href="/search/keyword[^>]+?>(.*?)</a>|', $page, $matches)) {
$this->all_keywords = $matches[1];
$query = <<<EOF
keyword {
text {
text
}
}
EOF;
$edges = $this->graphQlGetAll("TitleKeywordsPagination", "keywords", $query);
foreach ($edges as $edge) {
$this->all_keywords[] = $edge->node->keyword->text->text;
}
}
return $this->all_keywords;
Expand Down

0 comments on commit 8717692

Please sign in to comment.