Skip to content

Commit

Permalink
add malId to anime video episodes #294 [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Irfan committed Jul 9, 2020
1 parent 743a9df commit 4a92678
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/Model/Anime/StreamEpisodeListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
*/
class StreamEpisodeListItem
{
/**
* @var int
*/
public $malId;

/**
* @var string
*/
Expand Down Expand Up @@ -40,6 +45,7 @@ class StreamEpisodeListItem
public static function fromParser(StreamEpisodeListItemParser $parser): self
{
$instance = new self();
$instance->malId = $parser->getMalId();
$instance->title = $parser->getTitle();
$instance->episode = $parser->getEpisode();
$instance->url = $parser->getUrl();
Expand All @@ -48,6 +54,14 @@ public static function fromParser(StreamEpisodeListItemParser $parser): self
return $instance;
}

/**
* @return int
*/
public function getMalId(): int
{
return $this->malId;
}

/**
* @return string
*/
Expand Down
10 changes: 9 additions & 1 deletion src/Model/News/NewsListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class NewsListItem
{
/**
* @var int
* @var int|null
*/
private $malId;

Expand Down Expand Up @@ -84,6 +84,14 @@ public static function fromParser(NewsListItemParser $parser): self
return $instance;
}

/**
* @return int|null
*/
public function getMalId(): ?int
{
return $this->malId;
}

/**
* @return string
*/
Expand Down
14 changes: 14 additions & 0 deletions src/Parser/Anime/StreamEpisodeListItemParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ public function __construct(Crawler $crawler)
$this->crawler = $crawler;
}

/**
* @return int|null
*/
public function getMalId() : ?int
{
preg_match('~([\d]+)$~', $this->getUrl(), $matches);

if (!empty($matches)) {
return $matches[1];
}

return null;
}

/**
* @return StreamEpisodeListItem
* @throws \InvalidArgumentException
Expand Down
3 changes: 3 additions & 0 deletions src/Parser/News/NewsListItemParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function getTitle(): string
return $this->crawler->filterXPath('//p/a/strong')->text();
}

/**
* @return int|null
*/
public function getMalId() : ?int
{
preg_match('~([\d]+)$~', $this->getUrl(), $matches);
Expand Down

0 comments on commit 4a92678

Please sign in to comment.