maintainer = 'ORelio'; $this->name = 'Anime-Ultime'; $this->uri = 'http://www.anime-ultime.net/'; $this->description = 'Returns the 10 newest releases posted on Anime-Ultime'; $this->update = '2016-08-17'; $this->parameters[] = '[ { "name" : "Type", "type" : "list", "identifier" : "type", "values" : [ { "name" : "Everything", "value" : "" }, { "name" : "Anime", "value" : "A" }, { "name" : "Drama", "value" : "D" }, { "name" : "Tokusatsu", "value" : "T" } ] } ]'; } public function collectData(array $param) { //Add type filter if provided $typeFilter = ''; if (!empty($param['type'])) { if ($param['type'] == 'A' || $param['type'] == 'D' || $param['type'] == 'T') { $typeFilter = $param['type']; if ($typeFilter == 'A') { $this->filter = 'Anime'; } if ($typeFilter == 'D') { $this->filter = 'Drama'; } if ($typeFilter == 'T') { $this->filter = 'Tokusatsu'; } } else $this->returnClientError('The provided type filter is invalid. Expecting A, D, T, or no filter'); } //Build date and filters for making requests $thismonth = date('mY').$typeFilter; $lastmonth = date('mY', mktime(0, 0, 0, date('n') - 1, 1, date('Y'))).$typeFilter; //Process each HTML page until having 10 releases $processedOK = 0; foreach (array($thismonth, $lastmonth) as $requestFilter) { //Retrive page contents $website = 'http://www.anime-ultime.net/'; $url = $website.'history-0-1/'.$requestFilter; $html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Anime-Ultime: '.$url); //Relases are sorted by day : process each day individually foreach ($html->find('div.history', 0)->find('h3') as $daySection) { //Retrieve day and build date information $dateString = $daySection->plaintext; $day = intval(substr($dateString, strpos($dateString, ' ') + 1, 2)); $item_date = strtotime(str_pad($day, 2, '0', STR_PAD_LEFT).'-'.substr($requestFilter, 0, 2).'-'.substr($requestFilter, 2, 4)); $release = $daySection->next_sibling()->next_sibling()->first_child(); //