Ok Guys,
sorry didn't get what I had up to you yesterday.
I got side tracked with one of my other websites... Had a security issue.
Here is the short and simple of it.
I've just put it all in one script, this does NOT include integration with PHPMotion.
I tried but having problems inserting into the DB.
Inmotion, need to chat with you about how certain vars are passed on that.
Anyway, you put the YouTube URL into the box hit submit and it starts downloading to your server.
There is NO NEED for conversion as the files area already FLV. All you need to do is workout
the DB insert and it should work. No progress bar integration yet.
I've modded 2 template files and will post here later.
Like I said, this is NOT a finished product but will give you a start if you want to work on it yourself.
The transfer from youtube to your server is working, the DB insert, and thumb creation are not working.
Utor Procul Vestri Own Periculum - Use At Your Own Risk
send questions to admin at sensibleads dot com
Chris
OH, one more thing...
The URL from youtube needs to be the one that looks like this...
http://www.youtube.com/watch?v=dss3diPMvnkIt's the one that is above the EMBED code.
<?php
include_once ("classes/config.php");
include_once ('classes/login_check.php');
include_once ('classes/menu.php');
include_once ('classes/sessions.php');
$sid = urlencode(uniqid(rand()));
//This part is the submission form... works, but I am calling this script from another page.
echo"
<form method=post>
Enter Url <input type=text name=newurl size=71><input type=hidden name=sub value=1><input type=submit value=Submit name=B1>
</form>";
$form_submitted = $_POST['form_submitted'];//check if form has been submitted
$title = $_POST['title'];
$description = $_POST['description'];
$tags = $_POST['tags'];
$date_uploaded = $_POST["date_format"];
$location_recorded = $_POST["location_recorded"];
$allow_comments = $_POST['allow_comments'];
$allow_embedding = $_POST['allow_embedding'];
$public_private = $_POST['public_private'];
$channel = $_POST['channel'];
$procede = true;
//Added for this scripts
$chk = $_POST['chk'];
$sub = $_POST['sub'];
if($sub > 0) {
//You need to have pear installed with the following mods
require_once 'HTTP/Request.php';
require_once 'HTTP/Client/CookieManager.php';
require_once 'HTTP/Client.php';
function download ($video_id, $video_filename) {
$url = $_POST["newurl"];
$this->req =& new HTTP_Request($url);
$response = $this->req->sendRequest();
if (PEAR::isError($response)) {
echo $response->getMessage()."\n";
} else {
$page = $this->req->getResponseBody();
preg_match('/watch_fullscreen\?video_id=(.*?)&l=(.*?)+&t=(.*?)&/', $page, $match);
$url = "";
$url .= $match[1];
$url .= "&t=";
$url .= $match[3];
$url = "http://www.youtube.com/get_video?video_id=".$url;
if ($this->debug)
print $url."\n";
if ($h = fopen ($url,"r")) {
if ($o = fopen ($video_filename, "w")) {
while (fwrite($o,fread($h,1024)));
fclose ($o);
print "Download done! File: ".$video_filename."\n";
//DB INSERT.. Not working correctly
$sql = "insert into videos values('$video_id','$title','$description','$tags','$channel','0','$date_uploaded','$location_recorded','$video_legnth','$allow_comments','$allow_embedding','$allow_ratings','0','0','0','$public_private','0','yes','0','$user_id','no')";
$result1 = mysql_query($sql);
$output_file = $base_path . '/uploads/thumbs/' . $video_filename .'.jpg';
//don't have this part working either but am working on it.
//IMPORTANT: if your thumbs ar enot being created, try change "mjpeg" below to "image2"
$ffmpeg_cmd2 = "/usr/local/bin/ffmpeg -i $new_flv -ss $thumb_position -t 00:00:01 -s 120x90 -r 1 -f mjpeg $output_file";
//execute and record output to variable
@exec("$ffmpeg_cmd2 2>&1", $output);
} else {
print "Error: Failed to open target-file\n";
}
fclose ($h);
} else {
print "Error: Failed to open YouTube-Source\n";
}
}
}
}
$sid = md5(uniqid(rand()));
//Initiates the download function
download("$_POST[newurl]","$sid.flv");
?>