Author Topic: Youtube videos import  (Read 11689 times)

enzofsilva

  • Newbie
  • *
  • Posts: 2
Youtube videos import
« on: August 07, 2007, 10:35:24 PM »
Would it be possible ,if not possible yet, to do something similar to what www.phpdirector.co.uk does: import (or embed) Youtube videos (and others) with all the info from the videos?
Thanks.

cosminghiu

  • Newbie
  • *
  • Posts: 27
Re: Youtube videos import
« Reply #1 on: August 14, 2007, 08:00:20 AM »
--
i was actually searching for a script that can import videos from youtube and/or metacafe, etc. directly into PHPmotion.

This way we can have a tool that can automatically add video content based on keywords directly from a video sharing site.

right now, i upload them 1 by 1 using a tool like: http://javimoya.com/blog/youtube_en.php

... but it gets tough when you have to do it manually :)

enzofsilva

  • Newbie
  • *
  • Posts: 2
Re: Youtube videos import
« Reply #2 on: August 14, 2007, 12:04:09 PM »
would it take a lot of development to create a tool that adds to PHPMotion the same functionalities of  PHPDirector (mentioned on my first post here)?

deathcat

  • Newbie
  • *
  • Posts: 47
Re: Youtube videos import
« Reply #3 on: August 15, 2007, 12:48:44 AM »
im after this feature but i would like it so that when you click on the videos it does not load thesite it orginated from.

ozarkfisherman

  • Newbie
  • *
  • Posts: 18
Re: Youtube videos import
« Reply #4 on: August 20, 2007, 10:38:56 AM »
add me to the list of "Me toos"
I'd like to have this feature.


ozarkfisherman

  • Newbie
  • *
  • Posts: 18
Re: Youtube videos import
« Reply #5 on: August 20, 2007, 12:02:15 PM »
Hey Guys,

I think I got it. Let me run some testing here and I'll post back in a bit.


ozarkfisherman

  • Newbie
  • *
  • Posts: 18
Re: Youtube videos import
« Reply #6 on: August 20, 2007, 01:52:16 PM »
It's being a biotch but is coming along.
Running into errors occasionally when loading actual video from youtube...

I'm gonna have to do a better preg_match() or something with the URL.
I think it's screwing up somewhere in here:

?video_id=([^\&]+)\&[^\&]+\&t=([^"]+)"~i'

any ideas?

inmotion

  • Administrator
  • Hero Member
  • *****
  • Posts: 2788
  • PHPmotion Developer
    • PHPmotion Demo
Re: Youtube videos import
« Reply #7 on: August 21, 2007, 06:24:17 AM »
 ;D the fun filled world of regex's ......

ozarkfisherman

  • Newbie
  • *
  • Posts: 18
Re: Youtube videos import
« Reply #8 on: August 21, 2007, 07:16:06 AM »
OK guys,
Script working now, just need to integrate into PHPmotion now.
Give me a bit and I'll post some code :)

PM Me for a sample of what I have so far if interested.

Chris
http://www.MyViralTv.com
« Last Edit: August 21, 2007, 07:32:43 AM by ozarkfisherman »

inmotion

  • Administrator
  • Hero Member
  • *****
  • Posts: 2788
  • PHPmotion Developer
    • PHPmotion Demo
Re: Youtube videos import
« Reply #9 on: August 21, 2007, 08:44:49 AM »
Chris,

can you email me your code so i can take a look

ozarkfisherman

  • Newbie
  • *
  • Posts: 18
Re: Youtube videos import
« Reply #10 on: August 21, 2007, 09:11:21 AM »
Yeah, gimme a few I'm almost done.  ;D

cyberdog

  • Newbie
  • *
  • Posts: 23
Re: Youtube videos import
« Reply #11 on: August 22, 2007, 12:37:54 AM »
wow..
i'm really getting excited of this.

ozarkfisherman

  • Newbie
  • *
  • Posts: 18
Re: Youtube videos import
« Reply #12 on: August 22, 2007, 12:40:36 PM »
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=dss3diPMvnk

It's the one that is above the EMBED code.


Code: [Select]
<?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");

?>
« Last Edit: August 22, 2007, 01:11:54 PM by ozarkfisherman »

ozarkfisherman

  • Newbie
  • *
  • Posts: 18
Re: Youtube videos import
« Reply #13 on: August 22, 2007, 01:08:19 PM »
OH, one more thing...

The URL from youtube needs to be the one that looks like this...

http://www.youtube.com/watch?v=dss3diPMvnk

It's the one that is above the EMBED code.

cyberdog

  • Newbie
  • *
  • Posts: 23
Re: Youtube videos import
« Reply #14 on: August 23, 2007, 09:35:11 AM »
i hope someone can help us out here..