function url_to_download() { $client_info = $_SERVER['HTTP_USER_AGENT']; if (strstr($client_info, 'Windows')) { if (strstr($client_info, 'Win64') || strstr($client_info, 'WOW64')) { return get_download_url('winx64'); } else { return get_download_url('win'); } } else { if (strstr($client_info, 'Mac')) { if (strstr($client_info, 'PPC Mac OS X')) { return get_download_url('macppc'); } else { return get_download_url('mac'); } } else { if (strstr($client_info, 'Linux') && strstr($client_info, 'Android')) { // Check for Android before Linux, // since Android contains the Linux kernel and the // web browser user agent string list Linux too. return get_download_url('androidarm'); } else { if (strstr($client_info, 'Linux')) { if (strstr($client_info, 'x86_64')) { return get_download_url('linuxx64'); } else { return get_download_url('linux'); } } } } } return null; }
case "getParticipatoryLayers": require_once("LayerData.php"); get_participatory_layers(); break; case "getDownloadUrl": if (isset($_REQUEST['layer_tablename'], $_REQUEST['format'])) { $layer_tablename=$_REQUEST['layer_tablename']; $format=$_REQUEST['format']; } else { die(return_error('Required parameters are not set')); } require_once("LayerData.php"); get_download_url($layer_tablename, $format); break; case "getDownloadFormats": if (isset($_REQUEST['layer_tablename'])) { $layer_tablename=$_REQUEST['layer_tablename']; } else { die(return_error('Required parameters are not set')); } require_once("LayerData.php"); get_download_formats($layer_tablename); break; // LayerData.php ends default:
$video_id = substr($video, 0, strpos($video, '?')); } else { $video_id = $video; } if ($video_id === false) { p('Failed to get video id for cast=' . $cast); continue; } $out_name = str_replace(array('series/', 'lessons/'), array('', ''), $cast); $out_file = $directory . '/' . str_pad($video_id, $padding, '0', STR_PAD_LEFT) . '_' . str_replace('/', '_', $out_name) . '.mp4'; if (file_exists($out_file)) { p('File exists for out_file=' . $out_file . ', skipping'); continue; } p('Checking first url before redirection : https://laracasts.com/downloads/' . $video); $url = get_download_url('https://laracasts.com/downloads/' . $video); if ($url === false) { p('Could not get download url for video_id=' . $video_id); continue; } p('Downloading ' . $url . ' to ' . $out_file); $result = download_from_vimeo($out_file, $url); if ($result === false) { p('Failed to get url=' . $url); continue; } p('Success, got video_id=' . $video_id . ', cast=' . $cast); } //functions /* * Authenticates by first call /login, we need to establish