diff options
author | 2018-07-16 12:02:41 +0200 | |
---|---|---|
committer | 2018-07-16 12:02:41 +0200 | |
commit | 3f41d0593a740502f7446cf1338b631db198048a (patch) | |
tree | 8bacfb6daf57f597730aa124cad38aa1bd1b90f5 | |
parent | 7126f5e8380f05820d668b2728bf454cc67d9efb (diff) | |
download | rss-bridge-3f41d0593a740502f7446cf1338b631db198048a.tar.gz rss-bridge-3f41d0593a740502f7446cf1338b631db198048a.tar.zst rss-bridge-3f41d0593a740502f7446cf1338b631db198048a.zip |
Added RSS bridge for zenodo.org (#749)
* added RSS bridge for zenodo.org
-rw-r--r-- | bridges/ZenodoBridge.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/bridges/ZenodoBridge.php b/bridges/ZenodoBridge.php new file mode 100644 index 00000000..18ef91cd --- /dev/null +++ b/bridges/ZenodoBridge.php @@ -0,0 +1,55 @@ +<?php +class ZenodoBridge extends BridgeAbstract { + const MAINTAINER = 'theradialactive'; + const NAME = 'Zenodo'; + const URI = 'https://zenodo.org'; + const CACHE_TIMEOUT = 10; + const DESCRIPTION = 'Returns the newest content of Zenodo'; + + public function collectData(){ + $html = getSimpleHTMLDOM($this->getURI()) + or returnServerError('zenodo.org not reachable.'); + + foreach($html->find('div.record-elem') as $element) { + $item = array(); + $item['uri'] = self::URI . $element->find('h4', 0)->find('a', 0)->href; + $item['title'] = trim( + htmlspecialchars_decode($element->find('h4', 0)->find('a', 0)->innertext, + ENT_QUOTES + ) + ); + foreach($element->find('p', 0)->find('span') as $authors) { + $item['author'] = $item['author'] . $authors . '; '; + } + $content = $element->find('p.hidden-xs', 0)->find('a', 0)->innertext . '<br>'; + $type = '<br>Type: ' . $element->find('span.label-default', 0)->innertext; + + $raw_date = $element->find('small.text-muted', 0)->innertext; + $clean_date = date_parse(str_replace('Uploaded on ', '', $raw_date)); + + $content = $content . date_parse($clean_date); + + $item['timestamp'] = mktime( + $clean_date['hour'], + $clean_date['minute'], + $clean_date['second'], + $clean_date['month'], + $clean_date['day'], + $clean_date['year'] + ); + + $access = ''; + if ($element->find('span.label-success', 0)->innertext) { + $access = 'Open Access'; + } elseif ($element->find('span.label-warning', 0)->innertext) { + $access = 'Embargoed Access'; + } else { + $access = $element->find('span.label-error', 0)->innertext; + } + $access = '<br>Access: ' . $access; + $publication = '<br>Publication Date: ' . $element->find('span.label-info', 0)->innertext; + $item['content'] = $content . $type . $access . $publication; + $this->items[] = $item; + } + } +} |