Author Topic: Download youtube script!!!  (Read 1948 times)

0 Members and 1 Guest are viewing this topic.

Offline Jeff

  • Global Moderator
  • Sr phpd Member
  • *****
  • Posts: 359
  • Karma: 5
  • Need help? Feel free to ask.
    • View Profile
Download youtube script!!!
« on: July 05, 2009, 12:36:29 AM »
Yes i finally got it to be a standalone script without anything fancy....

I will give you a step by step guide on how to install this mod(its very easy)


Step 1.
Create a file named download.php

Step 2.
Inside download.php insert the below code
Code: [Select]
<?php
/*
+ ----------------------------------------------------------------------------+
|     Download Script
| License: GPL General Public License
| Website: http://mvideos.co.cc
| Author: Jeff Suthers
+----------------------------------------------------------------------------+
*/
function getContent($url) {
    
$ch curl_init();
    
curl_setopt ($chCURLOPT_URL$url);
    
curl_setopt ($chCURLOPT_HEADER0);

    
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($chCURLOPT_URL$url);
curl_setopt($chCURLOPT_HEADER1);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_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;
}
}
header("Location: ".$link);
exit;
}
?>


Step 3.
Upload download.php into root your server (or where you have phpdirector uploaded)

Step 4.
Open viewvid.tpl

Step 5.
inside of viewvid.tpl insert the below code where ever you want the download button to be
Code: [Select]
{if $vidtype eq "YouTube"}
<form action="download.php" method="get">
<input type="hidden" name="item" size="32" maxlength="128" value="{if $video[video].file eq ""}{$videoid}{else}{$video[video].file}{/if}"></dd>
<input type="submit" name="submit" id="submit" value="Download Video" />
<input type="hidden" name="type" id="type" value="0" checked="checked" />
</form>
{/if}


Step 6.
Upload modified viewvid.tpl
-----------------------------------------------------------------

There you go it should now be all done

Please dont distribute this as your own or remove the header of the script( although i cant make you) I just ask you to because of how much work i put into this script
« Last Edit: July 05, 2009, 01:17:58 AM by Jeff »

Offline FireDart

  • Project Leader
  • Pro Member
  • *****
  • Posts: 406
  • Karma: 4
    • View Profile
    • FireDart
Re: Download youtube script!!!
« Reply #1 on: July 05, 2009, 02:35:03 AM »
Very Cool, may added this to My PHPDTube Template as a pre-installed Mod.

Also how are you coming with making other video sites work like Google Video and DailyMotion?

Offline Jeff

  • Global Moderator
  • Sr phpd Member
  • *****
  • Posts: 359
  • Karma: 5
  • Need help? Feel free to ask.
    • View Profile
Re: Download youtube script!!!
« Reply #2 on: July 05, 2009, 03:15:44 AM »
havnt started those yet..... but im sure i will sooner or later lol

Offline naxtra

  • Full phpd Member
  • ***
  • Posts: 74
  • Karma: 1
    • View Profile
Re: Download youtube script!!!
« Reply #3 on: July 05, 2009, 05:28:33 AM »
Excellent bro!!  :o :o

Offline Jeff

  • Global Moderator
  • Sr phpd Member
  • *****
  • Posts: 359
  • Karma: 5
  • Need help? Feel free to ask.
    • View Profile
Re: Download youtube script!!!
« Reply #4 on: July 05, 2009, 05:29:52 AM »
thank you... i try :-D

Offline Jeff

  • Global Moderator
  • Sr phpd Member
  • *****
  • Posts: 359
  • Karma: 5
  • Need help? Feel free to ask.
    • View Profile
Re: Download youtube script!!!
« Reply #5 on: July 17, 2009, 12:38:14 AM »
Bump!!!

im very surprised that this doesnt have more views yet..... i would think this would be the most liked mod..... considering how much work it took haha