1
0
Fork 0
forked from blallo/rss-bridge

[SexactuBridge] Fix URI and timestamp

* const DOMAIN is not supported, it must be const URI
* strtotime should be used instead of date_parse in order to
receive a valid integer
* Some small readability enhancement
This commit is contained in:
logmanoriginal 2017-04-09 21:33:46 +02:00
parent f3b6b264d3
commit 8e84b52152

View file

@ -3,8 +3,8 @@ class SexactuBridge extends BridgeAbstract {
const MAINTAINER = 'Riduidel'; const MAINTAINER = 'Riduidel';
const NAME = 'Sexactu'; const NAME = 'Sexactu';
const AUTHOR = 'Maïa Mazaurette'; const AUTHOR = 'Ma<EFBFBD>a Mazaurette';
const DOMAIN = 'http://www.gqmagazine.fr'; const URI = 'http://www.gqmagazine.fr';
const CACHE_TIMEOUT = 7200; // 2h const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = 'Sexactu via rss-bridge'; const DESCRIPTION = 'Sexactu via rss-bridge';
@ -14,9 +14,8 @@ class SexactuBridge extends BridgeAbstract {
'data-original' => 'src' 'data-original' => 'src'
); );
public function getURI(){ public function getURI(){
return self::DOMAIN . '/sexactu'; return self::URI . '/sexactu';
} }
public function collectData(){ public function collectData(){
@ -40,7 +39,7 @@ class SexactuBridge extends BridgeAbstract {
if(substr($uri, 0, 1) === 'h'){ // absolute uri if(substr($uri, 0, 1) === 'h'){ // absolute uri
$item['uri'] = $uri; $item['uri'] = $uri;
} else if(substr($uri, 0, 1) === '/'){ // domain relative url } else if(substr($uri, 0, 1) === '/'){ // domain relative url
$item['uri'] = self::DOMAIN . $uri; $item['uri'] = self::URI . $uri;
} else { } else {
$item['uri'] = $this->getURI() . $uri; $item['uri'] = $this->getURI() . $uri;
} }
@ -49,7 +48,7 @@ class SexactuBridge extends BridgeAbstract {
$publicationDate = $article->find('time[itemprop=datePublished]', 0); $publicationDate = $article->find('time[itemprop=datePublished]', 0);
$short_date = $publicationDate->datetime; $short_date = $publicationDate->datetime;
$item['timestamp'] = date_parse($short_date); $item['timestamp'] = strtotime($short_date);
} else { } else {
// Sometimes we get rubbish, ignore. // Sometimes we get rubbish, ignore.
continue; continue;
@ -82,7 +81,7 @@ class SexactuBridge extends BridgeAbstract {
private function replaceUriInHtmlElement($element){ private function replaceUriInHtmlElement($element){
$returned = $element->innertext; $returned = $element->innertext;
foreach (self::REPLACED_ATTRIBUTES as $initial => $final) { foreach (self::REPLACED_ATTRIBUTES as $initial => $final) {
$returned = str_replace($initial.'="/', $final.'="' . self::DOMAIN . '/', $returned); $returned = str_replace($initial . '="/', $final . '="' . self::URI . '/', $returned);
} }
return $returned; return $returned;
} }