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