Commit ef17ab96 authored by John Long's avatar John Long

RefreshShow: Skip episode fetch when show is not premium

This reduces the number of calls made to the server, and reduces the amount of
data stored.

Also, feed saving was moved after episode saving to prevent a situation where
feed saving occurred but episode save was cut off.

Ticket: N/A
parent bef4f4d0
......@@ -33,22 +33,25 @@ class RefreshShow
$response = $this->fetch($query);
$this->processFeed($feed, $response->feed);
$episodes = $response->episodes->episode;
$seasons = $this->extractSeasons($response->feed->season);
$this->processItems($feed, $episodes, $seasons);
$count = (int)$response->feed['episodeCount'];
if ($count > $query['c']) {
while ($query['c'] + $query['s'] < $count) {
$query['s'] += $query['c'];
$response = $this->fetch($query);
$episodes = $response->episodes->episode;
$seasons = $this->extractSeasons($response->feed->season);
$this->processItems($feed, $episodes, $seasons);
if ($response->feed['premium']->__toString()) {
$episodes = $response->episodes->episode;
$seasons = $this->extractSeasons($response->feed->season);
$this->processItems($feed, $episodes, $seasons);
$count = (int)$response->feed['episodeCount'];
if ($count > $query['c']) {
while ($query['c'] + $query['s'] < $count) {
$query['s'] += $query['c'];
$response = $this->fetch($query);
$episodes = $response->episodes->episode;
$seasons = $this->extractSeasons($response->feed->season);
$this->processItems($feed, $episodes, $seasons);
}
}
}
$this->processFeed($feed, $response->feed);
}
protected function fetch(array $query): \SimpleXMLElement
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment