forked from blallo/rss-bridge
Update Flickr Bridge
Fix the bridge (Flickr update?) I get the pictures titles with the API (slowing down the bridge). If you have any suggestions to replace them, feel free to change it.
This commit is contained in:
parent
a5b8c8d422
commit
d60a822bc2
1 changed files with 22 additions and 9 deletions
|
@ -5,21 +5,34 @@ class FlickrExploreBridge extends BridgeAbstract{
|
|||
|
||||
$this->maintainer = "sebsauvage";
|
||||
$this->name = "Flickr Explore";
|
||||
$this->uri = "http://www.flickr.com/explore";
|
||||
$this->uri = "https://www.flickr.com/explore";
|
||||
$this->description = "Returns the latest interesting images from Flickr";
|
||||
$this->update = "2014-05-25";
|
||||
$this->update = "2016-07-30";
|
||||
|
||||
}
|
||||
|
||||
public function collectData(array $param){
|
||||
$html = $this->file_get_html('http://www.flickr.com/explore') or $this->returnError('Could not request Flickr.', 404);
|
||||
$html = $this->file_get_html('https://www.flickr.com/explore') or $this->returnError('Could not request Flickr.', 404);
|
||||
|
||||
foreach($html->find('.photo-list-photo-view') as $element) {
|
||||
// Get the styles
|
||||
$style = explode(';', $element->style);
|
||||
// Get the background-image style
|
||||
$backgroundImage = explode(':', end($style));
|
||||
// URI type : url(//cX.staticflickr.com/X/XXXXX/XXXXXXXXX.jpg)
|
||||
$imageURI = trim(str_replace(['url(', ')'], '', end($backgroundImage)));
|
||||
// Get the image ID
|
||||
$imageURIs = explode('_', basename($imageURI));
|
||||
$imageID = reset($imageURIs);
|
||||
|
||||
// Get the image JSON via Flickr API
|
||||
$imageJSON = json_decode(file_get_contents('https://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=103b574d49bd51f0e18bfe907da44a0f&photo_id='.$imageID.'&format=json&nojsoncallback=1')) or $this->returnError('Could not request Flickr.', 404); // FIXME: Request time too long...
|
||||
|
||||
foreach($html->find('span.photo_container') as $element) {
|
||||
$item = new \Item();
|
||||
$item->uri = 'http://flickr.com'.$element->find('a',0)->href;
|
||||
$item->thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src');
|
||||
$item->uri = 'https://flickr.com/photo.gne?id='.$imageID;
|
||||
$item->thumbnailUri = $imageURI;
|
||||
$item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a>'; // FIXME: Filter javascript ?
|
||||
$item->title = $element->find('a',0)->title;
|
||||
$item->title = $imageJSON->photo->title->_content;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +42,7 @@ class FlickrExploreBridge extends BridgeAbstract{
|
|||
}
|
||||
|
||||
public function getURI(){
|
||||
return 'http://www.flickr.com/explore';
|
||||
return 'https://www.flickr.com/explore';
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
|
|
Loading…
Reference in a new issue