Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
[PicalaBridge] Add new bridge (RSS-Bridge#2646)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chouchen authored and Kwbmm committed Jun 17, 2022
1 parent 608b3b3 commit 9166d70
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions bridges/PicalaBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

class PicalaBridge extends BridgeAbstract {
const TYPES = array(
'Actualités' => 'actualites',
'Économie' => 'economie',
'Tests' => 'tests',
'Pratique' => 'pratique',
);
const NAME = 'Picala Bridge';
const URI = 'https://www.picala.fr';
const DESCRIPTION = 'Dernière nouvelles du média indépendant sur le vélo électrique';
const MAINTAINER = 'Chouchen';
const PARAMETERS = array(
array(
'type' => array(
'name' => 'Type',
'type' => 'list',
'values' => self::TYPES,
),
),
);

public function getURI() {
if(!is_null($this->getInput('type'))) {
return sprintf('%s/%s', static::URI, $this->getInput('type'));
}

return parent::getURI();
}

public function getIcon() {
return 'https://picala-static.s3.amazonaws.com/static/img/favicon/favicon-32x32.png';
}

public function getDescription() {
if(!is_null($this->getInput('type'))) {
return sprintf('%s - %s', static::DESCRIPTION, array_search($this->getInput('type'), self::TYPES));
}

return parent::getDescription();
}

public function getName() {
if(!is_null($this->getInput('type'))) {
return sprintf('%s - %s', static::NAME, array_search($this->getInput('type'), self::TYPES));
}

return parent::getName();
}

public function collectData() {
$fullhtml = getSimpleHTMLDOM($this->getURI());
foreach($fullhtml->find('.list-container-category a') as $article) {
$srcsets = explode(',', $article->find('img', 0)->getAttribute('srcset'));
$image = explode(' ', trim(array_shift($srcsets)))[0];

$item = array();
$item['uri'] = self::URI . $article->href;
$item['title'] = $article->find('h2', 0)->plaintext;
$item['content'] = sprintf(
'<img src="%s" /><br>%s',
$image,
$article->find('.teaser__text', 0)->plaintext
);
$this->items[] = $item;
}
}
}

0 comments on commit 9166d70

Please sign in to comment.