aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joseph <joseph@verifiedjoseph.com> 2019-07-06 09:57:48 +0000
committerGravatar LogMANOriginal <LogMANOriginal@users.noreply.github.com> 2019-07-06 11:57:48 +0200
commit41a8eb74a1ec4d7bc514f122025e31ca902c9af3 (patch)
treeb68c90bc5beaa75a215fa033c40c89a52ef28b81
parent7e6c58b67a6ef6b3cd6aaca109e1bcf245f52e57 (diff)
downloadrss-bridge-41a8eb74a1ec4d7bc514f122025e31ca902c9af3.tar.gz
rss-bridge-41a8eb74a1ec4d7bc514f122025e31ca902c9af3.tar.zst
rss-bridge-41a8eb74a1ec4d7bc514f122025e31ca902c9af3.zip
[PinterestBridge] Remove search (#1206)
* Remove getSearchResults() * Remove ''From search' from PARAMETERS array * Update getURI() and getName() * Update collectData() * Add '.rss' to URL in `collectData` instead of in `getURI`
-rw-r--r--bridges/PinterestBridge.php90
1 files changed, 13 insertions, 77 deletions
diff --git a/bridges/PinterestBridge.php b/bridges/PinterestBridge.php
index 2917b267..3e518634 100644
--- a/bridges/PinterestBridge.php
+++ b/bridges/PinterestBridge.php
@@ -16,12 +16,6 @@ class PinterestBridge extends FeedExpander {
'name' => 'board',
'required' => true
)
- ),
- 'From search' => array(
- 'q' => array(
- 'name' => 'Keyword',
- 'required' => true
- )
)
);
@@ -29,17 +23,9 @@ class PinterestBridge extends FeedExpander {
return 'https://s.pinimg.com/webapp/style/images/favicon-9f8f9adf.png';
}
- public function collectData(){
- switch($this->queriedContext) {
- case 'By username and board':
- $this->collectExpandableDatas($this->getURI() . '.rss');
- $this->fixLowRes();
- break;
- case 'From search':
- default:
- $html = getSimpleHTMLDOMCached($this->getURI());
- $this->getSearchResults($html);
- }
+ public function collectData() {
+ $this->collectExpandableDatas($this->getURI() . '.rss');
+ $this->fixLowRes();
}
private function fixLowRes() {
@@ -55,71 +41,21 @@ class PinterestBridge extends FeedExpander {
}
- private function getSearchResults($html){
- $json = json_decode($html->find('#jsInit1', 0)->innertext, true);
- $results = $json['resourceDataCache'][0]['data']['results'];
-
- foreach($results as $result) {
- $item = array();
-
- $item['uri'] = self::URI . $result['board']['url'];
-
- // Some use regular titles, others provide 'advanced' infos, a few
- // provide even less info. Thus we attempt multiple options.
- $item['title'] = trim($result['title']);
-
- if($item['title'] === '')
- $item['title'] = trim($result['rich_summary']['display_name']);
+ public function getURI() {
- if($item['title'] === '')
- $item['title'] = trim($result['grid_description']);
-
- $item['timestamp'] = strtotime($result['created_at']);
- $item['username'] = $result['pinner']['username'];
- $item['fullname'] = $result['pinner']['full_name'];
- $item['avatar'] = $result['pinner']['image_small_url'];
- $item['author'] = $item['username'] . ' (' . $item['fullname'] . ')';
- $item['content'] = '<img align="left" style="margin: 2px 4px;" src="'
- . htmlentities($item['avatar'])
- . '" /><p><strong>'
- . $item['username']
- . '</strong><br>'
- . $item['fullname']
- . '</p><br><img src="'
- . $result['images']['736x']['url']
- . '" alt="" /><br><p>'
- . $result['description']
- . '</p>';
-
- $item['enclosures'] = array($result['images']['orig']['url']);
-
- $this->items[] = $item;
+ if ($this->queriedContext === 'By username and board') {
+ return self::URI . '/' . urlencode($this->getInput('u')) . '/' . urlencode($this->getInput('b'));
}
- }
- public function getURI(){
- switch($this->queriedContext) {
- case 'By username and board':
- $uri = self::URI . '/' . urlencode($this->getInput('u')) . '/' . urlencode($this->getInput('b'));// . '.rss';
- break;
- case 'From search':
- $uri = self::URI . '/search/?q=' . urlencode($this->getInput('q'));
- break;
- default: return parent::getURI();
- }
- return $uri;
+ return parent::getURI();
}
- public function getName(){
- switch($this->queriedContext) {
- case 'By username and board':
- $specific = $this->getInput('u') . ' - ' . $this->getInput('b');
- break;
- case 'From search':
- $specific = $this->getInput('q');
- break;
- default: return parent::getName();
+ public function getName() {
+
+ if ($this->queriedContext === 'By username and board') {
+ return $this->getInput('u') . ' - ' . $this->getInput('b') . ' - ' . self::NAME;
}
- return $specific . ' - ' . self::NAME;
+
+ return parent::getName();
}
}