<commit_before><?php
class CollegeDeFranceBridge extends BridgeAbstract{

	public function loadMetadatas() {
		$this->maintainer = "pit-fgfjiudghdf";
		$this->name = "CollegeDeFrance";
		$this->uri = "http://www.college-de-france.fr/";
		$this->description = "Returns the latest audio and video from CollegeDeFrance";
		$this->update = "2016-05-01";
	}

	public function collectData(array $param) {
		$months = array(
			'01' => 'janv.',
			'02' => 'févr.',
			'03' => 'mars',
			'04' => 'avr.',
			'05' => 'mai',
			'06' => 'juin',
			'07' => 'juil.',
			'08' => 'août',
			'09' => 'sept.',
			'10' => 'oct.',
			'11' => 'nov.',
			'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"><NAME></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(){
		return 'CollegeDeFrance';
	}

	public function getURI(){
		return 'http://www.college-de-france.fr/';
	}

	public function getCacheDuration(){
		return 3600*3; // 3 hour
	}
}<commit_msg>Fixed ColledgeDeFrance timezone and a small time parsing issue<commit_after><?php
class CollegeDeFranceBridge extends BridgeAbstract{

	public function loadMetadatas() {
		$this->maintainer = "pit-fgfjiudghdf";
		$this->name = "CollegeDeFrance";
		$this->uri = "http://www.college-de-france.fr/";
		$this->description = "Returns the latest audio and video from CollegeDeFrance";
		$this->update = "2016-05-01";
	}

	public function collectData(array $param) {
		$months = array(
			'01' => 'janv.',
			'02' => 'févr.',
			'03' => 'mars',
			'04' => 'avr.',
			'05' => 'mai',
			'06' => 'juin',
			'07' => 'juil.',
			'08' => 'août',
			'09' => 'sept.',
			'10' => 'oct.',
			'11' => 'nov.',
			'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"><NAME></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">
			//
			// Sometimes there's an __1, perhaps it signifies an update "/site/patrick-boucheron/seminar-2016-05-03-18h00__1.htm"
			//
			// But unfortunately some don't have any hours info
			// <a href="/site/institut-physique/The-Mysteries-of-Decoherence-Sebastien-Gleyzes-[Video-3-35].htm" data-target="after">
			$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
			$d = DateTime::createFromFormat('!Y-m-d-H\hi', substr($element->href, strpos($element->href, '201'), 16), $timezone) or DateTime::createFromFormat('!H m Y', trim(str_replace(array_values($months), array_keys($months), $element->find('.date', 0)->plaintext)), $timezone);
			$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(){
		return 'CollegeDeFrance';
	}

	public function getURI(){
		return 'http://www.college-de-france.fr/';
	}

	public function getCacheDuration(){
		return 3600*3; // 3 hours
	}
}
{'fraction_non_alphanumeric': 0.2024618776410068, 'fraction_numerical': 0.03876538673525629, 'mean_word_length': 3.7796312554872697, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '648092', 'n_tokens_mistral': 2296, 'n_tokens_neox': 1937, 'n_words': 413}