forked from blallo/rss-bridge
fixed title formatting
This commit is contained in:
parent
5f150d3ae5
commit
f7976419ae
1 changed files with 31 additions and 7 deletions
|
@ -9,7 +9,10 @@ define("GQ", "http://www.gqmagazine.fr");
|
|||
class Sexactu extends BridgeAbstract{
|
||||
|
||||
public function collectData(array $param){
|
||||
$html = file_get_html($this->getURI()) or $this->returnError('Could not request '.$this->getURI(), 404);
|
||||
$find = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'novembre', 'décembre');
|
||||
$replace = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
|
||||
|
||||
$html = file_get_html($this->getURI()) or $this->returnError('Could not request '.$this->getURI(), 404);
|
||||
|
||||
foreach($html->find('.content-holder') as $contentHolder) {
|
||||
// only use first list as second one only contains pages numbers
|
||||
|
@ -22,10 +25,19 @@ class Sexactu extends BridgeAbstract{
|
|||
// various metadata
|
||||
$titleBlock = $element->find('.title-holder', 0);
|
||||
if(is_object($titleBlock)) {
|
||||
$titleData = $titleBlock->find('.article-title',0)->find('h2', 0)->find('a',0);
|
||||
$item->title = trim($titleData->innertext);
|
||||
$titleDetails = $titleBlock->find('.article-title',0);
|
||||
$titleData = $titleDetails->find('h2', 0)->find('a',0);
|
||||
$titleTimestamp =$titleDetails->find('h4',0);
|
||||
$item->title = $this->correctCase(trim($titleData->innertext));
|
||||
$item->uri = GQ.$titleData->href;
|
||||
|
||||
// Fugly date parsing due to the fact my DNS-323 doesn't support php intl extension
|
||||
$dateText = $titleTimestamp->innertext;
|
||||
$dateText = substr($dateText, strpos($dateText,',')+1);
|
||||
$dateText = str_replace($find, $replace, strtolower($dateText));
|
||||
$date = strtotime($dateText);
|
||||
$item->timestamp = $date;
|
||||
|
||||
$item->name = "Maïa Mazaurette";
|
||||
$elementText = $element->find('.text-container', 0);
|
||||
// don't forget to replace images server url with gq one
|
||||
|
@ -56,8 +68,20 @@ class Sexactu extends BridgeAbstract{
|
|||
public function getDescription(){
|
||||
return "Sexactu via rss-bridge";
|
||||
}
|
||||
|
||||
public function correctCase($str) {
|
||||
$sentences=explode('.', mb_strtolower($str, "UTF-8"));
|
||||
$str="";
|
||||
$sep="";
|
||||
foreach ($sentences as $sentence)
|
||||
{
|
||||
//upper case first char
|
||||
$sentence=ucfirst(trim($sentence));
|
||||
|
||||
//append sentence to output
|
||||
$str=$str.$sep.$sentence;
|
||||
$sep=". ";
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// what did you do Seb ? WHAT DID YOU DO ????
|
||||
// seems like bridge should not incldue php close ?>
|
||||
|
||||
|
|
Loading…
Reference in a new issue