2014-01-30 14:55:35 +01:00
|
|
|
<?php
|
2017-04-09 23:26:35 +02:00
|
|
|
class PinterestBridge extends FeedExpander {
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
const MAINTAINER = 'pauder';
|
|
|
|
const NAME = 'Pinterest Bridge';
|
2017-04-09 23:26:35 +02:00
|
|
|
const URI = 'https://www.pinterest.com';
|
2017-02-11 16:16:56 +01:00
|
|
|
const DESCRIPTION = 'Returns the newest images on a board';
|
2016-08-27 21:03:26 +02:00
|
|
|
|
2016-09-17 19:09:33 +02:00
|
|
|
const PARAMETERS = array(
|
|
|
|
'By username and board' => array(
|
|
|
|
'u' => array(
|
|
|
|
'name' => 'username',
|
|
|
|
'required' => true
|
|
|
|
),
|
|
|
|
'b' => array(
|
|
|
|
'name' => 'board',
|
|
|
|
'required' => true
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2018-10-26 18:07:34 +02:00
|
|
|
public function getIcon() {
|
|
|
|
return 'https://s.pinimg.com/webapp/style/images/favicon-9f8f9adf.png';
|
|
|
|
}
|
|
|
|
|
2019-07-06 11:57:48 +02:00
|
|
|
public function collectData() {
|
|
|
|
$this->collectExpandableDatas($this->getURI() . '.rss');
|
|
|
|
$this->fixLowRes();
|
2017-04-09 23:26:35 +02:00
|
|
|
}
|
|
|
|
|
2018-03-06 13:01:48 +01:00
|
|
|
private function fixLowRes() {
|
2017-04-09 23:26:35 +02:00
|
|
|
|
2018-03-06 13:01:48 +01:00
|
|
|
$newitems = [];
|
|
|
|
$pattern = '/https\:\/\/i\.pinimg\.com\/[a-zA-Z0-9]*x\//';
|
|
|
|
foreach($this->items as $item) {
|
2017-04-09 23:26:35 +02:00
|
|
|
|
2018-06-29 23:55:33 +02:00
|
|
|
$item['content'] = preg_replace($pattern, 'https://i.pinimg.com/originals/', $item['content']);
|
2018-03-06 13:01:48 +01:00
|
|
|
$newitems[] = $item;
|
2016-09-17 19:09:33 +02:00
|
|
|
}
|
2018-03-06 13:01:48 +01:00
|
|
|
$this->items = $newitems;
|
|
|
|
|
2017-04-09 23:26:35 +02:00
|
|
|
}
|
2016-09-17 19:09:33 +02:00
|
|
|
|
2019-07-06 11:57:48 +02:00
|
|
|
public function getURI() {
|
2016-09-17 19:09:33 +02:00
|
|
|
|
2019-07-06 11:57:48 +02:00
|
|
|
if ($this->queriedContext === 'By username and board') {
|
|
|
|
return self::URI . '/' . urlencode($this->getInput('u')) . '/' . urlencode($this->getInput('b'));
|
2016-09-17 19:09:33 +02:00
|
|
|
}
|
|
|
|
|
2019-07-06 11:57:48 +02:00
|
|
|
return parent::getURI();
|
2016-09-17 19:09:33 +02:00
|
|
|
}
|
|
|
|
|
2019-07-06 11:57:48 +02:00
|
|
|
public function getName() {
|
|
|
|
|
|
|
|
if ($this->queriedContext === 'By username and board') {
|
|
|
|
return $this->getInput('u') . ' - ' . $this->getInput('b') . ' - ' . self::NAME;
|
2016-09-17 19:09:33 +02:00
|
|
|
}
|
2019-07-06 11:57:48 +02:00
|
|
|
|
|
|
|
return parent::getName();
|
2016-09-17 19:09:33 +02:00
|
|
|
}
|
2014-01-30 14:55:35 +01:00
|
|
|
}
|