-
Notifications
You must be signed in to change notification settings - Fork 1k
/
PinterestBridge.php
67 lines (58 loc) · 1.81 KB
/
PinterestBridge.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
class PinterestBridge extends FeedExpander
{
const MAINTAINER = 'pauder';
const NAME = 'Pinterest Bridge';
const URI = 'https://www.pinterest.com';
const DESCRIPTION = 'Returns the newest images on a board';
const PARAMETERS = [
'By username and board' => [
'u' => [
'name' => 'username',
'exampleValue' => 'VIGOIndustries',
'required' => true
],
'b' => [
'name' => 'board',
'exampleValue' => 'bathroom-remodels',
'required' => true
]
]
];
public function getIcon()
{
return 'https://s.pinimg.com/webapp/style/images/favicon-9f8f9adf.png';
}
public function collectData()
{
$this->collectExpandableDatas($this->getURI() . '.rss');
$this->fixLowRes();
}
private function fixLowRes()
{
$newitems = [];
$pattern = '/https\:\/\/i\.pinimg\.com\/[a-zA-Z0-9]*x\//';
foreach ($this->items as $item) {
$item['content'] = preg_replace($pattern, 'https://i.pinimg.com/originals/', $item['content']);
$item['enclosures'] = [
$item['uri'],
];
$newitems[] = $item;
}
$this->items = $newitems;
}
public function getURI()
{
if ($this->queriedContext === 'By username and board') {
return self::URI . '/' . urlencode($this->getInput('u')) . '/' . urlencode($this->getInput('b'));
}
return parent::getURI();
}
public function getName()
{
if ($this->queriedContext === 'By username and board') {
return $this->getInput('u') . ' - ' . $this->getInput('b') . ' - ' . self::NAME;
}
return parent::getName();
}
}