Bunu birkaç ay önce ihtiyaç için hazırlamıştım. İşe yarar düşüncesiyle paylaşıyorum. Korfezvideo.com adresindeki konu anlatım vidyolarının vimeo veya direkt linklerini çeker.

Bu arada, bu vidyoları bilgisayarlarınızda barındırmanız yasak. Biz sadece öğrenmek amaçlı linkleri çekiyoruz. Vidyoları değil.

<?php

set_time_limit(0);
error_reporting(E_ALL);
ini_set('max_execution_time', '');
header('Content-Type: text/html; charset=utf-8');

while (@ob_end_clean());
@ob_start();

$lessons = array(
	1 => 'LYS - TÜRKÇE',
	'LYS - TARİH',
	'LYS - COĞRAFYA',
	'LYS - FELSEFE',
	'LYS - MATEMATİK',
	'LYS - GEOMETRİ',
	'LYS - FİZİK',
	'LYS - KİMYA',
	'LYS - BİYOLOJİ',
);

$curl = curl_init();
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/korfex_cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/korfex_cookie.txt');
curl_setopt($curl, CURLOPT_URL, 'http://www.korfezvideo.com/index/kul-log.php');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array(
	'txtMail' => 'EPOSTA ADRESİNİZ',
	'txtSifre' => 'ŞİFRENİZ',
)));
curl_exec($curl);

foreach ($lessons as $id_lesson => $lesson)
{
	echo '
', $lesson, '<br />';
	@ob_flush();
	@flush();

	curl_setopt($curl, CURLOPT_URL, 'http://www.korfezvideo.com/index/k-konular.php?derskodu=' . $id_lesson);
	$data = curl_exec($curl);

	preg_match_all('~obj\.options\[obj\.options\.length\]\s*=\s*new\s*Option\(\'([^\']+)\',\'([^\']+)\'\);~', $data, $subjects, PREG_SET_ORDER);

	foreach ($subjects as &$subject)
	{
		echo '
	',iconv('ISO-8859-9', 'UTF-8', $subject[1]), '<br />';
		@ob_flush();
		@flush();

		curl_setopt($curl, CURLOPT_URL, 'http://www.korfezvideo.com/index/k-bolumler.php?konukodu=' . $subject[2] . '&derskodu=' . $id_lesson);
		$data = curl_exec($curl);

		preg_match_all('~obj\.options\[obj\.options\.length\]\s*=\s*new\s*Option\(\'([^\']+)\',\'([^\']+)\'\);~', $data, $subject['parts'], PREG_SET_ORDER);

		foreach ($subject['parts'] as $part)
		{
			curl_setopt($curl, CURLOPT_URL, 'http://www.korfezvideo.com/index/k-VBank.php?id=' . $part[2]);
			$data = curl_exec($curl);

			//if (strpos($data, 'vimeo.com'))
			$flv = preg_match('~<iframe src="([^"]+)"[^>]+>~', $data, $m) ? substr($m[1], 0, -strlen('?title=0&byline=0&portrait=0')) : (preg_match('~<embed.+?flashvars="([^"]+)"[^>]*>~sm', $data, $m2) ? 'http://www.korfezvideo.com' . substr(str_replace('.flv&wid', '.flv', $m2[1]), 7, -strlen('&width=640&height=500&image=reklamlar/4/11-4.jpg')) : '');

			echo '
		', iconv('ISO-8859-9', 'UTF-8', $part[1]), ' - ', $flv, '<br />';

			@ob_flush();
			@flush();
		}
	}
	echo '<hr>';
}


curl_close($curl);

?>