help me to download a video url usin this coding

Started on the old forum in March 2012 · view the original in the archive · old links redirect here

2 replies · 530 views · started 14 years ago · 1 min read

3 participants
Lue_chin Developer · 107 posts #1

hello friends i have a code

<?php
function getContent($url) {
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_HEADER, 0);

    ob_start();
    curl_exec ($ch);
    curl_close ($ch);
    $string = ob_get_contents();
    ob_end_clean();
    return $string;    
}
function fetch_headers($url) {
	$headers = array();
	$url = trim($url);

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, 1);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_NOBODY ,1);
	$data = curl_exec($ch);
	$errormsg = curl_error($ch);
	curl_close($ch);
					
	$headers = explode("\n", $data);
	return $headers;
}
function getYoutubeToken($id) {
	$path = "http://www.youtube.com/get_video_info?";
	$cont = getContent($path."&video_id=".$id);
	parse_str($cont, $opts);
	return $opts['token'];
}

$videoItem = trim($_GET['item']);
$videoType = "";
$videoPath = "http://www.youtube.com/get_video";

if ($_GET['type'] != "0") {
	$videoType = "&fmt=".$_GET['type'];
}
if ($videoItem != "") {
	$videoTokn = getYoutubeToken($videoItem);
	$videoURL = $videoPath."?video_id=".$videoItem."&t=".$videoTokn.$videoType;
	$headers = fetch_headers($videoURL);
	for ($i=0; $i<count($headers); $i++) {
		if (strstr($headers[$i], "ocation:")) {
			$str1 = explode("ocation:", $headers[$i]);
			$link = trim($str1[1]);
			break;
		}
	}
	
	$vn=rand(0,9999);
	
	if($_GET['type']==17){
		header("Content-Type: video/3gp");   
        header("Content-Disposition: attachment; filename=\"$vn.3gp\""); 
	}
	else if($_GET['type']==18){
		header("Content-Type: video/mp4");   
        header("Content-Disposition: attachment; filename=\"$vn.mp4\"");
	}
	else{
		header("Content-Type: video/x-flv");   
        header("Content-Disposition: attachment; filename=\"$vn.flv\"");
	}

		readfile($link);
    	flush();
    	exit();
}
?>

and i want to fix this code with another url for ex:the video is downloading with my url and not store in my server is this posible

just_m3. Developer · 199 posts #3

something else wrote: no ..........

It's just me who see that ctalk is assaulted by this type of requests ..?? no one is willing to learn anymore ... just request ..

i mean , what a hell is simple ... and easy .. Damn request it !!!!

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close