la idea es hacer un grabber para descargar los archivos, con o sin iniciar sesion... como muchas paginas que hay por la red para obtener un video o mp3.
por ahora solo llega a extraer la url... no se porque no puedo descargarlo con curl (se queda congelado o no hace nada)
se que tiene limitacion por ip para llegar al archivo, pero me muestra un error...
The page you are looking for is temporarily unavailable.
Please try again later.
dejo la clase que he preparado por si me podeis ayudar y si no pues para que lo tengan y si os gusta....ya sabeis lo unico que pido es que mantengan nos creditos...
Código PHP:
<?php
/*
Video Streamer version: 1.0.0
Desarrollador: Aleksander Haugas
Copyright: 2013 (c) Aleksander Haugas
*/
class StreamCloud
{
private $username = 'xxxxxx'; //Usuario
private $password = 'xxxxxxxxxxx'; //Password
private $user_agent = '84U645-W4RB0T ("Streamer bot" universal;)'; //User Agent
private $_dev_mode = TRUE; //Modo de desarrollo
public function __construct()
{
//ALGO
}
/**
*generate_post_access
*Se procede a generar la URL para enviar el formulario
*op + usr_login + id + fname + referer + hash + imhuman
*/
public function generate_post_access($url)
{
//Conectamos con el servidor
$this->url = trim($url);
$this->get_url = file_get_contents($this->url);
//Buscamos el formulario y verificamos si existe la id y el valor
preg_match_all('/<input type="hidden" name="(.*?)" value="(.*?)"\>/i', $this->get_url, $input);
$stack = array();
//Creamos las claves y los valores
for($i = 0; $i < count($input[1]); $i++)
{
$stack[$input[1][$i]] = $input[2][$i];
}
//Incrustamos los datos a los ya obtenidas
$submit = array('imhuman' => 'Watch+video+now');
return $result = array_merge($stack, $submit);
}
private function cURL_login_request($url, $post = FALSE, $cookie = FALSE)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent);
if (!$post == false)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if (!$cookie == false)
{
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__). '/temp/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/temp/cookie.txt');
}
if (curl_exec($ch) === FALSE)
{
return array(FALSE, curl_error($ch));
}
else
{
ob_start(); // prevent any output
return array(TRUE, curl_exec($ch));
ob_end_clean(); // stop preventing outp
}
curl_close($ch);
}
/**
*streamers
*La API de descargas permite a terceros generar el enlace directo para las descargas o streaming.
*Las cuentas premium permite solicitar enlaces directos utilizando su ancho de banda.
*/
public function streamers($original_url)
{
if (!$original_url == NULL)
{
$this->original_url = trim($original_url);
//Obtenemos los campos necesarios
$row->introtext = $this->generate_post_access($this->original_url);
//Enviamos los datos
$direct_down = $this->cURL_login_request($this->url, $row->introtext, true);
//Obtenemos la url del archivo
preg_match('/ *file: " *["\']?([^"\']*)/i', $direct_down[1], $matches);
return $this->cURL_login_request($matches[1]);
}
//return....
return false;
}
}
/*
* Fin de la clase
*/
?>