forked from blallo/rss-bridge
6f24858124
This commit is a squash of all commits that fix coding styles for the new coding style policy. [ABCTabsBridge] Fix coding style [AcrimedBridge] Fix coding style [AllocineFRBridge] Fix coding style [AnimeUltimeBridge] Fix coding style [Arte7Bridge] Fix coding style [AskfmBridge] Fix coding style [BandcampBridge] Fix coding style [BastaBridge] Fix coding style [BlaguesDeMerdeBridge] Fix coding style [BooruprojectBridge] Fix coding style [CADBridge] Fix coding style [CNETBridge] Fix coding style [CastorusBridge] Fix coding style [CollegeDeFranceBridge] Fix coding style [CommonDreamsBridge] Fix coding style [CopieDoubleBridge] Fix coding style [CourrierInternationalBridge] Fix coding style [CpasbienBridge] Fix coding style [CryptomeBridge] Fix coding style [DailymotionBridge] Fix coding style [DanbooruBridge] Fix coding style [DansTonChatBridge] Fix coding style [DauphineLibereBridge] Fix coding style [DeveloppezDotComBridge] Fix coding style [DemoBridge] Fix coding style [DilbertBridge] Fix coding style [DuckDuckGoBridge] Fix coding style [DollbooruBridge] Fix coding style [EliteDangerousGalnetBridge] Fix coding style [ElsevierBridge] Fix coding style [EstCeQuonMetEnProdBridge] Fix coding style [EZTVBridge] Fix coding style [FacebookBridge] Fix coding style [FeedExpanderExampleBridge] Fix coding style [FB2Bridge] Fix coding style [FierPandaBridge] Fix coding style [FlickrBridge] Fix coding style [FootitoBridge] Fix coding style [FourchanBridge] Fix coding style [FuturaSciencesBridge] Fix coding style [GBAtempBridge] Fix coding style [GelbooruBridge] Fix coding style [GiphyBridge] Fix coding style [GithubIssueBridge] Fix coding style [GizmodoBridge] Fix coding style [GoComicsBridge] Fix coding style [GooglePlusPostBridge] Fix coding style [GoogleSearchBridge] Fix coding style [HDWallpapersBridge] Fix coding style [HentaiHavenBridge] Fix coding style [IdenticaBridge] Fix coding style [InstagramBridge] Fix coding style [IsoHuntBridge] Fix coding style [JapanExpoBridge] Fix coding style [KonachanBridge] Fix coding style [KoreusBridge] Fix coding style [KununuBridge] Fix coding style [LeBonCoinBridge] Fix coding style [LegifranceJOBBridge] Fix coding style [LeMondeInformatiqueBridge] Fix coding style [LesJoiesDuCodeBridge] Fix coding style [LichessBridge] Fix coding style [LinkedInCompanyBridge] Fix coding style [LolibooruBridge] Fix coding style [LWNprevBridge] Fix coding style [MangareaderBridge] Fix coding style [MilbooruBridge] Fix coding style [MixCloudBridge] Fix coding style [MoebooruBridge] Fix coding style [MondeDiploBridge] Fix coding style [MsnMondeBridge] Fix coding style [MspabooruBridge] Fix coding style [NasaApodBridge] Fix coding style [NeuviemeArtBridge] Fix coding style [NextgovBridge] Fix coding style [NextInpactBridge] Fix coding style [NiceMatinBridge] Fix coding style [NovelUpdatesBridge] Fix coding style [OpenClassroomsBridge] Fix coding style [ParuVenduImmoBridge] Fix coding style [PickyWallpapersBridge] Fix coding style [PinterestBridge] Fix coding style [PlanetLibreBridge] Fix coding style [ReadComicsBridge] Fix coding style [Releases3DSBridge] Fix coding style [ReporterreBridge] Fix coding style [RTBFBridge] Fix coding style [Rue89Bridge] Fix coding style [Rule34Bridge] Fix coding style [Rule34pahealBridge] Fix coding style [SafebooruBridge] Fix coding style [SakugabooruBridge] Fix coding style [ScmbBridge] Fix coding style [ScoopItBridge] Fix coding style [SensCritiqueBridge] Fix coding style [SexactuBridge] Fix coding style [ShanaprojectBridge] Fix coding style [Shimmie2Bridge] Fix coding style [SoundcloudBridge] Fix coding style [StripeAPIChangeLogBridge] Fix coding style [SuperbWallpapersBridge] Fix coding style [T411Bridge] Fix coding style [TagBoardBridge] Fix coding style [TbibBridge] Fix coding style [TheCodingLoveBridge] Fix coding style [TheHackerNewsBridge] Fix coding style [ThePirateBayBridge] Fix coding style [TheTVDBBridge] Fix coding style [Torrent9Bridge] Fix coding style [TwitterBridge] Fix coding style [UnsplashBridge] Fix coding style [ViadeoCompanyBridge] Fix coding style [VineBridge] Fix coding style [VkBridge] Fix coding style [WallpaperStopBridge] Fix coding style [WebfailBridge] Fix coding style [WeLiveSecurityBridge] Fix coding style [WhydBridge] Fix coding style [WikipediaBridge] Fix coding style [WordPressBridge] Fix coding style [WorldOfTanksBridge] Fix coding style [XbooruBridge] Fix coding style [YandereBridge] Fix coding style [YoutubeBridge] Fix coding style [ZDNetBridge] Fix coding style
136 lines
5 KiB
PHP
136 lines
5 KiB
PHP
<?php
|
|
class Releases3DSBridge extends BridgeAbstract {
|
|
|
|
const MAINTAINER = 'ORelio';
|
|
const NAME = '3DS Scene Releases';
|
|
const URI = 'http://www.3dsdb.com/';
|
|
const CACHE_TIMEOUT = 10800; // 3h
|
|
const DESCRIPTION = 'Returns the newest scene releases.';
|
|
|
|
public function collectData(){
|
|
|
|
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 = self::URI . 'xml.php';
|
|
$xml = getContents($dataUrl)
|
|
or returnServerError('Could not request 3dsdb: ' . $dataUrl);
|
|
$limit = 0;
|
|
|
|
foreach(array_reverse(explode('<release>', $xml)) as $element){
|
|
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>');
|
|
$publisher = extractFromDelimiters($element, '<publisher>', '</publisher>');
|
|
$region = extractFromDelimiters($element, '<region>', '</region>');
|
|
$group = extractFromDelimiters($element, '<group>', '</group>');
|
|
$imagesize = extractFromDelimiters($element, '<imagesize>', '</imagesize>');
|
|
$serial = extractFromDelimiters($element, '<serial>', '</serial>');
|
|
$titleid = extractFromDelimiters($element, '<titleid>', '</titleid>');
|
|
$imgcrc = extractFromDelimiters($element, '<imgcrc>', '</imgcrc>');
|
|
$filename = extractFromDelimiters($element, '<filename>', '</filename>');
|
|
$trimmedsize = extractFromDelimiters($element, '<trimmedsize>', '</trimmedsize>');
|
|
$firmware = extractFromDelimiters($element, '<firmware>', '</firmware>');
|
|
$type = extractFromDelimiters($element, '<type>', '</type>');
|
|
$card = extractFromDelimiters($element, '<card>', '</card>');
|
|
|
|
//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 = getSimpleHTMLDOM($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 = '<div><img src="'
|
|
. $ignCoverArt
|
|
. '" /></div><div>'
|
|
. $ignDesc
|
|
. ' <a href="'
|
|
. $ignLink
|
|
. '">More at IGN</a></div>';
|
|
}
|
|
|
|
//Main section : Release description from 3DS database
|
|
$releaseDescription = '<h3>Release Details</h3><b>Release ID: </b>' . $id
|
|
. '<br /><b>Game Name: </b>' . $name
|
|
. '<br /><b>Publisher: </b>' . $publisher
|
|
. '<br /><b>Region: </b>' . $region
|
|
. '<br /><b>Group: </b>' . $group
|
|
. '<br /><b>Image size: </b>' . (intval($imagesize) / 8)
|
|
. 'MB<br /><b>Serial: </b>' . $serial
|
|
. '<br /><b>Title ID: </b>' . $titleid
|
|
. '<br /><b>Image CRC: </b>' . $imgcrc
|
|
. '<br /><b>File Name: </b>' . $filename
|
|
. '<br /><b>Release Name: </b>' . $releasename
|
|
. '<br /><b>Trimmed size: </b>' . intval(intval($trimmedsize) / 1048576)
|
|
. 'MB<br /><b>Firmware: </b>' . $firmware
|
|
. '<br /><b>Type: </b>' . typeToString($type)
|
|
. '<br /><b>Card: </b>' . cardToString($card)
|
|
. '<br />';
|
|
|
|
//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 = '<h3>Search this release</h3><ul><li><a href="'
|
|
. $searchLinkGoogle
|
|
. '">Search using Google</a></li><li><a href="'
|
|
. $searchLinkDuckDuckGo
|
|
. '">Search using DuckDuckGo</a></li><li><a href="'
|
|
. $searchLinkQwant
|
|
. '">Search using Qwant</a></li></ul>';
|
|
|
|
//Build and add final item with the above three sections
|
|
$item = array();
|
|
$item['title'] = $name;
|
|
$item['author'] = $publisher;
|
|
$item['timestamp'] = $ignDate;
|
|
$item['uri'] = empty($ignLink) ? $searchLinkDuckDuckGo : $ignLink;
|
|
$item['content'] = $ignDescription . $releaseDescription . $releaseSearchLinks;
|
|
$this->items[] = $item;
|
|
$limit++;
|
|
}
|
|
}
|
|
}
|