[CollegeDeFranceBridge] code simplification
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
7710613e62
commit
58f6a43574
1 changed files with 20 additions and 4 deletions
|
@ -30,7 +30,8 @@ class CollegeDeFranceBridge extends BridgeAbstract{
|
||||||
* </a>
|
* </a>
|
||||||
* </li>
|
* </li>
|
||||||
*/
|
*/
|
||||||
$html = $this->getSimpleHTMLDOM('http://www.college-de-france.fr/components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') or $this->returnServerError('Could not request CollegeDeFrance.');
|
$html = $this->getSimpleHTMLDOM($this->uri.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all')
|
||||||
|
or $this->returnServerError('Could not request CollegeDeFrance.');
|
||||||
foreach($html->find('a[data-target]') as $element) {
|
foreach($html->find('a[data-target]') as $element) {
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['title'] = $element->find('.title', 0)->plaintext;
|
$item['title'] = $element->find('.title', 0)->plaintext;
|
||||||
|
@ -43,10 +44,25 @@ class CollegeDeFranceBridge extends BridgeAbstract{
|
||||||
// <a href="/site/institut-physique/The-Mysteries-of-Decoherence-Sebastien-Gleyzes-[Video-3-35].htm" data-target="after">
|
// <a href="/site/institut-physique/The-Mysteries-of-Decoherence-Sebastien-Gleyzes-[Video-3-35].htm" data-target="after">
|
||||||
$timezone = new DateTimeZone('Europe/Paris');
|
$timezone = new DateTimeZone('Europe/Paris');
|
||||||
// strpos($element->href, '201') will break in 2020 but it'll probably break prior to then due to site changes anyway
|
// strpos($element->href, '201') will break in 2020 but it'll probably break prior to then due to site changes anyway
|
||||||
$d = DateTime::createFromFormat('!Y-m-d-H\hi', substr($element->href, strpos($element->href, '201'), 16), $timezone) ?: DateTime::createFromFormat('!d m Y', trim(str_replace(array_values($months), array_keys($months), $element->find('.date', 0)->plaintext)), $timezone);
|
$d = DateTime::createFromFormat(
|
||||||
|
'!Y-m-d-H\hi',
|
||||||
|
substr($element->href, strpos($element->href, '201'), 16),
|
||||||
|
$timezone
|
||||||
|
);
|
||||||
|
if(!$d){
|
||||||
|
$d=DateTime::createFromFormat(
|
||||||
|
'!d m Y',
|
||||||
|
trim(str_replace(
|
||||||
|
array_values($months),
|
||||||
|
array_keys($months),
|
||||||
|
$element->find('.date', 0)->plaintext
|
||||||
|
)),
|
||||||
|
$timezone
|
||||||
|
);
|
||||||
|
}
|
||||||
$item['timestamp'] = $d->format('U');
|
$item['timestamp'] = $d->format('U');
|
||||||
$item['content'] = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext;
|
$item['content'] = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext;
|
||||||
$item['uri'] = 'http://www.college-de-france.fr' . $element->href;
|
$item['uri'] = $this->uri . $element->href;
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue