maintainer = "ORelio"; $this->name = "3DS Scene Releases"; $this->uri = "http://www.3dsdb.com/"; $this->description = "Returns the newest scene releases."; $this->update = "2016-08-09"; } public function collectData(array $param) { function ExtractFromDelimiters($string, $start, $end) { if (strpos($string, $start) !== false) { $section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); return $section_retrieved; } return false; } function TypeToString($type) { switch ($type) { case 1: return '3DS Game'; case 4: return 'eShop'; default: return '??? ('.$type.')'; } } function CardToString($card) { switch ($card) { case 1: return 'Regular (CARD1)'; case 2: return 'NAND (CARD2)'; default: return '??? ('.$card.')'; } } $dataUrl = 'http://3dsdb.com/xml.php'; $xml = file_get_contents($dataUrl) or $this->returnError('Could not request 3dsdb: '.$dataUrl, 500); $limit = 0; foreach (array_reverse(explode('', $xml)) as $element) { if ($limit < 5) { if (strpos($element, '') !== false) { $id = ExtractFromDelimiters($element, '', ''); $name = ExtractFromDelimiters($element, '', ''); $publisher = ExtractFromDelimiters($element, '', ''); $region = ExtractFromDelimiters($element, '', ''); $group = ExtractFromDelimiters($element, '', ''); $imagesize = ExtractFromDelimiters($element, '', ''); $serial = ExtractFromDelimiters($element, '', ''); $titleid = ExtractFromDelimiters($element, '', ''); $imgcrc = ExtractFromDelimiters($element, '', ''); $filename = ExtractFromDelimiters($element, '', ''); $releasename = ExtractFromDelimiters($element, '', ''); $trimmedsize = ExtractFromDelimiters($element, '', ''); $firmware = ExtractFromDelimiters($element, '', ''); $type = ExtractFromDelimiters($element, '', ''); $card = ExtractFromDelimiters($element, '', ''); if (!empty($releasename)) { //Retrieve cover art and short desc from IGN? $ignResult = false; $ignDescription = ''; $ignLink = ''; $ignDate = time(); $ignCoverArt = ''; $ignSearchUrl = 'http://www.ign.com/search?q='.urlencode($name); if ($ignResult = $this->file_get_html($ignSearchUrl)) { $ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src; $ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext; $ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href; $ignDate = strtotime(trim($ignResult->find('span.publish-date', 0)->plaintext)); $ignDescription = '
'.$ignDesc.' More at IGN
'; } //Main section : Release description from 3DS database $releaseDescription = '

Release Details

' .'Release ID: '.$id.'
' .'Game Name: '.$name.'
' .'Publisher: '.$publisher.'
' .'Region: '.$region.'
' .'Group: '.$group.'
' .'Image size: '.(intval($imagesize)/8).'MB
' .'Serial: '.$serial.'
' .'Title ID: '.$titleid.'
' .'Image CRC: '.$imgcrc.'
' .'File Name: '.$filename.'
' .'Release Name: '.$releasename.'
' .'Trimmed size: '.intval(intval($trimmedsize)/1048576).'MB
' .'Firmware: '.$firmware.'
' .'Type: '.TypeToString($type).'
' .'Card: '.CardToString($card).'
'; //Build search links section to facilitate release search using search engines $releaseNameEncoded = urlencode(str_replace(' ', '+', $releasename)); $searchLinkGoogle = 'https://google.com/?q='.$releaseNameEncoded; $searchLinkDuckDuckGo = 'https://duckduckgo.com/?q='.$releaseNameEncoded; $searchLinkQwant = 'https://lite.qwant.com/?q='.$releaseNameEncoded.'&t=web'; $releaseSearchLinks = '

Search this release

'; //Build and add final item with the above three sections $item = new \Item(); $item->title = $name; $item->author = $publisher; $item->timestamp = $ignDate; $item->uri = empty($ignLink) ? $searchLinkDuckDuckGo : $ignLink; $item->content = $ignDescription.$releaseDescription.$releaseSearchLinks; $this->items[] = $item; $limit++; } } } } } public function getName() { return '3DS Scene Releases'; } public function getURI() { return 'http://www.3dsdb.com/'; } public function getCacheDuration() { return 10800; //3 hours } }