News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

problem while editing the bbc code

Started by djpaddystudio7, March 19, 2008, 06:41:22 PM

Previous topic - Next topic

djpaddystudio7

basically i created a function

download ($variable1, $variable2) in a file called phptube.php

now the function at the end prints a url as


$url = '<a href="'.$url.'"\n">click here to download</a>';
print $url."\n";


now when i use this function a link is  to be printed.

The problem is that i want to display it for a bbc code.
I have included the page phptube.php (source directory) in the index.php


now on the subs.php page i had to write

$tube = new PHPTube ();
$tube->download("$variable1","$variable2");


now the download function prints the link but how do i get it into the content of a tag....

Using the best of my limited knowledge of php all i managed was this...


array(
'tag' => 'yt',
'type' => 'unparsed_commas_content',
'test' => '.+?,.+?]',
'content' => ($context['browser']['is_ie'] && !$context['browser']['is_mac_ie'] ? '<object width="$2" height="$3"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="$2" height="$3"></embed></object>' : '<embed width="$2" height="$3" type="application/x-shockwave-flash" src="http://www.youtube.com/v/$1" /></embed><br> <br>
<img src="http://img.youtube.com/vi/$1/1.jpg"> <img src="http://img.youtube.com/vi/$1/2.jpg"> <img src="http://img.youtube.com/vi/$1/3.jpg">'

download("$1","video.flv"); ),


I am trying to get the link just below the images that are given in the end.

the error that i get is
Parse error: syntax error, unexpected T_STRING in /home/masttinf/public_html/forum/Sources/Subs.php on line 1378

Rumbaar

Not sure what you trying to do with the last BBC array, but the 'content' string isn't valid and is missing a closing bracket.  Also not sure what the download() is doing there.

You might want to take a look how KarlBensons embed video mod works, particularly the YouTube part, and then try and modify to your needs.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

djpaddystudio7

this is the code in the file that defines the function download()



// Function: download  ... Download any Video-Clip from YouTube
// Paramters: $video_id ... Video-ID as given in YouTube URL (f.e. the Video at http://youtube.com/watch?v=TWZ5j-SNVKs
//   has the ID "TWZ5j-SNVKs"
// $video_filename ... local path+filename, the video is downloaded to (check write-permissions!)

function download ($video_id, $video_filename) {
$url = "http://www.youtube.com/watch?v=".$video_id;
$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);
preg_match('/"video_id": "(.*?)"/', $page, $match);
$var_id = $match[1];

preg_match('/"t": "(.*?)"/', $page, $match);
$var_t = $match[1];

$url = "";
$url .= $var_id;
$url .= "&t=";
$url .= $var_t;
$url = "http://www.youtube.com/get_video?video_id=".$url;
$url = '<a href="'.$url.'"\n">click here to download</a>';
if ($this->debug)
print $url."\n";
$req =& new HTTP_Request($url,array ("allowRedirects"=>true, "maxRedirects"=> 99));
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->addHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
$response = $req->sendRequest();
if (PEAR::isError($response)) {
    //echo $response->getMessage()."\n";
print "the video";    
} else {
                if ($o = fopen ($video_filename, "w")) {
fwrite($o,$req->getResponseBody());
fclose ($o);
                    print "the video";
} else {
print "Error: Failed to open target-file\n";
        }
}
}
}



What i am basically trying to do is get a link to download the videos from you tube.

in the above stated code
$url = "http://www.youtube.com/get_video?video_id=".$url;

gives the link value to the string $url. now all i want to do is display this final $url in array function. now for the process to take place, i need to feed the value $video_id that is the first variable in the array for the tag yt.
If possible put these attached file in a folder in a server and then open the file demo.php in a browser. the demo.php file has a sample video_id which it uses to fetch the download link. I hope I am able to make clear what i am trying to do.

Advertisement: