mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-29 14:48:52 +03:00
[InstructablesBridge] Fix after layout changes
This commit is contained in:
parent
d324aa5da1
commit
60c1339612
1 changed files with 38 additions and 33 deletions
|
@ -215,7 +215,7 @@ class InstructablesBridge extends BridgeAbstract {
|
|||
),
|
||||
),
|
||||
'title' => 'Select your category (required)',
|
||||
'defaultValue' => 'Technology'
|
||||
'defaultValue' => 'Circuits'
|
||||
),
|
||||
'filter' => array(
|
||||
'name' => 'Filter',
|
||||
|
@ -233,43 +233,44 @@ class InstructablesBridge extends BridgeAbstract {
|
|||
)
|
||||
);
|
||||
|
||||
private $uri;
|
||||
|
||||
public function collectData() {
|
||||
// Enable the following line to get the category list (dev mode)
|
||||
// $this->listCategories();
|
||||
|
||||
$this->uri = static::URI;
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Error loading category ' . $this->getURI());
|
||||
$html = defaultLinkTo($html, $this->getURI());
|
||||
|
||||
switch($this->queriedContext) {
|
||||
case 'Category': $this->uri .= $this->getInput('category') . $this->getInput('filter');
|
||||
}
|
||||
$covers = $html->find('
|
||||
.category-projects-list > div,
|
||||
.category-landing-projects-list > div,
|
||||
');
|
||||
|
||||
$html = getSimpleHTMLDOM($this->uri)
|
||||
or returnServerError('Error loading category ' . $this->uri);
|
||||
|
||||
foreach($html->find('ul.explore-covers-list li') as $cover) {
|
||||
foreach($covers as $cover) {
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = static::URI . $cover->find('a.cover-image', 0)->href;
|
||||
$item['title'] = $cover->find('.title', 0)->innertext;
|
||||
$item['uri'] = $cover->find('a.ible-title', 0)->href;
|
||||
$item['title'] = $cover->find('a.ible-title', 0)->innertext;
|
||||
$item['author'] = $this->getCategoryAuthor($cover);
|
||||
$item['content'] = '<a href='
|
||||
. $item['uri']
|
||||
. '><img src='
|
||||
. $cover->find('a.cover-image img', 0)->src
|
||||
. $cover->find('img', 0)->getAttribute('data-src')
|
||||
. '></a>';
|
||||
|
||||
$image = str_replace('.RECTANGLE1', '.LARGE', $cover->find('a.cover-image img', 0)->src);
|
||||
$item['enclosures'] = [$image];
|
||||
$item['enclosures'][] = str_replace(
|
||||
'.RECTANGLE1',
|
||||
'.LARGE',
|
||||
$cover->find('img', 0)->getAttribute('data-src')
|
||||
);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
if(!is_null($this->getInput('category'))
|
||||
&& !is_null($this->getInput('filter'))) {
|
||||
switch($this->queriedContext) {
|
||||
case 'Category': {
|
||||
foreach(self::PARAMETERS[$this->queriedContext]['category']['values'] as $key => $value) {
|
||||
$subcategory = array_search($this->getInput('category'), $value);
|
||||
|
||||
|
@ -283,15 +284,19 @@ class InstructablesBridge extends BridgeAbstract {
|
|||
);
|
||||
|
||||
return $subcategory . ' (' . $filter . ') - ' . static::NAME;
|
||||
} break;
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
if(!is_null($this->getInput('category'))
|
||||
&& !is_null($this->getInput('filter'))) {
|
||||
return $this->uri;
|
||||
switch($this->queriedContext) {
|
||||
case 'Category': {
|
||||
return self::URI
|
||||
. $this->getInput('category')
|
||||
. $this->getInput('filter');
|
||||
} break;
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
|
@ -349,9 +354,9 @@ class InstructablesBridge extends BridgeAbstract {
|
|||
*/
|
||||
private function getCategoryAuthor($cover) {
|
||||
return '<a href='
|
||||
. static::URI . $cover->find('span.author a', 0)->href
|
||||
. $cover->find('.ible-author a', 0)->href
|
||||
. '>'
|
||||
. $cover->find('span.author a', 0)->innertext
|
||||
. $cover->find('.ible-author a', 0)->innertext
|
||||
. '</a>';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue