mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-23 10:05:32 +03:00
c6ce453c47
This commit fixes DOM changes reported via #436 New DOM introduced via https://blog.mixcloud.com/2017/01/10/take-a-look-at-the-new-and-improved-mixcloud/
52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
class MixCloudBridge extends BridgeAbstract {
|
|
|
|
const MAINTAINER = 'Alexis CHEMEL';
|
|
const NAME = 'MixCloud';
|
|
const URI = 'https://mixcloud.com/';
|
|
const CACHE_TIMEOUT = 3600; // 1h
|
|
const DESCRIPTION = 'Returns latest musics on user stream';
|
|
|
|
const PARAMETERS = array(array(
|
|
'u' => array(
|
|
'name' => 'username',
|
|
'required' => true,
|
|
)
|
|
));
|
|
|
|
public function getName(){
|
|
if(!is_null($this->getInput('u'))){
|
|
return 'MixCloud - ' . $this->getInput('u');
|
|
}
|
|
|
|
return parent::getName();
|
|
}
|
|
|
|
public function collectData(){
|
|
|
|
$html = getSimpleHTMLDOM(self::URI . $this->getInput('u'))
|
|
or returnServerError('Could not request MixCloud.');
|
|
|
|
foreach($html->find('section.card') as $element){
|
|
|
|
$item = array();
|
|
|
|
$item['uri'] = self::URI . $element->find('hgroup.card-title h1 a', 0)->getAttribute('href');
|
|
$item['title'] = html_entity_decode(
|
|
$element->find('hgroup.card-title h1 a span', 0)->getAttribute('title'),
|
|
ENT_QUOTES
|
|
);
|
|
|
|
$image = $element->find('a.album-art img', 0);
|
|
|
|
if($image){
|
|
$item['content'] = '<img src="' . $image->getAttribute('src') . '" />';
|
|
}
|
|
|
|
$item['author'] = trim($element->find('hgroup.card-title h2 a', 0)->innertext);
|
|
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
}
|