Fix up CollegeDeFranceBridge
The site changed.
This commit is contained in:
parent
99b7d2e6b4
commit
de4952d31f
1 changed files with 52 additions and 31 deletions
|
@ -2,41 +2,62 @@
|
||||||
class CollegeDeFranceBridge extends BridgeAbstract{
|
class CollegeDeFranceBridge extends BridgeAbstract{
|
||||||
|
|
||||||
public function loadMetadatas() {
|
public function loadMetadatas() {
|
||||||
|
|
||||||
$this->maintainer = "pit-fgfjiudghdf";
|
$this->maintainer = "pit-fgfjiudghdf";
|
||||||
$this->name = "CollegeDeFrance";
|
$this->name = "CollegeDeFrance";
|
||||||
$this->uri = "http://www.college-de-france.fr/";
|
$this->uri = "http://www.college-de-france.fr/";
|
||||||
$this->description = "Returns the 10 newest posts from CollegeDeFrance";
|
$this->description = "Returns the latest audio and video from CollegeDeFrance";
|
||||||
$this->update = "2014-05-26";
|
$this->update = "2016-05-01";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param) {
|
||||||
$find = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'novembre', 'décembre');
|
$months = array(
|
||||||
$replace = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
|
'01' => 'janv.',
|
||||||
$html = file_get_html('http://www.college-de-france.fr/site/audio-video/_audiovideos.jsp?index=0&prompt=&fulltextdefault=mots-cles...&fulltext=mots-cles...&fields=TYPE2_ACTIVITY&fieldsdefault=0_0&TYPE2=0') or $this->returnError('Could not request CollegeDeFrance.', 404);
|
'02' => 'févr.',
|
||||||
$limit = 0;
|
'03' => 'mars',
|
||||||
foreach($html->find('li.audio') as $element) {
|
'04' => 'avr.',
|
||||||
if($limit < 10) {
|
'05' => 'mai',
|
||||||
$item = new \Item();
|
'06' => 'juin',
|
||||||
$item->title = $element->find('span.title', 0)->plaintext;
|
'07' => 'juil.',
|
||||||
$item->timestamp = strtotime(str_replace($find, $replace, $element->find('span.date', 0)->plaintext));
|
'08' => 'août',
|
||||||
$item->content = $element->find('span.lecturer', 0)->innertext . ' - ' . $element->find('span.title', 0)->innertext;
|
'09' => 'sept.',
|
||||||
$item->uri = $element->find('a', 0)->href;
|
'10' => 'oct.',
|
||||||
$this->items[] = $item;
|
'11' => 'nov.',
|
||||||
$limit++;
|
'12' => 'déc.'
|
||||||
}
|
);
|
||||||
}
|
// The "API" used by the site returns a list of partial HTML in this form
|
||||||
|
/* <li>
|
||||||
|
* <a href="/site/thomas-romer/guestlecturer-2016-04-15-14h30.htm" data-target="after">
|
||||||
|
* <span class="date"><span class="list-icon list-icon-video"></span><span class="list-icon list-icon-audio"></span>15 avr. 2016</span>
|
||||||
|
* <span class="lecturer">Christopher Hays</span>
|
||||||
|
* <span class='title'>Imagery of Divine Suckling in the Hebrew Bible and the Ancient Near East</span>
|
||||||
|
* </a>
|
||||||
|
* </li>
|
||||||
|
*/
|
||||||
|
$html = file_get_html('http://www.college-de-france.fr/components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') or $this->returnError('Could not request CollegeDeFrance.', 404);
|
||||||
|
foreach($html->find('a[data-target]') as $element) {
|
||||||
|
$item = new \Item();
|
||||||
|
$item->title = $element->find('.title', 0)->plaintext;
|
||||||
|
// Most relative URLs contains an hour in addition to the date, so let's use it
|
||||||
|
// <a href="/site/yann-lecun/course-2016-04-08-11h00.htm" data-target="after">
|
||||||
|
// But unfortunately some don't
|
||||||
|
// <a href="/site/institut-physique/The-Mysteries-of-Decoherence-Sebastien-Gleyzes-[Video-3-35].htm" data-target="after">
|
||||||
|
$d = DateTime::createFromFormat('!Y-m-d-H\hi', substr($element->href, -20, -4)) ?: DateTime::createFromFormat('!H m Y', str_replace(array_values($months), array_keys($months), $element->find('.date', 0)->innertext));
|
||||||
|
$item->timestamp = $d->format('U');
|
||||||
|
$item->content = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext;
|
||||||
|
$item->uri = 'http://www.college-de-france.fr' . $element->href;
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public function getName(){
|
||||||
public function getName(){
|
return 'CollegeDeFrance';
|
||||||
return 'CollegeDeFrance';
|
}
|
||||||
}
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
return 'http://www.college-de-france.fr/';
|
return 'http://www.college-de-france.fr/';
|
||||||
}
|
}
|
||||||
public function getCacheDuration(){
|
|
||||||
return 3600*3; // 3 hour
|
public function getCacheDuration(){
|
||||||
}
|
return 3600*3; // 3 hour
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue