[Releases3DSBridge] code simplification

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-29 22:22:33 +02:00
parent 9f82adc87b
commit 75a6f8af8a
1 changed files with 77 additions and 73 deletions

View File

@ -32,13 +32,23 @@ class Releases3DSBridge extends BridgeAbstract {
}
}
$dataUrl = 'http://3dsdb.com/xml.php';
$dataUrl = $this->uri.'xml.php';
$xml = $this->getContents($dataUrl) or $this->returnServerError('Could not request 3dsdb: '.$dataUrl);
$limit = 0;
foreach (array_reverse(explode('<release>', $xml)) as $element) {
if ($limit < 5) {
if (strpos($element, '</release>') !== false) {
if ($limit >= 5) {
break;
}
if (strpos($element, '</release>') === false) {
continue;
}
$releasename = ExtractFromDelimiters($element, '<releasename>', '</releasename>');
if (empty($releasename)) {
continue;
}
$id = ExtractFromDelimiters($element, '<id>', '</id>');
$name = ExtractFromDelimiters($element, '<name>', '</name>');
@ -50,14 +60,11 @@ class Releases3DSBridge extends BridgeAbstract {
$titleid = ExtractFromDelimiters($element, '<titleid>', '</titleid>');
$imgcrc = ExtractFromDelimiters($element, '<imgcrc>', '</imgcrc>');
$filename = ExtractFromDelimiters($element, '<filename>', '</filename>');
$releasename = ExtractFromDelimiters($element, '<releasename>', '</releasename>');
$trimmedsize = ExtractFromDelimiters($element, '<trimmedsize>', '</trimmedsize>');
$firmware = ExtractFromDelimiters($element, '<firmware>', '</firmware>');
$type = ExtractFromDelimiters($element, '<type>', '</type>');
$card = ExtractFromDelimiters($element, '<card>', '</card>');
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);
@ -109,9 +116,6 @@ class Releases3DSBridge extends BridgeAbstract {
$limit++;
}
}
}
}
}
public function getCacheDuration() {
return 10800; //3 hours